Calls the PutResourceMetricRules operation to create multiple threshold alert rules for a specified metric of a specified resource.
Operation description
This topic provides an example of how to create a threshold alert rule for the cpu_total metric of the Elastic Computing Service (ECS) instance i-uf6j91r34rnwawoo**** in the acs_ecs_dashboard namespace. The alert contact group is set to ECS_Group, the alert rule name is set to test123, the alert rule ID is set to a151cd6023eacee2f0978e03863cc1697c89508****, the statistics method for the Critical level is set to Average, the comparison operator for the Critical level is set to GreaterThanOrEqualToThreshold, the threshold for the Critical level is set to 90, and the retry count for the Critical level is set to 3.
As of August 15, 2024, Statistics validation is added. You can set the statistics value only to the Statistics value that corresponds to the metric. For more information about how to obtain the value of this parameter, see Alibaba Cloud service monitoring metrics.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
cms:PutResourceMetricRules |
create |
*All Resource
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| Rules |
array<object> |
Yes |
The list of threshold alert rules. Valid values of N: 1 to 50. |
|
|
array<object> |
No |
None. |
||
| Escalations.Info.Threshold |
string |
No |
The threshold for Info-level alerts. Note
You must specify at least one of the following alert levels: Critical, Warn, or Info. For the specified alert level, you must set all of the following parameters: Statistics, ComparisonOperator, Threshold, and Times. |
90 |
| MetricName |
string |
No |
The metric name. Valid values of N: 1 to 50. For more information about how to query metric names, see Alibaba Cloud service monitoring metrics. |
cpu_total |
| Escalations.Warn.Threshold |
string |
No |
The threshold for Warn-level alerts. Valid values of N: 1 to 50. Note
You must specify at least one of the following alert levels: Critical, Warn, or Info. For the specified alert level, you must set all of the following parameters: Statistics, ComparisonOperator, Threshold, and Times. |
90 |
| EffectiveInterval |
string |
No |
The effective period of the alert rule. Valid values of N: 1 to 50. |
00:00-23:59 |
| NoEffectiveInterval |
string |
No |
The time range during which the alert rule is ineffective. Valid values of N: 1 to 50. |
00:00-06:00 |
| RuleId |
string |
Yes |
The alert rule ID. Valid values of N: 1 to 50. You can enter a new alert rule ID or use an existing alert rule ID in CloudMonitor. For more information about how to query alert rule IDs, see DescribeMetricRuleList. Note
If you enter a new alert rule ID, a threshold alert rule is created. |
a151cd6023eacee2f0978e03863cc1697c89508**** |
| Escalations.Critical.Times |
integer |
No |
The retry count for Critical-level alerts. Valid values of N: 1 to 50. Note
You must specify at least one of the following alert levels: Critical, Warn, or Info. For the specified alert level, you must set all of the following parameters: Statistics, ComparisonOperator, Threshold, and Times. |
3 |
| Escalations.Critical.Threshold |
string |
No |
The threshold for Critical-level alerts. Valid values of N: 1 to 50. Note
You must specify at least one of the following alert levels: Critical, Warn, or Info. For the specified alert level, you must set all of the following parameters: Statistics, ComparisonOperator, Threshold, and Times. |
90 |
| Escalations.Critical.Statistics |
string |
No |
The statistics method for Critical-level alerts. Valid values of N: 1 to 50. The value of this parameter is determined by the Note
You must specify at least one of the following alert levels: Critical (critical), Warn (warning), or Info (information). For the specified alert level, you must set all of the following parameters: Statistics, ComparisonOperator, Threshold, and Times. |
Average |
| Escalations.Warn.ComparisonOperator |
string |
No |
The comparison operator for Warn-level alerts. Valid values:
Valid values of N: 1 to 50. Note
You must specify at least one of the following alert levels: Critical, Warn, or Info. For the specified alert level, you must set all of the following parameters: Statistics, ComparisonOperator, Threshold, and Times. |
GreaterThanOrEqualToThreshold |
| Escalations.Info.Times |
integer |
No |
The retry count for Info-level alerts. Valid values of N: 1 to 50. Note
You must specify at least one of the following alert levels: Critical, Warn, or Info. For the specified alert level, you must set all of the following parameters: Statistics, ComparisonOperator, Threshold, and Times. |
3 |
| Resources |
string |
Yes |
The resource information, such as Valid values of N: 1 to 50. For more information about the supported dimensions, see Alibaba Cloud service monitoring metrics. |
[{"instanceId":"i-uf6j91r34rnwawoo****"}] |
| SilenceTime |
integer |
No |
The mute period. Unit: seconds. Default value: 86400. Valid values of N: 1 to 50. Note
The mute period specifies the interval at which an alert notification is sent again if the alert is not cleared. |
86400 |
| Webhook |
string |
No |
The callback URL to which a POST request is sent when an alert is triggered. Valid values of N: 1 to 50. |
https://alert.aliyun.com.com:8080/callback |
| ContactGroups |
string |
Yes |
The alert contact group. Alert notifications are sent to the alert contacts in the alert contact group. Valid values of N: 1 to 50. Note
An alert contact group contains one or more alert contacts. For more information about how to create alert contacts and alert contact groups, see PutContact and PutContactGroup. |
ECS_Group |
| Namespace |
string |
Yes |
The data namespace of the Alibaba Cloud service. Valid values of N: 1 to 50. For more information about how to query the data namespace of an Alibaba Cloud service, see Alibaba Cloud service monitoring metrics. |
acs_ecs_dashboard |
| EmailSubject |
string |
No |
The subject of the alert email. Valid values of N: 1 to 50. |
ECS instance alert |
| Period |
string |
No |
The statistical period of the metric. Unit: seconds. Default value: the original reporting period of the metric. Valid values of N: 1 to 50. Note
For more information about how to query the statistical period of a metric, see Alibaba Cloud service monitoring metrics. |
60 |
| RuleName |
string |
Yes |
The alert rule name. Valid values of N: 1 to 50. You can enter a new alert rule name or use an existing alert rule name in CloudMonitor. For more information about how to query alert rule names, see DescribeMetricRuleList. Note
If you enter a new alert rule name, a threshold alert rule is created. |
test123 |
| Escalations.Info.Statistics |
string |
No |
The statistics method for Info-level alerts. Valid values of N: 1 to 50. The value of this parameter is determined by the Note
You must specify at least one of the following alert levels: Critical (critical), Warn (warning), or Info (information). For the specified alert level, you must set all of the following parameters: Statistics, ComparisonOperator, Threshold, and Times. |
Average |
| Escalations.Warn.Times |
integer |
No |
The retry count for Warn-level alerts. Valid values of N: 1 to 50. Note
You must specify at least one of the following alert levels: Critical, Warn, or Info. For the specified alert level, you must set all of the following parameters: Statistics, ComparisonOperator, Threshold, and Times. |
3 |
| Escalations.Info.ComparisonOperator |
string |
No |
The comparison operator for Info-level alerts. Valid values:
Valid values of N: 1 to 50. Note
You must specify at least one of the following alert levels: Critical, Warn, or Info. For the specified alert level, you must set all of the following parameters: Statistics, ComparisonOperator, Threshold, and Times. |
GreaterThanOrEqualToThreshold |
| Interval |
string |
No |
The trigger period of the alert rule. Unit: seconds. Valid values of N: 1 to 50. Note
For more information about how to query the statistical period of a metric, see Alibaba Cloud service monitoring metrics. |
60 |
| Escalations.Critical.ComparisonOperator |
string |
No |
The comparison operator for Critical-level alerts. Valid values:
Valid values of N: 1 to 50. Note
You must specify at least one of the following alert levels: Critical, Warn, or Info. For the specified alert level, you must set all of the following parameters: Statistics, ComparisonOperator, Threshold, and Times. |
GreaterThanOrEqualToThreshold |
| Escalations.Warn.Statistics |
string |
No |
The statistics method for Warn-level alerts. Valid values of N: 1 to 50. The value of this parameter is determined by the Note
You must specify at least one of the following alert levels: Critical (critical), Warn (warning), or Info (information). For the specified alert level, you must set all of the following parameters: Statistics, ComparisonOperator, Threshold, and Times. |
Average |
| NoDataPolicy |
string |
No |
The processing method when no monitoring data is found. Valid values:
Valid values of N: 1 to 50. |
KEEP_LAST_STATE |
| Labels |
array<object> |
No |
When the metric reaches the alert condition and an alert is triggered, the labels are written to the metric and displayed in the alert notification. |
|
|
object |
No |
None. |
||
| Key |
string |
No |
The label key. |
tagKey1 |
| Value |
string |
No |
The label value. Note
The label value supports template parameters. Template parameters are replaced with actual label values. |
ECS |
| SendOK |
boolean |
No |
Specifies whether to send a recovery notification. |
true |
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
The value 200 indicates success. |
200 |
| Message |
string |
The error message. |
The request processing has failed due to some unknown error. |
| RequestId |
string |
The request ID. |
15D1440E-BF24-5A41-93E4-36864635179E |
| Success |
boolean |
Indicates whether the operation was successful. Valid values:
|
true |
| FailedListResult |
object |
||
| Target |
array<object> |
The list of failed results for setting alert rules on resources. |
|
|
array<object> |
None. |
||
| RuleId |
string |
The alert rule ID. |
a151cd6023eacee2f0978e03863cc1697c89508**** |
| Result |
object |
The failure result. |
|
| Code |
string |
The status code. |
404 |
| Message |
string |
The error message. |
The request processing has failed due to some unknown error. |
| Success |
boolean |
Indicates whether the operation was successful. Valid values:
|
false |
Examples
Success response
JSON format
{
"Code": "200",
"Message": "The request processing has failed due to some unknown error.",
"RequestId": "15D1440E-BF24-5A41-93E4-36864635179E",
"Success": true,
"FailedListResult": {
"Target": [
{
"RuleId": "a151cd6023eacee2f0978e03863cc1697c89508****",
"Result": {
"Code": "404",
"Message": "The request processing has failed due to some unknown error.",
"Success": false
}
}
]
}
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | %s | %s | |
| 422 | %s | %s | |
| 499 | %s | %s | |
| 500 | InternalError | The request processing has failed due to some unknown error. | |
| 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.