All Products
Search
Document Center

Cloud Monitor:PutGroupMetricRule

Last Updated:Nov 02, 2026

Creates or modifies an alert rule in a specified application group.

Operation description

This topic provides an example of how to create an alert rule for the cpu_total monitoring metric of the Alibaba Cloud service Elastic Computing Service server in the application group 17285****. The alert rule ID is 123456, the alert rule name is Rule_test, the alert level is Critical, the statistical method is Average, the threshold comparison operator is GreaterThanOrEqualToThreshold, the threshold is 90, and the retry count is 3. The response shows that the alert rule is created and the alert rule ID is 123456.

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

create

*GroupMetricRule

acs:cms::{#accountId}:group/{#groupId}

None None

Request parameters

Parameter

Type

Required

Description

Example

GroupId

string

Yes

The ID of the application group.

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

17285****

RuleId

string

Yes

The ID of the alert rule.

  • To create an alert rule for the application group, enter an alert rule ID.

  • To modify a specified alert rule in the application group, you must obtain the alert rule ID. For more information about how to obtain the ID of an alert rule, see DescribeMetricRuleList.

123456

Category

string

No

The abbreviation of the Alibaba Cloud service name.

For more information about how to obtain the abbreviation of an Alibaba Cloud service name, see the metricCategory field in the Labels response parameter of the DescribeProjectMeta operation.

ECS

RuleName

string

Yes

The name of the alert rule.

  • To create an alert rule for the application group, enter an alert rule name.

  • To modify a specified alert rule in the application group, you must obtain the alert rule name. For more information about how to obtain the name of an alert rule, see DescribeMetricRuleList.

Rule_01

Namespace

string

Yes

The namespace of the Alibaba Cloud service.

For more information about how to obtain the namespace of an Alibaba Cloud service, see DescribeMetricMetaList or cloud service monitoring metrics.

acs_ecs_dashboard

MetricName

string

Yes

The name of the monitoring metric.

For more information about how to obtain the name of a monitoring metric, see DescribeMetricMetaList or cloud service monitoring metrics.

cpu_total

Dimensions

string

No

The first-level dimension of the alert rule in the application group.

Format: a collection of key:value pairs. Examples: {"userId":"120886317861****"} and {"instanceId":"i-m5e1qg6uo38rztr4****"}.

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

ExtraDimensionJson

string

No

The second-level or third-level dimension of the alert rule in the application group.

Format: a collection of key:value pairs. Examples: port:80 and /dev/xvda:d-m5e6yphgzn3aprwu****.

If the first-level dimension of the alert rule is {"instanceId":"i-m5e1qg6uo38rztr4****"}, the second-level dimension is the cloud disk in the instance, such as {"/dev/xvda":"d-m5e6yphgzn3aprwu****"}.

{"/dev/xvda":"d-m5e6yphgzn3aprwu****"}

EffectiveInterval

string

No

The effective period of the alert rule.

05:31-23:59

NoEffectiveInterval

string

No

The time range during which the alert rule is inactive.

00:00-05:30

SilenceTime

integer

No

The mute for epoch.

Unit: seconds. Default value: 86400.

86400

Period

string

No

The reporting period of monitoring data.

The value of Period must be 60 or a multiple of 60. Unit: seconds. Default value: 300.

60

Interval

string

No

The detection period of the alert rule. Unit: seconds.

Note

Set the detection period of the alert rule to the same value as the data reporting period. If the detection period is shorter than the data reporting period, alerts cannot be triggered due to insufficient data.

60

Webhook

string

No

The webhook URL that is called when an alert is triggered.

Enter a publicly accessible URL. CloudMonitor pushes alert notifications to this URL by sending POST requests. Only HTTP is supported.

https://www.aliyun.com

EmailSubject

string

No

The subject of the alert email.

ECS instance

ContactGroups

string

No

The alert contact groups.

ECS_Group

Escalations.Critical.Statistics

string

No

The statistical method for Critical-level alerts. Separate multiple statistical methods with commas (,).

The valid values of this parameter are determined by the Statistics column that corresponds to the MetricName of the specified Alibaba Cloud service. Examples: Maximum, Minimum, and Average. For more information about how to obtain the valid values of this parameter, see cloud service monitoring metrics.

Average

Escalations.Critical.ComparisonOperator

string

No

The threshold comparison operator for Critical-level alerts. Valid values:

  • GreaterThanOrEqualToThreshold: greater than or equal to the threshold

  • GreaterThanThreshold: greater than the threshold

  • LessThanOrEqualToThreshold: less than or equal to the threshold

  • LessThanThreshold: less than the threshold

  • NotEqualToThreshold: not equal to the threshold

  • 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

GreaterThanOrEqualToThreshold

Escalations.Critical.Threshold

string

No

The threshold for Critical-level alerts.

90

Escalations.Critical.Times

integer

No

The number of retries for Critical-level alerts.

3

Escalations.Warn.Statistics

string

No

The statistical method for Warn-level alerts. Separate multiple statistical methods with commas (,).

The valid values of this parameter are determined by the Statistics column that corresponds to the MetricName of the specified Alibaba Cloud service. Examples: Maximum, Minimum, and Average. For more information about how to obtain the valid values of this parameter, see cloud service monitoring metrics.

Average

Escalations.Warn.ComparisonOperator

string

No

The threshold comparison operator for Warn-level alerts. Valid values:

  • GreaterThanOrEqualToThreshold: greater than or equal to the threshold

  • GreaterThanThreshold: greater than the threshold

  • LessThanOrEqualToThreshold: less than or equal to the threshold

  • LessThanThreshold: less than the threshold

  • NotEqualToThreshold: not equal to the threshold

  • 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

GreaterThanOrEqualToThreshold

Escalations.Warn.Threshold

string

No

The threshold for Warn-level alerts.

90

Escalations.Warn.Times

integer

No

The number of retries for Warn-level alerts.

3

Escalations.Info.Statistics

string

No

The statistical method for Info-level alerts. Separate multiple statistical methods with commas (,).

The valid values of this parameter are determined by the Statistics column that corresponds to the MetricName of the specified Alibaba Cloud service. Examples: Maximum, Minimum, and Average. For more information about how to obtain the valid values of this parameter, see cloud service monitoring metrics.

Average

Escalations.Info.ComparisonOperator

string

No

The threshold comparison operator for Info-level alerts. Valid values:

  • GreaterThanOrEqualToThreshold: greater than or equal to the threshold

  • GreaterThanThreshold: greater than the threshold

  • LessThanOrEqualToThreshold: less than or equal to the threshold

  • LessThanThreshold: less than the threshold

  • NotEqualToThreshold: not equal to the threshold

  • 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

GreaterThanOrEqualToThreshold

Escalations.Info.Threshold

string

No

The threshold for Info-level alerts.

90

Escalations.Info.Times

integer

No

The number of retries for Info-level alerts.

3

NoDataPolicy

string

No

The action to take when no monitoring data is found. Valid values:

  • KEEP_LAST_STATE: Takes no action. This is the default value.

  • INSUFFICIENT_DATA: Sends an alert notification indicating that no data is found.

  • OK: Sends an alert notification indicating that the status is normal.

KEEP_LAST_STATE

Labels

array<object>

No

The tags of the alert rule.

Alert notifications include the tags.

object

No

None.

Key

string

No

The tag key of the alert rule.

key1

Value

string

No

The tag value of the alert rule.

value1

Options

string

No

The advanced settings.

Format: {"key1":"value1","key2":"value2"}. Example: {"NotSendOK":true}, which specifies whether to send alert recovery notifications. The key is NotSendOK, and the value is true (do not send) or false (send, which is the default).

{"NotSendOK":true}

DryRun

boolean

No

Specifies whether to only precheck the request. Valid values:

  • true: sends a check request and does not perform the actual operation. The system checks whether required parameters are specified, the request format is valid, and service limits are met. If the check fails, the system returns an error. If the check succeeds, the system returns the error code DryRunOperation.

  • false: sends a normal request. If the check succeeds, the system returns an HTTP 2xx status code and performs the operation. This is the default value.

false

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

Response elements

Element

Type

Description

Example

object

None.

Code

string

The HTTP status code.

Note

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

200

Message

string

The error message.

The Request is not authorization.

RequestId

string

The request ID.

461CF2CD-2FC3-4B26-8645-7BD27E7D0F1D

Success

boolean

Indicates whether the operation is successful. Valid values:

  • true: The operation is successful.

  • false: The operation fails.

true

Result

object

The result of creating or modifying the alert rule.

RuleId

string

The ID of the alert rule.

123456

Examples

Success response

JSON format

{
  "Code": "200",
  "Message": "The Request is not authorization.",
  "RequestId": "461CF2CD-2FC3-4B26-8645-7BD27E7D0F1D",
  "Success": true,
  "Result": {
    "RuleId": "123456"
  }
}

Error codes

HTTP status code

Error code

Error message

Description

400 %s %s
499 %s %s
412 DryRunOperation %s. dryRun Pre-Verification Results
500 %s %s
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.