Creates a metric import task for an Alibaba Cloud service or creates a metric for logs imported from Simple Log Service.
Operation description
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 Simple Log Service, make sure that you have activated Simple Log Service and created a project and a Logstore. For more information, see Getting Started.
Description
This topic provides an example on 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
Authorization information
The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action
policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:
- Operation: the value that you can use in the Action element to specify the operation on a resource.
- Access level: the access level of each operation. The levels are read, write, and list.
- Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
- The required resource types are displayed in bold characters.
- If the permissions cannot be granted at the resource level,
All Resources
is used in the Resource type column of the operation.
- Condition Key: the condition key that is defined by the cloud service.
- Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
Operation | Access level | Resource type | Condition key | Associated operation |
---|---|---|---|---|
cms:CreateHybridMonitorTask | create |
|
| none |
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
Namespace | string | Yes | The name of the namespace. For information about how to obtain the name of a namespace, see DescribeHybridMonitorNamespaceList . | aliyun |
Description | string | No | The description of the metric import task. | |
TaskName | string | No | The name of the metric import task.
| aliyun_task |
TaskType | string | Yes | The type of the metric import task. Valid values:
| aliyun_fc |
CollectTargetType | string | Yes | The type of the collection target.
| aliyun_fc |
CollectInterval | string | No | The collection period of the metric. Valid values:
Unit: seconds. Note
This parameter is required only if the TaskType parameter is set to aliyun_sls .
| 60 |
GroupId | string | No | 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 .
| 3607**** |
YARMConfig | string | No | 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 .
| products:- namespace: acs_ecs_dashboard metric_info: - metric_list: - cpu_total |
TargetUserId | string | No | The ID of the member account. If you call this operation by using the management account of a resource directory, you can connect the Alibaba Cloud services that are activated for all members in the 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 .
| 120886317861**** |
AttachLabels | array<object> | No | The tags of the metric. Note
This parameter is required only if the TaskType parameter is set to aliyun_sls .
| |
object | No | |||
Value | string | No | The tag value of the metric. | testValue |
Name | string | No | The tag key of the metric. | app_service |
TargetUserIdList | string | No | 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.
| 120886317861**** |
SLSProcessConfig | object | No | The configurations of the logs that are imported from Simple 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 Simple Log Service. | |
Relation | string | No | The relationship between multiple filter conditions. Valid values:
| and |
Filters | array<object> | No | The conditions that are used to filter logs imported from Simple Log Service. | |
object | No | |||
SLSKeyName | string | No | The name of the key that is used to filter logs imported from Simple Log Service. | code |
Operator | string | No | The method that is used to filter logs imported from Simple Log Service. Valid values:
| = |
Value | string | No | The value of the key that is used to filter logs imported from Simple Log Service. | 200 |
Statistics | array<object> | No | The method that is used to aggregate logs imported from Simple Log Service. | |
object | No | |||
SLSKeyName | string | No | The name of the key that is used to aggregate logs imported from Simple Log Service. | name |
Function | string | No | The function that is used to aggregate the log data of a statistical period. Valid values:
| count |
Alias | string | No | The alias of the aggregation result. | level_count |
Parameter1 | string | No | The value of the function that is used to aggregate logs imported from Simple Log Service.
| 200 |
Parameter2 | string | No | The value of the function that is used to aggregate logs imported from Simple 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.
| 299 |
GroupBy | array<object> | No | The dimension based on which data is aggregated. This parameter is equivalent to the GROUP BY clause in SQL. | |
object | No | |||
SLSKeyName | string | No | The name of the key that is used to aggregate logs imported from Simple Log Service. | code |
Alias | string | No | The alias of the aggregation result. | ApiResult |
Express | array<object> | No | The extended fields that specify the results of basic operations performed on aggregation results. | |
object | No | |||
Express | string | No | The extended field that specifies the result of basic operations performed on aggregation results. | success_count |
Alias | string | No | The alias of the extended field that specifies the result of basic operations performed on aggregation results. | SuccRate |
For more information about common request parameters, see Common parameters.
Response parameters
Examples
Sample success responses
JSON
format
{
"Code": "200",
"Message": "yamlConfigFail",
"RequestId": "28CEA2E0-3E90-51B2-A7E8-B1ED75534E49",
"Success": "true",
"TaskId": 0
}
Error codes
HTTP status code | Error code | Error message |
---|---|---|
400 | %s | %s |
500 | InternalError | The request processing has failed due to some unknown error. |
For a list of error codes, visit the Service error codes.
Change history
Change time | Summary of changes | Operation |
---|---|---|
2023-12-21 | The Error code has changed. The request parameters of the API has changed | View Change Details |
2021-12-09 | The Error code has changed. The request parameters of the API has changed | View Change Details |