Sets multiple threshold alert rules for a specified metric of a specified resource.
Operation description
This topic provides an example on how to configure a threshold alert rule for the cpu_total metric of the Elastic Compute Service (ECS) instance i-uf6j91r34rnwawoo**** in the acs_ecs_dashboard namespace. The alert contact group for the alert rule is ECS_Group, the alert rule name is test123, the alert rule ID is a151cd6023eacee2f0978e03863cc1697c89508****, the statistical method for the Critical level is Average, the comparison operator for the Critical level is GreaterThanOrEqualToThreshold, the threshold for the Critical level is 90, and the alert retry count for the Critical level is 3.
On August 15, 2024, validation for Statistics was added. The statistical value must match the Statistics of the corresponding metric. For more information about how to obtain the value of this parameter, see Alibaba Cloud service 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 alert threshold for the Info level. Note
You must set at least one of the following alert levels: Critical, Warn, and Info. The Statistics, ComparisonOperator, Threshold, and Times parameters must be set at the same time for the specified alert level. |
90 |
| MetricName |
string |
No |
The name of the metric. Valid values of N: 1 to 50. For more information about how to query the name of a metric, see Alibaba Cloud service metrics. |
cpu_total |
| Escalations.Warn.Threshold |
string |
No |
The alert threshold for the Warn level. Valid values of N: 1 to 50. Note
You must set at least one of the following alert levels: Critical, Warn, and Info. The Statistics, ComparisonOperator, Threshold, and Times parameters must be set at the same time for the specified alert level. |
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 ID of the alert rule. 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 the ID of an alert rule, see DescribeMetricRuleList. Note
If you enter a new alert rule ID, a threshold alert rule is created. |
a151cd6023eacee2f0978e03863cc1697c89508**** |
| Escalations.Critical.Times |
integer |
No |
The number of alert retries for the Critical level. Valid values of N: 1 to 50. Note
You must set at least one of the following alert levels: Critical, Warn, and Info. The Statistics, ComparisonOperator, Threshold, and Times parameters must be set at the same time for the specified alert level. |
3 |
| Escalations.Critical.Threshold |
string |
No |
The alert threshold for the Critical level. Valid values of N: 1 to 50. Note
You must set at least one of the following alert levels: Critical, Warn, and Info. The Statistics, ComparisonOperator, Threshold, and Times parameters must be set at the same time for the specified alert level. |
90 |
| Escalations.Critical.Statistics |
string |
No |
The statistical method for the Critical level. Valid values of N: 1 to 50. The value of this parameter is determined by the Statistics column that corresponds to the MetricName of the specified Alibaba Cloud service, such as Maximum, Minimum, and Average. For more information about how to obtain the value of this parameter, see Alibaba Cloud service metrics. Note
You must configure at least one of the following alert levels: Critical, Warn, and Info. The Statistics, ComparisonOperator, Threshold, and Times parameters must be configured at the same time for the specified alert level. |
Average |
| Escalations.Warn.ComparisonOperator |
string |
No |
The comparison operator for the Warn level. Valid values:
Valid values of N: 1 to 50. Note
You must set at least one of the following alert levels: Critical, Warn, and Info. The Statistics, ComparisonOperator, Threshold, and Times parameters must be set at the same time for the specified alert level. |
GreaterThanOrEqualToThreshold |
| Escalations.Info.Times |
integer |
No |
The number of alert retries for the Info level. Valid values of N: 1 to 50. Note
You must set at least one of the following alert levels: Critical, Warn, and Info. The Statistics, ComparisonOperator, Threshold, and Times parameters must be set at the same time for the specified alert level. |
3 |
| Resources |
string |
Yes |
The resource information, such as Valid values of N: 1 to 50. For more information about the dimensions supported by resource information, see Alibaba Cloud service metrics. |
[{"instanceId":"i-uf6j91r34rnwawoo****"}] |
| SilenceTime |
integer |
No |
The mute epoch. Unit: seconds. Default value: 86400. Valid values of N: 1 to 50. Note
The mute epoch refers to the interval before the system can send an alert notification again if the alert is not cleared after it is triggered. |
86400 |
| Webhook |
string |
No |
The webhook 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 this alert contact group. Valid values of N: 1 to 50. Note
An alert contact group is a group of alert contacts and can contain one or more alert contacts. For more information about how to create an alert contact and an alert contact group, 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 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. The default value is 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 metrics. |
60 |
| RuleName |
string |
Yes |
The name of the alert rule. 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 the name of an alert rule, see DescribeMetricRuleList. Note
If you enter a new alert rule name, a threshold alert rule is created. |
test123 |
| Escalations.Info.Statistics |
string |
No |
The statistical method for the Info level. Valid values of N: 1 to 50. The value of this parameter is determined by the Statistics column that corresponds to the MetricName of the specified Alibaba Cloud service, such as Maximum, Minimum, and Average. For more information about how to obtain the value of this parameter, see Alibaba Cloud service metrics. Note
You must configure at least one of the following alert levels: Critical, Warn, and Info. The Statistics, ComparisonOperator, Threshold, and Times parameters must be configured at the same time for the specified alert level. |
Average |
| Escalations.Warn.Times |
integer |
No |
The number of alert retries for the Warn level. Valid values of N: 1 to 50. Note
You must set at least one of the following alert levels: Critical, Warn, and Info. The Statistics, ComparisonOperator, Threshold, and Times parameters must be set at the same time for the specified alert level. |
3 |
| Escalations.Info.ComparisonOperator |
string |
No |
The comparison operator for the Info level. Valid values:
Valid values of N: 1 to 50. Note
You must set at least one of the following alert levels: Critical, Warn, and Info. The Statistics, ComparisonOperator, Threshold, and Times parameters must be set at the same time for the specified alert level. |
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 metrics. |
60 |
| Escalations.Critical.ComparisonOperator |
string |
No |
The comparison operator for the Critical level. Valid values:
Valid values of N: 1 to 50. Note
You must set at least one of the following alert levels: Critical, Warn, and Info. The Statistics, ComparisonOperator, Threshold, and Times parameters must be set at the same time for the specified alert level. |
GreaterThanOrEqualToThreshold |
| Escalations.Warn.Statistics |
string |
No |
The statistical method for the Warn level. Valid values of N: 1 to 50. The value of this parameter is determined by the Statistics column that corresponds to the MetricName of the specified Alibaba Cloud service, such as Maximum, Minimum, and Average. For more information about how to obtain the value of this parameter, see Alibaba Cloud service metrics. Note
You must configure at least one of the following alert levels: Critical, Warn, and Info. The Statistics, ComparisonOperator, Threshold, and Times parameters must be configured at the same time for the specified alert level. |
Average |
| NoDataPolicy |
string |
No |
The handling method when no monitoring data is available. Valid values:
Valid values of N: 1 to 50. |
KEEP_LAST_STATE |
| Labels |
array<object> |
No |
The labels that are written to the metric and displayed in the alert notification when the metric meets the alert condition and an alert is triggered. |
|
|
object |
No |
None. |
||
| Key |
string |
No |
The label key. |
tagKey1 |
| Value |
string |
No |
The label value. Note
The label value supports template parameters. The template parameters are replaced with the actual label values. |
ECS |
| SendOK |
boolean |
No |
Specifies whether to send a recovery notification. |
true |
| DryRun |
boolean |
No |
Specifies whether to only precheck the request. Valid values:
|
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 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 failure results for setting alert rules for resources. |
|
|
array<object> |
None. |
||
| RuleId |
string |
The ID of the alert rule. |
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 | |
| 412 | DryRunOperation | %s. | dryRun Pre-Verification Results |
| 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.