CreateGroupMetricRules
Creates alert rules in batches for a specified application group.
Operation description
This topic provides an example on how to create an alert rule for the cpu_total metric of the Alibaba Cloud service Elastic Compute Service (ECS) in the application group 123456. The alert rule ID is 456789, the alert rule name is ECS_Rule1, the alert level is Critical, the statistical method is Average, the threshold comparison operator is GreaterThanOrEqualToThreshold, the threshold is 90, and the retry count is 3. The response shows that the alert rule ECS_Rule1 is created.
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 about how to obtain the ID of an application group, see DescribeMonitorGroups. |
3607**** |
| GroupMetricRules |
array<object> |
No |
The list of metric rules for the application group. |
|
|
array<object> |
No |
The metric rule for the application group. |
||
| Escalations.Info.Threshold |
string |
No |
The threshold for info-level alerts. Valid values of N: 1 to 200. Note
You must specify at least one of the following alert levels: Critical, Warn, and Info. For the specified alert level, you must specify the Statistics, ComparisonOperator, Threshold, and Times parameters at the same time. |
10 |
| MetricName |
string |
Yes |
The name of the monitoring metric. Valid values of N: 1 to 200. For more information about how to obtain the name of a monitoring metric, see DescribeMetricMetaList or cloud service monitoring metrics. |
cpu_total |
| Escalations.Warn.Threshold |
string |
No |
The threshold for warning-level alerts. Valid values of N: 1 to 200. Note
You must specify at least one of the following alert levels: Critical, Warn, and Info. For the specified alert level, you must specify the Statistics, ComparisonOperator, Threshold, and Times parameters at the same time. |
20 |
| EffectiveInterval |
string |
No |
The effective period of the alert rule. Valid values of N: 1 to 200. |
05:31-23:59 |
| NoEffectiveInterval |
string |
No |
The time period during which the alert rule is ineffective. Valid values of N: 1 to 200. |
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 monitoring metrics must reach the alert threshold to send a critical-level alert notification. Valid values of N: 1 to 200. Note
You must specify at least one of the following alert levels: Critical, Warn, and Info. For the specified alert level, you must specify the Statistics, ComparisonOperator, Threshold, and Times parameters at the same time. |
3 |
| Dimensions |
string |
No |
The monitoring dimensions of the specified resource. Format: a collection of |
[{"instanceId":"i-m5e1qg6uo38rztr4****"}] |
| Escalations.Critical.Threshold |
string |
No |
The threshold that triggers the critical-level alert notification. Valid values of N: 1 to 200. Note
You must specify at least one of the following alert levels: Critical, Warn, and Info. For the specified alert level, you must specify the Statistics, ComparisonOperator, Threshold, and Times parameters at the same time. |
90 |
| Escalations.Critical.Statistics |
string |
No |
The statistical method for critical-level alerts. Valid values of N: 1 to 200. The valid values of this parameter are determined by the Statistics column that corresponds to the MetricName parameter of the specified Alibaba Cloud service. Examples: Maximum, Minimum, and Average. For more information about how to obtain the valid values of this parameter, see cloud service monitoring metrics. Note
You must specify at least one of the following alert levels: Critical, Warn, and Info. For the specified alert level, you must specify the Statistics, ComparisonOperator, Threshold, and Times parameters at the same time. |
Average |
| Escalations.Warn.ComparisonOperator |
string |
No |
The comparison operator for the warning-level threshold. Valid values:
Valid values of N: 1 to 200. Note
You must specify at least one of the following alert levels: Critical, Warn, and Info. For the specified alert level, you must specify the Statistics, ComparisonOperator, Threshold, and Times parameters at the same time. |
GreaterThanOrEqualToThreshold |
| Escalations.Info.Times |
integer |
No |
The number of times the monitoring metrics must reach the alert threshold to send an info-level alert notification. Valid values of N: 1 to 200. Note
You must specify at least one of the following alert levels: Critical, Warn, and Info. For the specified alert level, you must specify the Statistics, ComparisonOperator, Threshold, and Times parameters at the same time. |
1 |
| SilenceTime |
integer |
No |
The mute period for alert notifications. Valid values of N: 1 to 200. Unit: seconds. Default value: 86400. Minimum value: 3600. |
86400 |
| Webhook |
string |
No |
The webhook URL that is called when an alert is triggered. Valid values of N: 1 to 200. Specify a publicly accessible URL. CloudMonitor pushes alert notifications to this URL by sending POST requests. Only HTTP is supported. |
https://www.aliyun.com |
| Namespace |
string |
Yes |
The data namespace of the Alibaba Cloud service. Valid values of N: 1 to 200. For more information about how to obtain the data namespace of an Alibaba Cloud service, see DescribeMetricMetaList or cloud service monitoring metrics. |
acs_ecs_dashboard |
| EmailSubject |
string |
No |
The subject of the alert email. Valid values of N: 1 to 200. |
ECS instance |
| Period |
string |
No |
The reporting period of monitoring data. Valid values of N: 1 to 200. The value of Period must be 60 or a multiple of 60. Unit: seconds. Default value: 300. |
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-level alerts. Valid values of N: 1 to 200. The valid values of this parameter are determined by the Statistics column that corresponds to the MetricName parameter of the specified Alibaba Cloud service. Examples: Maximum, Minimum, and Average. For more information about how to obtain the valid values of this parameter, see cloud service monitoring metrics. Note
You must specify at least one of the following alert levels: Critical, Warn, and Info. For the specified alert level, you must specify the Statistics, ComparisonOperator, Threshold, and Times parameters at the same time. |
Average |
| Escalations.Warn.Times |
integer |
No |
The number of times the monitoring metrics must reach the alert threshold to send a warning-level alert notification. Valid values of N: 1 to 200. Note
You must specify at least one of the following alert levels: Critical, Warn, and Info. For the specified alert level, you must specify the Statistics, ComparisonOperator, Threshold, and Times parameters at the same time. |
3 |
| Escalations.Info.ComparisonOperator |
string |
No |
The comparison operator for the info-level threshold. Valid values:
Valid values of N: 1 to 200. Note
You must specify at least one of the following alert levels: Critical, Warn, and Info. For the specified alert level, you must specify the Statistics, ComparisonOperator, Threshold, and Times parameters at the same time. |
GreaterThanOrEqualToThreshold |
| Interval |
string |
No |
The detection period of the alert rule. Valid values of N: 1 to 200. Unit: seconds. The default value is the minimum reporting frequency of the metric. Note
Set the detection period of the alert rule to the same value as the reporting period of monitoring data. If the detection period is shorter than the reporting period, alerts cannot be triggered due to insufficient data. |
60 |
| Category |
string |
Yes |
The abbreviation of the cloud service name. Valid values of N: 1 to 200. For more information about how to obtain the abbreviation of a cloud service name, see the metricCategory field in the Labels response parameter of the DescribeProjectMeta operation. |
ECS |
| Escalations.Critical.ComparisonOperator |
string |
No |
The comparison operator for the critical-level threshold. Valid values:
Valid values of N: 1 to 200. Note
You must specify at least one of the following alert levels: Critical, Warn, and Info. For the specified alert level, you must specify the Statistics, ComparisonOperator, Threshold, and Times parameters at the same time. |
GreaterThanOrEqualToThreshold |
| Escalations.Warn.Statistics |
string |
No |
The statistical method for warning-level alerts. Valid values of N: 1 to 200. The valid values of this parameter are determined by the Statistics column that corresponds to the MetricName parameter of the specified Alibaba Cloud service. Examples: Maximum, Minimum, and Average. For more information about how to obtain the valid values of this parameter, see cloud service monitoring metrics. Note
You must specify at least one of the following alert levels: Critical, Warn, and Info. For the specified alert level, you must specify the Statistics, ComparisonOperator, Threshold, and Times parameters at the same time. |
Average |
| NoDataPolicy |
string |
No |
The processing method when no monitoring data is available. Valid values:
Valid values of N: 1 to 200. |
KEEP_LAST_STATE |
| ContactGroups |
string |
No |
The alert contact group. Valid values of N: 1 to 200. For more information about how to obtain an alert contact group, see DescribeContactGroupList. |
ECS_Group |
| Labels |
array<object> |
No |
The tags of the alert rule. |
|
|
object |
No |
The tags of the alert rule. |
||
| Key |
string |
No |
The tag key of the alert rule. Alert notifications include tags. Valid values of N: 1 to 200. |
key1 |
| Value |
string |
No |
The tag value of the alert rule. Alert notifications include tags. Valid values of N: 1 to 200. |
value1 |
| Options |
string |
No |
The advanced settings. Format: |
{ "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
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 is successful. Valid values:
|
true |
| Resources |
object |
||
| AlertResult |
array<object> |
The list of alert rules. |
|
|
object |
|||
| Code |
integer |
The status code of the newly created alert rule. Note
200 indicates success. |
200 |
| Message |
string |
The error message of the newly created alert rule. |
Metric not found. |
| Success |
boolean |
Indicates whether the alert rule is created. Valid values:
|
true |
| RuleName |
string |
The name of the newly created alert rule. |
ECS_Rule1 |
| RuleId |
string |
The ID of the newly created 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.