All Products
Search
Document Center

Cloud Monitor:CreateHybridMonitorTask

Last Updated:Oct 30, 2025

Call the CreateHybridMonitorTask operation to create a data import task for an Alibaba Cloud service or a metric from Simple Log Service (SLS) logs.

Operation description

Usage notes

  • Make sure that you have activated Hybrid Cloud Monitoring. For more information, see Activate Hybrid Cloud Monitoring.

  • If you want to create metrics from SLS logs, make sure that you have activated Simple Log Service (SLS) and created a project and a Logstore. For more information, see Quick Start.

Instructions

This topic provides an example of how to create a data import task named aliyun_task for an Alibaba Cloud service. In this example, the cpu_total metric from Elastic Compute Service (ECS) is imported into the aliyun metric repository. The response indicates that the data import task was created.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

cms:CreateHybridMonitorTask

create

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

Namespace

string

Yes

The name of the metric repository.

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

aliyun

Description

string

No

The description of the monitoring job.

阿里云产品数据接入任务。

TaskName

string

No

The name of the monitoring job.

  • If you set TaskType to aliyun_fc, enter the name of the data import task for the Alibaba Cloud service.

  • If you set TaskType to aliyun_sls, enter the name of the metric for the SLS logs.

aliyun_task

TaskType

string

Yes

The type of the monitoring job. Valid values:

  • aliyun_fc: a data import task for an Alibaba Cloud service.

  • aliyun_sls: a metric for SLS logs.

Valid values:

  • aliyun_fc :

    aliyun_fc

  • aliyun_sls :

    aliyun_sls

aliyun_fc

CollectTargetType

string

Yes

The type of the collection target.

  • If you set TaskType to aliyun_fc, enter aliyun_fc.

  • If you set TaskType to aliyun_sls, enter the name of the Logstore group for the SLS logs.

aliyun_fc

CollectInterval

string

No

The collection period of the metric. Unit: seconds. Valid values:

  • 15

  • 60 (default)

Unit: seconds.

Note

This parameter is required only when you set TaskType to aliyun_sls.

Valid values:

  • 15 :

    15

  • 60 :

    60

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 when you set TaskType to aliyun_sls.

3607****

YARMConfig

string

No

The configuration file of the Alibaba Cloud service that is connected to 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 provides 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 when you set TaskType to aliyun_fc.

products:- namespace: acs_ecs_dashboard metric_info: - metric_list: - cpu_total

TargetUserId

string

No

The ID of the member.

If you use a management account to call this operation, you can connect the Alibaba Cloud services of any member in your resource directory to Hybrid Cloud Monitoring. This lets you centrally monitor the Alibaba Cloud services of different members across accounts.

Note

This parameter is required only when you set TaskType to aliyun_fc.

120886317861****

AttachLabels

array<object>

No

The tags of the metric.

Note

This parameter is required only when you set TaskType to aliyun_sls.

object

No

None.

Value

string

No

The value of the tag.

testValue

Name

string

No

The key of the tag.

app_service

TargetUserIdList

string

No

The IDs of the members. Separate multiple member IDs with commas (,).

Note

This parameter is required only when you call this operation using a management account.

120886317861****

SLSProcessConfig

object

No

The configurations of SLS logs.

Note

This parameter is required only when you set TaskType to aliyun_sls.

Filter

object

No

The filter conditions for the parameters in SLS logs.

Relation

string

No

The relationship between multiple filter conditions. Valid values:

  • and (default): The logs are processed only if all filter conditions are met.

  • or: The logs are processed if any of the filter conditions is met.

Valid values:

  • or :

    or

  • and :

    and

and

Filters

array<object>

No

The list of filter conditions for the parameters in SLS logs.

object

No

None.

SLSKeyName

string

No

The name of the parameter that is used to filter logs.

code

Operator

string

No

The operator that is used to filter logs based on the parameter value. 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

The value of the parameter that is used to filter logs.

200

Statistics

array<object>

No

The method that is used to aggregate the log data.

object

No

None.

SLSKeyName

string

No

The name of the parameter that is used to aggregate log data.

name

Function

string

No

The aggregate function. The log data is aggregated based on the specified function over a statistical period. Valid values:

  • count: The number of logs.

  • sum: The sum of the values of a field.

  • avg: The average value of a field.

  • max: The maximum value of a field.

  • min: The minimum value of a field.

  • value: The value that is collected in a statistical period.

  • countps: The average number of logs that are generated per second in a statistical period.

  • sumps: The average value of a field per second in a statistical period.

  • distinct: The number of unique values of a field in a statistical period.

  • distribution: The number of times that the value of a field is within a specified range.

  • percentile: The percentile of the value of a field. For example, a value of 0.5 specifies the 50th percentile.

count

Alias

string

No

The alias of the aggregation result.

level_count

Parameter1

string

No

The aggregation value.

  • If you set Function to distribution, this parameter specifies the lower limit of the statistical range. For example, to count the number of HTTP status codes 2XX, set this parameter to 200.

  • If you set Function to percentile, this parameter specifies the percentile. For example, a value of 0.5 specifies the 50th percentile.

200

Parameter2

string

No

The aggregation value.

Note

This parameter is required only when you set Function to distribution. This parameter specifies the upper limit of the statistical range. For example, to count the number of HTTP status codes 2XX, set this parameter to 299.

299

GroupBy

array<object>

No

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

object

No

None.

SLSKeyName

string

No

The name of the parameter that is used to aggregate log data.

code

Alias

string

No

The alias of the aggregation result.

ApiResult

Express

array<object>

No

The result of the basic operations that are performed on the extended fields of the aggregation result.

object

No

None.

Express

string

No

The result of the basic operations that are performed on the extended fields of the aggregation result.

success_count

Alias

string

No

The alias of the result of the basic operations that are performed on the extended fields of the aggregation result.

SuccRate

CloudAccessId

array

No

The list of main account IDs for other cloud service providers that are connected to Cloud Monitor.

string

No

The ID of the main account of another cloud service provider that is connected to Cloud Monitor.

n5n9ik1b****

For more information about common request parameters, see Common parameters.

Response elements

Element

Type

Description

Example

object

None.

Code

string

The status code.

Note

A status code of 200 indicates that the request was successful.

200

Message

string

The error message.

yamlConfigFail

RequestId

string

The request ID.

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

Success

string

Indicates whether the operation was successful. Valid values:

  • true: The operation was successful.

  • false: The operation failed.

true

TaskId

integer

The ID of the monitoring job.

36****

Examples

Success response

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

Description

400 %s %s
500 %s %s
500 InternalError The request processing has failed due to some unknown error.
403 %s %s
404 %s %s
409 %s %s

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.