All Products
Search
Document Center

Cloud Monitor:PutResourceMetricRules

Last Updated:Nov 02, 2026

Sets multiple threshold alert rules for a specified metric of a specified resource.

Operation description

This topic provides an example on how to configure a threshold alert rule for the cpu_total metric of the Elastic Compute Service (ECS) instance i-uf6j91r34rnwawoo**** in the acs_ecs_dashboard namespace. The alert contact group for the alert rule is ECS_Group, the alert rule name is test123, the alert rule ID is a151cd6023eacee2f0978e03863cc1697c89508****, the statistical method for the Critical level is Average, the comparison operator for the Critical level is GreaterThanOrEqualToThreshold, the threshold for the Critical level is 90, and the alert retry count for the Critical level is 3.

Note

On August 15, 2024, validation for Statistics was added. The statistical value must match the Statistics of the corresponding metric. For more information about how to obtain the value of this parameter, see Alibaba Cloud service metrics.

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:PutResourceMetricRules

create

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

Rules

array<object>

Yes

The list of threshold alert rules.

Valid values of N: 1 to 50.

array<object>

No

None.

Escalations.Info.Threshold

string

No

The alert threshold for the Info level.

Note

You must set at least one of the following alert levels: Critical, Warn, and Info. The Statistics, ComparisonOperator, Threshold, and Times parameters must be set at the same time for the specified alert level.

90

MetricName

string

No

The name of the metric.

Valid values of N: 1 to 50.

For more information about how to query the name of a metric, see Alibaba Cloud service metrics.

cpu_total

Escalations.Warn.Threshold

string

No

The alert threshold for the Warn level.

Valid values of N: 1 to 50.

Note

You must set at least one of the following alert levels: Critical, Warn, and Info. The Statistics, ComparisonOperator, Threshold, and Times parameters must be set at the same time for the specified alert level.

90

EffectiveInterval

string

No

The effective period of the alert rule.

Valid values of N: 1 to 50.

00:00-23:59

NoEffectiveInterval

string

No

The time range during which the alert rule is ineffective.

Valid values of N: 1 to 50.

00:00-06:00

RuleId

string

Yes

The ID of the alert rule.

Valid values of N: 1 to 50.

You can enter a new alert rule ID or use an existing alert rule ID in CloudMonitor. For more information about how to query the ID of an alert rule, see DescribeMetricRuleList.

Note

If you enter a new alert rule ID, a threshold alert rule is created.

a151cd6023eacee2f0978e03863cc1697c89508****

Escalations.Critical.Times

integer

No

The number of alert retries for the Critical level.

Valid values of N: 1 to 50.

Note

You must set at least one of the following alert levels: Critical, Warn, and Info. The Statistics, ComparisonOperator, Threshold, and Times parameters must be set at the same time for the specified alert level.

3

Escalations.Critical.Threshold

string

No

The alert threshold for the Critical level.

Valid values of N: 1 to 50.

Note

You must set at least one of the following alert levels: Critical, Warn, and Info. The Statistics, ComparisonOperator, Threshold, and Times parameters must be set at the same time for the specified alert level.

90

Escalations.Critical.Statistics

string

No

The statistical method for the Critical level.

Valid values of N: 1 to 50.

The value of this parameter is determined by the Statistics column that corresponds to the MetricName of the specified Alibaba Cloud service, such as Maximum, Minimum, and Average. For more information about how to obtain the value of this parameter, see Alibaba Cloud service metrics.

Note

You must configure at least one of the following alert levels: Critical, Warn, and Info. The Statistics, ComparisonOperator, Threshold, and Times parameters must be configured at the same time for the specified alert level.

Average

Escalations.Warn.ComparisonOperator

string

No

The comparison operator for the Warn level. Valid values:

  • GreaterThanOrEqualToThreshold: greater than or equal to.

  • GreaterThanThreshold: greater than.

  • LessThanOrEqualToThreshold: less than or equal to.

  • LessThanThreshold: less than.

  • NotEqualToThreshold: not equal to.

  • EqualToThreshold: equal to.

  • GreaterThanYesterday: greater than the value at the same time yesterday.

  • LessThanYesterday: less than the value at the same time yesterday.

  • GreaterThanLastWeek: greater than the value at the same time last week.

  • LessThanLastWeek: less than the value at the same time last week.

  • GreaterThanLastPeriod: greater than the value in the last period.

  • LessThanLastPeriod: less than the value in the last period.

Valid values of N: 1 to 50.

Note

You must set at least one of the following alert levels: Critical, Warn, and Info. The Statistics, ComparisonOperator, Threshold, and Times parameters must be set at the same time for the specified alert level.

GreaterThanOrEqualToThreshold

Escalations.Info.Times

integer

No

The number of alert retries for the Info level.

Valid values of N: 1 to 50.

Note

You must set at least one of the following alert levels: Critical, Warn, and Info. The Statistics, ComparisonOperator, Threshold, and Times parameters must be set at the same time for the specified alert level.

3

Resources

string

Yes

The resource information, such as [{"instanceId":"i-uf6j91r34rnwawoo****"}] and [{"userId":"100931896542****"}].

Valid values of N: 1 to 50.

For more information about the dimensions supported by resource information, see Alibaba Cloud service metrics.

[{"instanceId":"i-uf6j91r34rnwawoo****"}]

SilenceTime

integer

No

The mute epoch.

Unit: seconds. Default value: 86400.

Valid values of N: 1 to 50.

Note

The mute epoch refers to the interval before the system can send an alert notification again if the alert is not cleared after it is triggered.

86400

Webhook

string

No

The webhook URL to which a POST request is sent when an alert is triggered.

Valid values of N: 1 to 50.

https://alert.aliyun.com.com:8080/callback

ContactGroups

string

Yes

The alert contact group. Alert notifications are sent to the alert contacts in this alert contact group.

Valid values of N: 1 to 50.

Note

An alert contact group is a group of alert contacts and can contain one or more alert contacts. For more information about how to create an alert contact and an alert contact group, see PutContact and PutContactGroup.

ECS_Group

Namespace

string

Yes

The data namespace of the Alibaba Cloud service.

Valid values of N: 1 to 50.

For more information about how to query the data namespace of an Alibaba Cloud service, see Alibaba Cloud service metrics.

acs_ecs_dashboard

EmailSubject

string

No

The subject of the alert email.

Valid values of N: 1 to 50.

ECS instance alert

Period

string

No

The statistical period of the metric.

Unit: seconds. The default value is the original reporting period of the metric.

Valid values of N: 1 to 50.

Note

For more information about how to query the statistical period of a metric, see Alibaba Cloud service metrics.

60

RuleName

string

Yes

The name of the alert rule.

Valid values of N: 1 to 50.

You can enter a new alert rule name or use an existing alert rule name in CloudMonitor. For more information about how to query the name of an alert rule, see DescribeMetricRuleList.

Note

If you enter a new alert rule name, a threshold alert rule is created.

test123

Escalations.Info.Statistics

string

No

The statistical method for the Info level.

Valid values of N: 1 to 50.

The value of this parameter is determined by the Statistics column that corresponds to the MetricName of the specified Alibaba Cloud service, such as Maximum, Minimum, and Average. For more information about how to obtain the value of this parameter, see Alibaba Cloud service metrics.

Note

You must configure at least one of the following alert levels: Critical, Warn, and Info. The Statistics, ComparisonOperator, Threshold, and Times parameters must be configured at the same time for the specified alert level.

Average

Escalations.Warn.Times

integer

No

The number of alert retries for the Warn level.

Valid values of N: 1 to 50.

Note

You must set at least one of the following alert levels: Critical, Warn, and Info. The Statistics, ComparisonOperator, Threshold, and Times parameters must be set at the same time for the specified alert level.

3

Escalations.Info.ComparisonOperator

string

No

The comparison operator for the Info level. Valid values:

  • GreaterThanOrEqualToThreshold: greater than or equal to.

  • GreaterThanThreshold: greater than.

  • LessThanOrEqualToThreshold: less than or equal to.

  • LessThanThreshold: less than.

  • NotEqualToThreshold: not equal to.

  • EqualToThreshold: equal to.

  • GreaterThanYesterday: greater than the value at the same time yesterday.

  • LessThanYesterday: less than the value at the same time yesterday.

  • GreaterThanLastWeek: greater than the value at the same time last week.

  • LessThanLastWeek: less than the value at the same time last week.

  • GreaterThanLastPeriod: greater than the value in the last period.

  • LessThanLastPeriod: less than the value in the last period.

Valid values of N: 1 to 50.

Note

You must set at least one of the following alert levels: Critical, Warn, and Info. The Statistics, ComparisonOperator, Threshold, and Times parameters must be set at the same time for the specified alert level.

GreaterThanOrEqualToThreshold

Interval

string

No

The trigger period of the alert rule.

Unit: seconds.

Valid values of N: 1 to 50.

Note

For more information about how to query the statistical period of a metric, see Alibaba Cloud service metrics.

60

Escalations.Critical.ComparisonOperator

string

No

The comparison operator for the Critical level. Valid values:

  • GreaterThanOrEqualToThreshold: greater than or equal to.

  • GreaterThanThreshold: greater than.

  • LessThanOrEqualToThreshold: less than or equal to.

  • LessThanThreshold: less than.

  • NotEqualToThreshold: not equal to.

  • EqualToThreshold: equal to.

  • GreaterThanYesterday: greater than the value at the same time yesterday.

  • LessThanYesterday: less than the value at the same time yesterday.

  • GreaterThanLastWeek: greater than the value at the same time last week.

  • LessThanLastWeek: less than the value at the same time last week.

  • GreaterThanLastPeriod: greater than the value in the last period.

  • LessThanLastPeriod: less than the value in the last period.

Valid values of N: 1 to 50.

Note

You must set at least one of the following alert levels: Critical, Warn, and Info. The Statistics, ComparisonOperator, Threshold, and Times parameters must be set at the same time for the specified alert level.

GreaterThanOrEqualToThreshold

Escalations.Warn.Statistics

string

No

The statistical method for the Warn level.

Valid values of N: 1 to 50.

The value of this parameter is determined by the Statistics column that corresponds to the MetricName of the specified Alibaba Cloud service, such as Maximum, Minimum, and Average. For more information about how to obtain the value of this parameter, see Alibaba Cloud service metrics.

Note

You must configure at least one of the following alert levels: Critical, Warn, and Info. The Statistics, ComparisonOperator, Threshold, and Times parameters must be configured at the same time for the specified alert level.

Average

NoDataPolicy

string

No

The handling method when no monitoring data is available. Valid values:

  • KEEP_LAST_STATE: No action is taken. This is the default value.

  • INSUFFICIENT_DATA: The alert content indicates that no data is available.

  • OK: Normal.

Valid values of N: 1 to 50.

KEEP_LAST_STATE

Labels

array<object>

No

The labels that are written to the metric and displayed in the alert notification when the metric meets the alert condition and an alert is triggered.

object

No

None.

Key

string

No

The label key.

tagKey1

Value

string

No

The label value.

Note

The label value supports template parameters. The template parameters are replaced with the actual label values.

ECS

SendOK

boolean

No

Specifies whether to send a recovery notification.

true

DryRun

boolean

No

Specifies whether to only precheck the request. Valid values:

  • true: A check request is sent, and no security group is associated with the instance. The check items include whether required parameters are specified, the request format, and service limits. If the check fails, an error is returned. If the check succeeds, the error code DryRunOperation is returned.

  • false: A normal request is sent. If the check succeeds, an HTTP 2xx status code is returned and the operation is performed. This is the default value.

true

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 value of 200 indicates success.

200

Message

string

The error message.

The request processing has failed due to some unknown error.

RequestId

string

The request ID.

15D1440E-BF24-5A41-93E4-36864635179E

Success

boolean

Indicates whether the operation was successful. Valid values:

  • true: The operation was successful.

  • false: The operation failed.

true

FailedListResult

object

Target

array<object>

The list of failure results for setting alert rules for resources.

array<object>

None.

RuleId

string

The ID of the alert rule.

a151cd6023eacee2f0978e03863cc1697c89508****

Result

object

The failure result.

Code

string

The status code.

404

Message

string

The error message.

The request processing has failed due to some unknown error.

Success

boolean

Indicates whether the operation was successful. Valid values:

  • true: The operation was successful.

  • false: The operation failed.

false

Examples

Success response

JSON format

{
  "Code": "200",
  "Message": "The request processing has failed due to some unknown error.",
  "RequestId": "15D1440E-BF24-5A41-93E4-36864635179E",
  "Success": true,
  "FailedListResult": {
    "Target": [
      {
        "RuleId": "a151cd6023eacee2f0978e03863cc1697c89508****",
        "Result": {
          "Code": "404",
          "Message": "The request processing has failed due to some unknown error.",
          "Success": false
        }
      }
    ]
  }
}

Error codes

HTTP status code

Error code

Error message

Description

400 %s %s
422 %s %s
499 %s %s
412 DryRunOperation %s. dryRun Pre-Verification Results
500 InternalError The request processing has failed due to some unknown error.
204 %s %s
403 %s %s
206 %s %s
404 %s %s
503 %s %s
406 %s %s

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.