All Products
Search
Document Center

Cloud Monitor:CreateHybridMonitorTask

Last Updated:Jul 10, 2026

Creates a monitoring task for Alibaba Cloud services or Simple Log Service (SLS) logs in Hybrid Cloud Monitoring.

Operation description

Operation description

  • Before calling this operation, make sure that Hybrid Cloud Monitoring is activated.

  • To create a metric for SLS logs, make sure that SLS is activated and that a project and a Logstore are created.

  • Depending on the value of TaskType, some parameters are required. For example, if TaskType is set to aliyun_fc, you must configure YARMConfig. If TaskType is set to aliyun_sls, you must configure parameters such as CollectInterval.

  • For cross-account operations, specify TargetUserId or TargetUserIdList to connect resources of other members to Hybrid Cloud Monitoring.

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

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

aliyun

Description

string

No

The description of the monitoring task.

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

TaskName

string

No

The name of the monitoring task.

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

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

aliyun_task

TaskType

string

Yes

The type of the monitoring task. Valid values:

  • aliyun_fc: a data import task for Alibaba Cloud services.

  • 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 for monitoring data.

  • If TaskType is set to aliyun_fc, enter aliyun_fc.

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

aliyun_fc

CollectInterval

string

No

The collection period of the metric. Valid values:

  • 15

  • 60 (default)

Unit: seconds.

Note

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

Valid values:

  • 15 :

    15

  • 60 :

    60

60

GroupId

string

No

The application group ID.

For information about how to obtain the application group ID, see DescribeMonitorGroups.

Note

This parameter is required only when TaskType is set 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 example shows the 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 when TaskType is set to aliyun_fc.

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

TargetUserId

string

No

The member ID.

When you invoke this operation by using a management account, you can use cloud native mode to connect Alibaba Cloud services of any member in the resource folder to Hybrid Cloud Monitoring. This allows you to implement cross-account unified monitoring of Alibaba Cloud services through the resource folder. Go to Settings to configure this feature in the CloudMonitor console.

Note

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

120886317861****

AttachLabels

array<object>

No

The labels of the metric.

Note

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

object

No

None.

Value

string

No

The label value of the metric.

testValue

Name

string

No

The label key of the metric.

app_service

TargetUserIdList

string

No

The member IDs. Separate multiple member IDs with commas (,).

Note

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

120886317861****

SLSProcessConfig

object

No

The SLS log configuration.

Note

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

Filter

object

No

The filter conditions for parameters in SLS logs.

Relation

string

No

The relationship between multiple filter conditions. Valid values:

  • and (default): Logs are processed only when all filter conditions are met.

  • or: Logs are processed when any filter condition is met.

Valid values:

  • or :

    or

  • and :

    and

and

Filters

array<object>

No

The list of filter conditions for parameters in SLS logs.

object

No

None.

SLSKeyName

string

No

The name of the parameter to filter in SLS logs.

code

Operator

string

No

The filter method for parameter values in SLS logs. 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 filter value of the parameter in SLS logs.

200

Statistics

array<object>

No

The statistical method for SLS logs.

object

No

None.

SLSKeyName

string

No

The name of the parameter for SLS log statistics.

name

Function

string

No

Aggregates log data within the statistical period based on the selected statistical method. Valid values:

  • count: counts the number of occurrences.

  • sum: calculates the sum.

  • avg: calculates the average.

  • max: returns the maximum value.

  • min: returns the minimum value.

  • value: samples within the period.

  • countps: calculates the per-second average of the count for the specified field within the statistical period.

  • sumps: calculates the per-second average of the sum for the specified field within the statistical period.

  • distinct: calculates the number of occurrences of the specified field after deduplication within the statistical period.

  • distribution: calculates the number of occurrences of field values within a specified range.

  • percentile: calculates the distribution value of field values, such as P50.

count

Alias

string

No

The alias of the SLS log statistical result.

level_count

Parameter1

string

No

The statistical value of SLS logs.

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

  • If Function is set to percentile, this parameter specifies the percentile of the statistical distribution. For example, 0.5 indicates P50.

200

Parameter2

string

No

The statistical value of SLS logs.

Note

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

299

GroupBy

array<object>

No

Aggregates data by spatial dimension, which is equivalent to Group By in SQL.

object

No

None.

SLSKeyName

string

No

The name of the parameter for SLS log statistics.

code

Alias

string

No

The alias of the SLS log statistical result.

ApiResult

Express

array<object>

No

The arithmetic operation result of the extended field for SLS log statistical results.

object

No

None.

Express

string

No

The arithmetic operation result of the extended field for SLS log statistical results.

success_count

Alias

string

No

The alias of the arithmetic operation result of the extended field for SLS log statistical results.

SuccRate

CloudAccessId

array

No

The list of primary account IDs of other cloud providers that are connected to CloudMonitor.

string

No

The primary account ID of another cloud provider that is connected to CloudMonitor.

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

200 indicates success.

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: Successful.

  • false: Failed.

true

TaskId

integer

The monitoring task ID.

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.