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

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

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.

  • If the TaskType parameter is set to aliyun_fc, enter the name of the metric import task.
  • If the TaskType parameter is set to aliyun_sls, enter the name of the metric for logs imported from Log Service.
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:

  • aliyun_fc: creates a metric import task for an Alibaba Cloud service
  • aliyun_sls: creates a metric for logs imported from Log Service
CollectTargetType String Yes aliyun_fc

The type of the collection target.

  • If the TaskType parameter is set to aliyun_fc, enter aliyun_fc.
  • If the TaskType parameter is set to aliyun_sls, enter the name of the Logstore group.
CollectInterval String No 60

The interval at which metrics are collected. Valid values:

  • 15
  • 60 (default value)

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.

  • namespace: the namespace of the Alibaba Cloud service. For information about how to query the namespace of an Alibaba Cloud service, see DescribeMetricMetaList.
  • metric_list: the metrics of the Alibaba Cloud service. For information about how to query the metrics of an Alibaba Cloud service, see DescribeMetricMetaList.

The following code shows a sample configuration file:


products:
- namespace: acs_ecs_dashboard
  metric_info:
  - metric_list:
    - cpu_total
    - cpu_idle
    - diskusage_utilization
    - CPUUtilization
    - DiskReadBPS
    - InternetOut
    - IntranetOut
    - cpu_system
- namespace: acs_rds_dashboard
  metric_info:
  - metric_list:
    - MySQL_QPS
    - MySQL_TPS
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:

  • and (default value): Logs are processed only if all filter conditions are met.
  • or: Logs are processed if one of the filter conditions is met.
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:

  • contain: contains
  • notContain: does not contain
  • >: greater than
  • <: less than
  • =: equal to
  • ! =: not equal to
  • >=: greater than or equal to
  • <=: less than or equal to
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:

  • count: counts the number.
  • sum: calculates the total value.
  • avg: calculates the average value.
  • max: selects the maximum value.
  • min: selects the minimum value.
  • value: collects samples within the statistical period.
  • countps: calculates the counted number of the specified field divided by the total number of seconds within the statistical period.
  • sumps: calculates the total value of the specified field divided by the total number of seconds within the statistical period.
  • distinct: counts the number of logs where the specified field appears within the statistical period.
  • distribution: counts the number of logs that meet a specified condition within the statistical period.
  • percentile: sorts the values of the specified field in ascending order, and then returns the value that is at the specified percentile within the statistical period. Example: P50.
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.

  • If you set the Function parameter to distribution, this parameter specifies the lower 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 200.
  • If you set the Function parameter to percentile, this parameter specifies the percentile at which the expected value is. For example, 0.5 specifies P50.
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:

  • true: The call was successful.
  • false: The call failed.
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.