Call the CreateGroupMetricRules operation to create multiple alert rules for an application group.
Operation description
This topic provides an example of how to create an alert rule for the cpu_total metric of an Elastic Compute Service (ECS) instance that belongs to application group 123456. The following parameters are set for the alert rule: the alert rule ID is 456789, the alert rule name is ECS_Rule1, the alert level is Critical, the statistical method is Average, the comparison operator is GreaterThanOrEqualToThreshold, the threshold is 90, and the number of retries is 3. The response indicates that the alert rule ECS_Rule1 is created successfully.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
cms:CreateGroupMetricRules |
create |
*GroupMetricRule
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| GroupId |
integer |
Yes |
The ID of the application group. For more information, see DescribeMonitorGroups. |
3607**** |
| GroupMetricRules |
array<object> |
No |
A list of metric rules for the application group. |
|
|
array<object> |
No |
A metric rule for the application group. |
||
| Escalations.Info.Threshold |
string |
No |
The threshold for `Info` alerts. Valid values of N: 1 to 200. Note
You must specify parameters for at least one alert level: `Critical`, `Warning`, or `Info`. For the specified alert level, you must set the `Statistics`, `ComparisonOperator`, `Threshold`, and `Times` parameters. |
10 |
| MetricName |
string |
Yes |
The name of the metric. For more information, see DescribeMetricMetaList or Metrics for cloud services. For more information about how to obtain metric names, see DescribeMetricMetaList or Cloud service monitoring metrics. |
cpu_total |
| Escalations.Warn.Threshold |
string |
No |
The threshold for `Warning` alerts. Valid values of N: 1 to 200. Note
You must specify parameters for at least one alert level: `Critical`, `Warning`, or `Info`. For the specified alert level, you must set the `Statistics`, `ComparisonOperator`, `Threshold`, and `Times` parameters. |
20 |
| EffectiveInterval |
string |
No |
The time period when the alert rule is effective. |
05:31-23:59 |
| NoEffectiveInterval |
string |
No |
The time period when the alert rule is ineffective. |
00:00-05:30 |
| RuleId |
string |
Yes |
The ID of the alert rule. Valid values of N: 1 to 200. |
456789 |
| Escalations.Critical.Times |
integer |
No |
The number of times the metric value must exceed the threshold before a `Critical` alert is triggered. Valid values of N: 1 to 200. Note
You must specify parameters for at least one alert level: `Critical`, `Warning`, or `Info`. For the specified alert level, you must set the `Statistics`, `ComparisonOperator`, `Threshold`, and `Times` parameters. |
3 |
| Dimensions |
string |
No |
The dimensions that specify the resources to monitor. The value is a collection of key-value pairs. For example: |
[{"instanceId":"i-m5e1qg6uo38rztr4****"}] |
| Escalations.Critical.Threshold |
string |
No |
The threshold for `Critical` alerts. Valid values of N: 1 to 200. Note
You must specify parameters for at least one alert level: `Critical`, `Warning`, or `Info`. For the specified alert level, you must set the `Statistics`, `ComparisonOperator`, `Threshold`, and `Times` parameters. |
90 |
| Escalations.Critical.Statistics |
string |
No |
The statistical method for `Critical` alerts. The value of this parameter is determined by the `Statistics` column that corresponds to the `MetricName` of the cloud service. Examples: Maximum, Minimum, and Average. For more information, see Metrics for cloud services. The value of this parameter is determined by the Note
You must specify parameters for at least one alert level: `Critical`, `Warning`, or `Info`. For the specified alert level, you must set the `Statistics`, `ComparisonOperator`, `Threshold`, and `Times` parameters. |
Average |
| Escalations.Warn.ComparisonOperator |
string |
No |
The comparison operator for the `Warning` alert level. Valid values:
Valid values of N: 1 to 200. Note
You must specify parameters for at least one alert level: `Critical`, `Warning`, or `Info`. For the specified alert level, you must set the `Statistics`, `ComparisonOperator`, `Threshold`, and `Times` parameters. |
GreaterThanOrEqualToThreshold |
| Escalations.Info.Times |
integer |
No |
The number of times the metric value must exceed the threshold before an `Info` alert is triggered. Valid values of N: 1 to 200. Note
You must specify parameters for at least one alert level: `Critical`, `Warning`, or `Info`. For the specified alert level, you must set the `Statistics`, `ComparisonOperator`, `Threshold`, and `Times` parameters. |
1 |
| SilenceTime |
integer |
No |
The mute period of the alert notification. Unit: seconds. Default value: 86400. Minimum value: 3600. |
86400 |
| Webhook |
string |
No |
The callback URL to which alert notifications are sent. Enter a URL that is accessible over the Internet. Cloud Monitor pushes alert notifications to the URL by sending POST requests. Only HTTP is supported. |
https://www.aliyun.com |
| Namespace |
string |
Yes |
The data namespace of the cloud service. For more information, see DescribeMetricMetaList or Metrics for cloud services. To learn how to obtain the data namespace for a cloud product, see DescribeMetricMetaList or Cloud Service Monitoring Items. |
acs_ecs_dashboard |
| EmailSubject |
string |
No |
The subject of the alert email. Valid values of N: 1 to 200. |
ECS实例 |
| Period |
string |
No |
The reporting cycle of the monitoring data. The value must be 60 or a multiple of 60. Unit: seconds. Default value: 300. The value of |
60 |
| RuleName |
string |
Yes |
The name of the alert rule. Valid values of N: 1 to 200. |
ECS_Rule1 |
| Escalations.Info.Statistics |
string |
No |
The statistical method for `Info` alerts. The value of this parameter is determined by the `Statistics` column that corresponds to the `MetricName` of the cloud service. Examples: Maximum, Minimum, and Average. For more information, see Metrics for cloud services. The value of this parameter is determined by the Note
You must specify parameters for at least one alert level: `Critical`, `Warning`, or `Info`. For the specified alert level, you must set the `Statistics`, `ComparisonOperator`, `Threshold`, and `Times` parameters. |
Average |
| Escalations.Warn.Times |
integer |
No |
The number of times the metric value must exceed the threshold before a `Warning` alert is triggered. Valid values of N: 1 to 200. Note
You must specify parameters for at least one alert level: `Critical`, `Warning`, or `Info`. For the specified alert level, you must set the `Statistics`, `ComparisonOperator`, `Threshold`, and `Times` parameters. |
3 |
| Escalations.Info.ComparisonOperator |
string |
No |
The comparison operator for the `Info` alert level. Valid values:
Valid values of N: 1 to 200. Note
You must specify parameters for at least one alert level: `Critical`, `Warning`, or `Info`. For the specified alert level, you must set the `Statistics`, `ComparisonOperator`, `Threshold`, and `Times` parameters. |
GreaterThanOrEqualToThreshold |
| Interval |
string |
No |
The detection cycle of the alert rule. Unit: seconds. The default value is the minimum frequency of the metric. Unit: seconds. The default value is the lowest frequency at which the metric is polled. Note
Set the detection cycle to the same value as the data reporting cycle. If the detection cycle is shorter than the data reporting cycle, alerts may not be triggered due to insufficient data. |
60 |
| Category |
string |
Yes |
The abbreviation of the cloud service name. For more information, see the To obtain the abbreviations for cloud product names, see the |
ECS |
| Escalations.Critical.ComparisonOperator |
string |
No |
The comparison operator for the `Critical` alert level. Valid values:
Valid values of N: 1 to 200. Note
You must specify parameters for at least one alert level: `Critical`, `Warning`, or `Info`. For the specified alert level, you must set the `Statistics`, `ComparisonOperator`, `Threshold`, and `Times` parameters. |
GreaterThanOrEqualToThreshold |
| Escalations.Warn.Statistics |
string |
No |
The statistical method for `Warning` alerts. The value of this parameter is determined by the `Statistics` column that corresponds to the `MetricName` of the cloud service. Examples: Maximum, Minimum, and Average. For more information, see Metrics for cloud services. The value of this parameter is determined by the Note
You must specify parameters for at least one alert level: `Critical`, `Warning`, or `Info`. For the specified alert level, you must set the `Statistics`, `ComparisonOperator`, `Threshold`, and `Times` parameters. |
Average |
| NoDataPolicy |
string |
No |
The method to handle alerts when no monitoring data is available. Valid values:
Valid values of N: 1 to 200. |
KEEP_LAST_STATE |
| ContactGroups |
string |
No |
The alert contact groups. For more information, see DescribeContactGroupList. For more information about how to obtain alert contact groups, see DescribeContactGroupList. |
ECS_Group |
| Labels |
array<object> |
No |
The tags of the alert rule. |
|
|
object |
No |
The tag of the alert rule. |
||
| Key |
string |
No |
The key of the tag. The tag is included in alert notifications. Valid values of N: 1 to 200. |
key1 |
| Value |
string |
No |
The value of the tag. The tag is included in alert notifications. Valid values of N: 1 to 200. |
value1 |
| Options |
string |
No |
The advanced settings. Format: {"key1":"value1","key2":"value2"}. For example, {"NotSendOK":true} specifies whether to send a notification when an alert is cleared. The key is NotSendOK. The value can be true (do not send) or false (send by default). |
{ "NotSendOK": true } |
For more information about common request parameters, see Common parameters.
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| Code |
integer |
The status code. Note
A status code of 200 indicates that the request was successful. |
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 |
| Resources |
object |
||
| AlertResult |
array<object> |
A list of alert rules. |
|
|
object |
|||
| Code |
integer |
The status code for creating the alert rule. Note
A status code of 200 indicates that the operation was successful. |
200 |
| Message |
string |
The error message for creating the alert rule. |
Metric not found. |
| Success |
boolean |
Indicates whether the alert rule was created. Valid values:
|
true |
| RuleName |
string |
The name of the new alert rule. |
ECS_Rule1 |
| RuleId |
string |
The ID of the new alert rule. |
456789 |
Examples
Success response
JSON format
{
"Code": 200,
"Message": "The Request is not authorization.",
"RequestId": "461CF2CD-2FC3-4B26-8645-7BD27E7D0F1D",
"Success": true,
"Resources": {
"AlertResult": [
{
"Code": 200,
"Message": "Metric not found.",
"Success": true,
"RuleName": "ECS_Rule1",
"RuleId": "456789"
}
]
}
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | %s | %s | |
| 412 | %s | %s | |
| 500 | %s | %s | |
| 500 | 500 | %s | |
| 403 | %s | %s | |
| 404 | %s | %s | |
| 409 | %s | %s |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.