Creates a metric import task for an Alibaba Cloud service or creates a metric for logs imported from Log Service.
Prerequisites
- Hybrid Cloud Monitoring is activated. For more information, see Activate Hybrid Cloud Monitoring.
- If you want to create a metric for logs imported from Log Service, make sure that you have activated Log Service and created a project and a Logstore. For more information, see Getting Started.
Usage notes
This topic provides an example to show how to create a metric import task named aliyun_task
for Elastic Compute Service (ECS). The task imports the cpu_total
metric to the aliyun
namespace. The response shows that the metric import task is created.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | CreateHybridMonitorTask |
The operation that you want to perform. Set the value to CreateHybridMonitorTask. |
Namespace | String | Yes | aliyun |
The name of the namespace. For information about how to obtain the name of a namespace, see DescribeHybridMonitorNamespaceList. |
Description | String | No | The metric import task for an Alibaba Cloud service |
The description of the metric import task. |
TaskName | String | No | aliyun_task |
The name of the metric import task.
|
TaskType | String | Yes | aliyun_fc |
Specifies whether to create a metric import task for an Alibaba Cloud service or create a metric for logs imported from Log Service. Valid values:
|
CollectTargetType | String | Yes | aliyun_fc |
The type of the collection target.
|
CollectInterval | String | No | 60 |
The interval at which metrics are collected. Valid values:
Unit: seconds. Note This parameter is required only if the
TaskType parameter is set to aliyun_sls .
|
GroupId | String | No | 3607**** |
The ID of the application group. For information about how to obtain the ID of an application group, see DescribeMonitorGroups. Note This parameter is required only if the
TaskType parameter is set to aliyun_sls .
|
YARMConfig | String | No | products:- namespace: acs_ecs_dashboard metric_info: - metric_list: - cpu_total |
The configuration file of the Alibaba Cloud service that you want to monitor by using Hybrid Cloud Monitoring.
The following code shows a sample configuration file:
Note This parameter is required only if the
TaskType parameter is set to aliyun_fc .
|
TargetUserId | String | No | 120886317861**** |
The ID of the member account. If you call API operations by using a management account, you can connect the Alibaba Cloud services that are activated for a member account in a resource directory to Hybrid Cloud Monitoring. You can use the resource directory to monitor Alibaba Cloud services across enterprise accounts. Note This parameter is required only if the
TaskType parameter is set to aliyun_fc .
|
AttachLabels.N.Value | String | No | testValue |
The tag value of the metric. |
AttachLabels.N.Name | String | No | app_service |
The tag key of the metric. |
TargetUserIdList | String | No | 120886317861**** |
The IDs of the member accounts. Separate multiple member account IDs with commas (,). Note This parameter is required only if you call this operation by using the management
account.
|
SLSProcessConfig | Object | No |
The configurations of the logs that are imported from Log Service. Note This parameter is required only if the
TaskType parameter is set to aliyun_sls .
|
|
Filter | Object | No |
The conditions that are used to filter logs imported from Log Service. |
|
Relation | String | No | and |
The relationship between multiple filter conditions. Valid values:
|
Filters | Array | No |
The conditions that are used to filter logs imported from Log Service. |
|
SLSKeyName | String | No | code |
The name of the key that is used to filter logs imported from Log Service. |
Operator | String | No | = |
The method that is used to filter logs imported from Log Service. Valid values:
|
Value | String | No | 200 |
The value of the key that is used to filter logs imported from Log Service. |
Statistics | Array | No |
The method that is used to aggregate logs imported from Log Service. |
|
SLSKeyName | String | No | name |
The name of the key that is used to aggregate logs imported from Log Service. |
Function | String | No | count |
The function that is used to aggregate log data within a statistical period. Valid values:
|
Alias | String | No | level_count |
The alias of the aggregation result. |
Parameter1 | String | No | 200 |
The value of the function that is used to aggregate logs imported from Log Service.
|
Parameter2 | String | No | 299 |
The value of the function that is used to aggregate logs imported from Log Service. Note This parameter is required only if the
Function parameter is set to distribution . This parameter specifies the upper limit of the statistical interval. For example,
if you want to calculate the number of HTTP requests whose status code is 2XX, set
this parameter to 299.
|
GroupBy | Array | No |
The dimension based on which data is aggregated. This parameter is equivalent to the GROUP BY clause in SQL. |
|
SLSKeyName | String | No | code |
The name of the key that is used to aggregate logs imported from Log Service. |
Alias | String | No | ApiResult |
The alias of the aggregation result. |
Express | Array | No |
The extended fields that specify the results of basic operations that are performed on aggregation results. |
|
Express | String | No | success_count |
The extended field that specifies the result of basic operations that are performed on aggregation results. |
Alias | String | No | SuccRate |
The alias of the extended field that specifies the result of basic operations that are performed on aggregation results. |
For more information about common request parameters, see Common parameters.
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
Code | String | 200 |
The HTTP status code. Note The status code 200 indicates that the call was successful.
|
Message | String | yamlConfigFail |
The error message. |
RequestId | String | 28CEA2E0-3E90-51B2-A7E8-B1ED75534E49 |
The ID of the request. |
Success | String | true |
Indicates whether the call was successful. Valid values:
|
TaskId | Long | 36**** |
The ID of the metric import task. |
Examples
Sample requests
http(s)://[Endpoint]/?Action=CreateHybridMonitorTask
&Namespace=aliyun
&TaskName=aliyun_task
&TaskType=aliyun_fc
&YARMConfig=products:
- namespace: acs_ecs_dashboard
metric_info:
- metric_list:
- cpu_total
&<Common request parameters>
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<CreateHybridMonitorTaskResponse>
<TaskId>36****</TaskId>
<RequestId>28CEA2E0-3E90-51B2-A7E8-B1ED75534E49</RequestId>
<Code>200</Code>
<Success>true</Success>
</CreateHybridMonitorTaskResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"TaskId" : "36****",
"RequestId" : "28CEA2E0-3E90-51B2-A7E8-B1ED75534E49",
"Code" : 200,
"Success" : true
}
Error codes
For a list of error codes, visit the API Error Center.