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
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 | object [] | No | The tags of the alert rule. The specified tag is contained in alert notifications. | |
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 | see changesets | ||||||||||||||||||||||||
| ||||||||||||||||||||||||||
2021-09-14 | The Error code has changed. The request parameters of the API has changed | see changesets | ||||||||||||||||||||||||
|