Creates one or more alert rules for a specified application group.
Operation description
This topic provides an example to show how to create an alert rule for the cpu_total
metric of Elastic Compute Service (ECS) in the 123456
application group. The ID of the alert rule is 456789
. The name of the alert rule is ECS_Rule1
. The alert level is Critical
. The statistical method is Average
. The comparison operator is GreaterThanOrEqualToThreshold
. The alert threshold is 90
. The number of alert retries is 3
. The response shows that the alert rule named ECS_Rule1
is created.
Debugging
Authorization information
The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action
policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:
- Operation: the value that you can use in the Action element to specify the operation on a resource.
- Access level: the access level of each operation. The levels are read, write, and list.
- Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
- The required resource types are displayed in bold characters.
- If the permissions cannot be granted at the resource level,
All Resources
is used in the Resource type column of the operation.
- Condition Key: the condition key that is defined by the cloud service.
- Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
Operation | Access level | Resource type | Condition key | Associated operation |
---|---|---|---|---|
cms:CreateGroupMetricRules | create |
|
| none |
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
GroupId | long | Yes | The ID of the application group. For information about how to obtain the ID of an application group, see DescribeMonitorGroups . | 123456 |
GroupMetricRules | array<object> | No | ||
object | No | The statistical methods for Warn-level alerts. Separate multiple statistical methods with commas (,). Valid values of N: 1 to 200. Valid value:
| ||
Escalations.Info.Threshold | string | No | The threshold for Info-level alerts. Valid values of N: 1 to 200. | 10 |
MetricName | string | Yes | The name of the metric. Valid values of N: 1 to 200. For information about how to obtain the name of a metric, see DescribeMetricMetaList or Appendix 1: Metrics. | cpu_total |
Escalations.Warn.Threshold | string | No | The threshold for Warn-level alerts. Valid values of N: 1 to 200. | 20 |
EffectiveInterval | string | No | The time period during which the alert rule is effective. Valid values of N: 1 to 200. | 05:31-23:59 |
NoEffectiveInterval | string | No | The time period during which the alert rule is ineffective. Valid values of N: 1 to 200. | 00:00-05:30 |
RuleId | string | Yes | The ID of the alert rule. Valid values of N: 1 to 200. | 456789 |
Escalations.Critical.Times | integer | No | The consecutive number of times for which the metric value meets the alert condition before a Critical-level alert is triggered. Valid values of N: 1 to 200. | 3 |
Dimensions | string | No | The dimension of the alert rule. Valid values of N: 1 to 200. Set the value to a set of key-value pairs, for example, | [{"instanceId":"i-m5e1qg6uo38rztr4****"}] |
Escalations.Critical.Threshold | string | No | The threshold for Critical-level alerts. Valid values of N: 1 to 200. | 90 |
Escalations.Critical.Statistics | string | No | The statistical methods for Critical-level alerts. Separate multiple statistical methods with commas (,). Valid values of N: 1 to 200. Valid value:
| Average |
Escalations.Warn.ComparisonOperator | string | No | The comparison operator that is used to compare the metric value with the threshold. Valid values of N: 1 to 200. Valid value:
| GreaterThanOrEqualToThreshold |
Escalations.Info.Times | integer | No | The consecutive number of times for which the metric value meets the alert condition before an Info-level alert is triggered. Valid values of N: 1 to 200. | 1 |
SilenceTime | integer | No | The mute period during which new alerts are not sent even if the trigger conditions are met. Valid values of N: 1 to 200. Unit: seconds. Default value: 86400. Minimum value: 3600. | 86400 |
Webhook | string | No | The callback URL. Valid values of N: 1 to 200. The callback URL must be accessible over the Internet. CloudMonitor pushes an alert notification to the specified callback URL by sending an HTTP POST request. Only the HTTP protocol is supported. | https://www.aliyun.com |
Namespace | string | Yes | The namespace of the cloud service. Valid values of N: 1 to 200. For information about how to obtain the namespace of a cloud service, see DescribeMetricMetaList or Appendix 1: Metrics. | acs_ecs_dashboard |
EmailSubject | string | No | The subject of the alert notification email. Valid values of N: 1 to 200. | |
Period | string | No | The aggregation period of the metric data. Valid values of N: 1 to 200. Set the | 60 |
RuleName | string | Yes | The name of the alert rule. Valid values of N: 1 to 200. | ECS_Rule1 |
Escalations.Info.Statistics | string | No | The statistical methods for Info-level alerts. Separate multiple statistical methods with commas (,). Valid values of N: 1 to 200. Valid value:
| Average |
Escalations.Warn.Times | integer | No | The consecutive number of times for which the metric value meets the alert condition before a Warn-level alert is triggered. Valid values of N: 1 to 200. | 3 |
Escalations.Info.ComparisonOperator | string | No | The comparison operator that is used to compare the metric value with the threshold. Valid values of N: 1 to 200. Valid value:
| GreaterThanOrEqualToThreshold |
Interval | string | No | The interval at which CloudMonitor checks whether the alert rule is triggered. Valid values of N: 1 to 200. Unit: seconds. The default value is the lowest frequency at which the metric is polled. Note
We recommend that you set the interval to the data aggregation period. If the interval is shorter than the data aggregation period, alerts cannot be triggered due to insufficient data.
| 60 |
Category | string | Yes | The name of the cloud service. Valid values of N: 1 to 200. Valid value:
| ECS |
Escalations.Critical.ComparisonOperator | string | No | The comparison operator that is used to compare the metric value with the threshold. Valid values of N: 1 to 200. Valid value:
| GreaterThanOrEqualToThreshold |
Escalations.Warn.Statistics | string | No | The statistical methods for Warn-level alerts. Separate multiple statistical methods with commas (,). Valid values of N: 1 to 200. Valid value:
| Average |
NoDataPolicy | string | No | The method that is used to handle alerts when no monitoring data is found. Valid values of N: 1 to 200. Valid value:
| KEEP_LAST_STATE |
ContactGroups | string | No | The alert contact groups. Valid values of N: 1 to 200. For information about how to obtain alert contact groups, see DescribeContactGroupList . | ECS_Group |
Labels | array<object> | No | ||
object | No | |||
Key | string | No | The tag key of the alert rule. The specified tag is contained in alert notifications. Valid values of N: 1 to 200. | key1 |
Value | string | No | The tag value of the alert rule. The specified tag is contained in alert notifications. Valid values of N: 1 to 200. | value1 |
For more information about common request parameters, see Common parameters.
Response parameters
Examples
Sample success responses
JSON
format
{
"Code": 200,
"Message": "The Request is not authorization.",
"RequestId": "461CF2CD-2FC3-4B26-8645-7BD27E7D0F1D",
"Success": true,
"Resources": {
"AlertResult": [
{
"Code": 200,
"Message": "Metric not found.",
"Success": true,
"RuleName": "ECS_Rule1",
"RuleId": "456789"
}
]
}
}
Error codes
HTTP status code | Error code | Error message |
---|---|---|
400 | %s | %s |
500 | 500 | %s |
For a list of error codes, visit the Service error codes.
Change history
Change time | Summary of changes | Operation |
---|---|---|
2023-12-13 | The Error code has changed | View Change Details |
2021-10-28 | The Error code has changed | View Change Details |
2021-10-28 | The Error code has changed | View Change Details |