Creates or modifies an alert rule in a specified 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 application group 17285****. The alert rule ID is 123456, the alert rule name is Rule_test, the alert severity is Critical, the statistical method is Average, the comparison operator is GreaterThanOrEqualToThreshold, the threshold is 90, and the retry count is 3. The response shows that the alert rule is created. The alert rule ID is 123456.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
cms:PutGroupMetricRule |
create |
*GroupMetricRule
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| GroupId |
string |
Yes |
The application group ID. For information about how to obtain the application group ID, see DescribeMonitorGroups. |
17285**** |
| RuleId |
string |
Yes |
The alert rule ID.
|
123456 |
| Category |
string |
No |
The abbreviation of the Alibaba Cloud service name. For information about how to obtain the abbreviation, see the |
ECS |
| RuleName |
string |
Yes |
The alert rule name.
|
Rule_01 |
| Namespace |
string |
Yes |
The namespace of the Alibaba Cloud service. For information about how to obtain the namespace, see DescribeMetricMetaList or Cloud service monitoring. |
acs_ecs_dashboard |
| MetricName |
string |
Yes |
The metric name. For information about how to obtain the metric name, see DescribeMetricMetaList or Cloud service monitoring. |
cpu_total |
| Dimensions |
string |
No |
The first-level dimensions of the alert rule in the application group. Format: a collection of |
[{"instanceId":"i-m5e1qg6uo38rztr4****"}] |
| ExtraDimensionJson |
string |
No |
The second-level or third-level dimensions of the alert rule in the application group. Format: a collection of If the first-level dimension is |
{"/dev/xvda":"d-m5e6yphgzn3aprwu****"} |
| EffectiveInterval |
string |
No |
The effective period during which the alert rule takes effect. |
05:31-23:59 |
| NoEffectiveInterval |
string |
No |
The time range during which the alert rule is ineffective. |
00:00-05:30 |
| SilenceTime |
integer |
No |
The mute period. Unit: seconds. Default value: 86400. |
86400 |
| Period |
string |
No |
The reporting period of monitoring data. The value of |
60 |
| Interval |
string |
No |
The detection period of the alert rule. Unit: seconds. Note
Keep the detection period consistent with the data reporting period. If the detection period is shorter than the data reporting period, alerts may not be triggered due to insufficient data. |
60 |
| Webhook |
string |
No |
The callback URL to which a request is sent when an alert is triggered. Enter a publicly accessible URL. CloudMonitor sends a POST request to push alert information to this URL. Only the HTTP protocol is supported. |
https://www.aliyun.com |
| EmailSubject |
string |
No |
The subject of the alert email. |
ECS instance |
| ContactGroups |
string |
No |
The alert contact group. |
ECS_Group |
| Escalations.Critical.Statistics |
string |
No |
Critical 级别报警统计方法。多个统计方法之间用半角逗号(,)分隔。 该参数的取值由指定云产品的 |
Average |
| Escalations.Critical.ComparisonOperator |
string |
No |
Critical 级别阈值比较符。取值:
|
GreaterThanOrEqualToThreshold |
| Escalations.Critical.Threshold |
string |
No |
Critical 级别报警阈值。 |
90 |
| Escalations.Critical.Times |
integer |
No |
Critical 级别报警重试次数。 |
3 |
| Escalations.Warn.Statistics |
string |
No |
Warn 级别报警统计方法。多个统计方法之间用半角逗号(,)分隔。 该参数的取值由指定云产品的 |
Average |
| Escalations.Warn.ComparisonOperator |
string |
No |
Warn 级别阈值比较符。取值:
|
GreaterThanOrEqualToThreshold |
| Escalations.Warn.Threshold |
string |
No |
Warn 级别报警阈值。 |
90 |
| Escalations.Warn.Times |
integer |
No |
Warn 级别报警重试次数。 |
3 |
| Escalations.Info.Statistics |
string |
No |
Info 级别报警统计方法。多个统计方法之间用半角逗号(,)分隔。 该参数的取值由指定云产品的 |
Average |
| Escalations.Info.ComparisonOperator |
string |
No |
Info 级别阈值比较符。取值:
|
GreaterThanOrEqualToThreshold |
| Escalations.Info.Threshold |
string |
No |
Info 级别报警阈值。 |
90 |
| Escalations.Info.Times |
integer |
No |
Info 级别报警重试次数。 |
3 |
| NoDataPolicy |
string |
No |
The processing method when no monitoring data is found. Valid values:
|
KEEP_LAST_STATE |
| Labels |
array<object> |
No |
The tags of the alert rule. Tags are included in alert notifications. |
|
|
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}. This specifies whether to send a notification when the alert is cleared. The key is NotSendOK, and the value is true (do not send) or false (send, which is the default). |
{"NotSendOK":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 is not authorization. |
| RequestId |
string |
The request ID. |
461CF2CD-2FC3-4B26-8645-7BD27E7D0F1D |
| Success |
boolean |
Indicates whether the operation was successful. Valid values:
|
true |
| Result |
object |
The result of creating or modifying the alert rule. |
|
| RuleId |
string |
The alert rule ID. |
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 | |
| 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.