Creates or modifies an alert rule for an application group.
Operation description
This topic provides an example on how to create an alert rule for the cpu_total
metric of Elastic Compute Service (ECS) in the 17285****
application group. The ID of the alert rule is 123456
. The name of the alert rule is Rule_test
. The alert level is Critical
. The statistical method is Average
. The alert threshold comparator is GreaterThanOrEqualToThreshold
. The alert threshold is 90
. The number of alert retries is 3
. The returned result shows that the alert rule is created and the alert rule ID is 123456
.
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:PutGroupMetricRule | create |
|
| none |
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
GroupId | string | Yes | The application group ID. 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.
| 123456 |
Category | string | No | The abbreviation of the cloud service name. For more information about how to obtain the abbreviation of a cloud service name, see | ECS |
RuleName | string | Yes | The name of the alert rule.
| Rule_01 |
Namespace | string | Yes | The namespace of the cloud service. For more information about how to obtain the namespace of a cloud service, see DescribeMetricMetaList or Appendix 1: Metrics. | acs_ecs_dashboard |
MetricName | string | Yes | The metric name. For more information about how to obtain the name of a metric, see DescribeMetricMetaList or Appendix 1: Metrics. | cpu_total |
Dimensions | string | No | The first-level dimension of the alert rule in the application group. Set the value to a set of key-value pairs, for example, | [{"instanceId":"i-m5e1qg6uo38rztr4****"}] |
ExtraDimensionJson | string | No | The second-level or third-level dimension of the alert rule in the application group. Set the value to a set of key-value pairs, for example, If the first-level dimension of the alert rule is | {"/dev/xvda":"d-m5e6yphgzn3aprwu****"} |
EffectiveInterval | string | No | The time period during which the alert rule is effective. | 05:31-23:59 |
NoEffectiveInterval | string | No | The time period during which the alert rule is ineffective. | 00:00-05:30 |
SilenceTime | integer | No | The mute period during which new alerts are not sent even if the trigger conditions are met. Unit: seconds. Default value: 86400. | 86400 |
Period | string | No | The aggregation period of the metric data. Set the | 60 |
Interval | string | No | The interval at which CloudMonitor checks whether the alert rule is triggered. Unit: seconds. 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 |
Webhook | string | No | The callback URL. The callback URL must be accessible over the Internet. CloudMonitor sends a POST request to push an alert notification to the callback URL that you specify. Only HTTP requests are supported. | https://www.aliyun.com |
EmailSubject | string | No | The subject of the alert notification email. | |
ContactGroups | string | No | The alert contact group. | ECS_Group |
Escalations.Critical.Statistics | string | No | The statistical methods for Critical-level alerts. Separate multiple statistical methods with commas (,). The value of this parameter is determined by the | Average |
Escalations.Critical.ComparisonOperator | string | No | The operator that is used to compare the metric value with the threshold for Critical-level alerts. Valid values:
| GreaterThanOrEqualToThreshold |
Escalations.Critical.Threshold | string | No | The threshold for Critical-level alerts. | 90 |
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. | 3 |
Escalations.Warn.Statistics | string | No | The statistical methods for Warn-level alerts. Separate multiple statistical methods with commas (,). The value of this parameter is determined by the | Average |
Escalations.Warn.ComparisonOperator | string | No | The operator that is used to compare the metric value with the threshold for Warn-level alerts. Valid values:
| GreaterThanOrEqualToThreshold |
Escalations.Warn.Threshold | string | No | The threshold for Warn-level alerts. | 90 |
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. | 3 |
Escalations.Info.Statistics | string | No | The statistical methods for Info-level alerts. Separate multiple statistical methods with commas (,). The value of this parameter is determined by the | Average |
Escalations.Info.ComparisonOperator | string | No | The operator that is used to compare the metric value with the threshold for Info-level alerts. Valid values:
| GreaterThanOrEqualToThreshold |
Escalations.Info.Threshold | string | No | The threshold for Info-level alerts. | 90 |
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. | 3 |
NoDataPolicy | string | No | The method that is used to handle alerts when no monitoring data is found. Valid values:
| KEEP_LAST_STATE |
Labels | array<object> | No | The tags of the alert rule. The specified tag is contained in alert notifications. | |
object | No | |||
Key | string | No | The tag key of the alert rule. | key1 |
Value | string | No | The tag value of the alert rule. | 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,
"Result": {
"RuleId": "123456"
}
}
Error codes
HTTP status code | Error code | Error message |
---|---|---|
204 | %s | %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. The request parameters of the API has changed | View Change Details |
2021-09-14 | The Error code has changed. The request parameters of the API has changed | View Change Details |