All Products
Search
Document Center

CloudMonitor:CreateHybridMonitorTask

Last Updated:Mar 01, 2024

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

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

Authorization information

There is currently no authorization information disclosed in the API.

Request parameters

ParameterTypeRequiredDescriptionExample
NamespacestringYes

The name of the namespace.

For information about how to obtain the name of a namespace, see DescribeHybridMonitorNamespaceList .

aliyun
DescriptionstringNo

The description of the metric import task.

TaskNamestringNo

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 Simple Log Service.
aliyun_task
TaskTypestringYes

The type of the metric import task. Valid values:

  • aliyun_fc: metric import tasks for Alibaba Cloud services.
  • aliyun_sls: metrics for logs imported from Simple Log Service.
aliyun_fc
CollectTargetTypestringYes

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.
aliyun_fc
CollectIntervalstringNo

The collection period of the metric. Valid values:

  • 15
  • 60 (default)

Unit: seconds.

Note This parameter is required only if the TaskType parameter is set to aliyun_sls.
60
GroupIdstringNo

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****
YARMConfigstringNo

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.
products:- namespace: acs_ecs_dashboard metric_info: - metric_list: - cpu_total
TargetUserIdstringNo

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****
AttachLabelsobject []No

The tags of the metric.

Note This parameter is required only if the TaskType parameter is set to aliyun_sls.
ValuestringNo

The tag value of the metric.

testValue
NamestringNo

The tag key of the metric.

app_service
TargetUserIdListstringNo

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****
SLSProcessConfigobjectNo

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.
FilterobjectNo

The conditions that are used to filter logs imported from Simple Log Service.

RelationstringNo

The relationship between multiple filter conditions. Valid values:

  • and (default): Logs are processed only if all filter conditions are met.
  • or: Logs are processed if one of the filter conditions is met.
and
Filtersobject []No

The conditions that are used to filter logs imported from Simple Log Service.

SLSKeyNamestringNo

The name of the key that is used to filter logs imported from Simple Log Service.

code
OperatorstringNo

The method that is used to filter logs imported from Simple 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
=
ValuestringNo

The value of the key that is used to filter logs imported from Simple Log Service.

200
Statisticsobject []No

The method that is used to aggregate logs imported from Simple Log Service.

SLSKeyNamestringNo

The name of the key that is used to aggregate logs imported from Simple Log Service.

name
FunctionstringNo

The function that is used to aggregate the log data of a statistical period. Valid values:

  • count: counts the number.
  • sum: calculates the total value.
  • avg: calculates the average value.
  • max: calculates the maximum value.
  • min: calculates the minimum value.
  • value: collects samples within the statistical period.
  • countps: calculates the number of values of the specified field divided by the total number of seconds within a statistical period.
  • sumps: calculates the sum of the values of the specified field divided by the total number of seconds within a statistical period.
  • distinct: calculates the number of unique values of the specified field within a statistical period.
  • distribution: calculates 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.
count
AliasstringNo

The alias of the aggregation result.

level_count
Parameter1stringNo

The value of the function that is used to aggregate logs imported from Simple Log Service.

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

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
GroupByobject []No

The dimension based on which data is aggregated. This parameter is equivalent to the GROUP BY clause in SQL.

SLSKeyNamestringNo

The name of the key that is used to aggregate logs imported from Simple Log Service.

code
AliasstringNo

The alias of the aggregation result.

ApiResult
Expressobject []No

The extended fields that specify the results of basic operations performed on aggregation results.

ExpressstringNo

The extended field that specifies the result of basic operations performed on aggregation results.

success_count
AliasstringNo

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

ParameterTypeDescriptionExample
object

None.

Codestring

The response code.

Note The status code 200 indicates that the request was successful.
200
Messagestring

The error message returned.

yamlConfigFail
RequestIdstring

The request ID.

28CEA2E0-3E90-51B2-A7E8-B1ED75534E49
Successstring

Indicates whether the request was successful. Valid values:

  • true
  • false
true
TaskIdlong

The ID of the monitoring task.

36****

Examples

Sample success responses

JSONformat

{
  "Code": "200",
  "Message": "yamlConfigFail",
  "RequestId": "28CEA2E0-3E90-51B2-A7E8-B1ED75534E49",
  "Success": "true",
  "TaskId": 0
}

Error codes

HTTP status codeError codeError message
400%s%s
500InternalErrorThe request processing has failed due to some unknown error.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2023-12-21The Error code has changed. The request parameters of the API has changedsee changesets
Change itemChange content
Error CodesThe Error code has changed.
    delete Error Codes: 400
    delete Error Codes: 403
    delete Error Codes: 404
    delete Error Codes: 409
    delete Error Codes: 500
Input ParametersThe request parameters of the API has changed.
    Added Input Parameters: CloudAccessId
2021-12-09The Error code has changed. The request parameters of the API has changedsee changesets
Change itemChange content
Error CodesThe Error code has changed.
    delete Error Codes: 400
    delete Error Codes: 403
    delete Error Codes: 404
    delete Error Codes: 409
    delete Error Codes: 500
Input ParametersThe request parameters of the API has changed.
    Added Input Parameters: TargetUserIdList