Creates alert rules for an application group.
This topic provides an example to show how to create an alert rule for the cpu_total
metric of Elastic Compute Service (ECS) in the 123456
application group. The ID of the alert rule is 456789
. The name of the alert rule is ECS_Rule1
. The alert level is Critical
. The statistical method is Average
. The comparison operator is GreaterThanOrEqualToThreshold
. The alert threshold is 90
. The number of alert retries is 3
. The response shows that the alert rule named ECS_Rule1
is created.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | CreateGroupMetricRules | The operation that you want to perform. Set the value to CreateGroupMetricRules. |
GroupId | Long | Yes | 3607**** | The ID of the application group. For information about how to obtain the ID of an application group, see DescribeMonitorGroups. |
GroupMetricRules.N.Escalations.Info.Threshold | String | No | 10 | The threshold for Info-level alerts. Valid values of N: 1 to 200. Note You must select at least one of the Critical, Warn, and Info alert levels and specify the Statistics, ComparisonOperator, Threshold, and Times parameters for the selected alert level. |
GroupMetricRules.N.MetricName | String | Yes | cpu_total | The name of the metric. Valid values of N: 1 to 200. For information about how to obtain the name of a metric, see DescribeMetricMetaList or Appendix 1: Metrics. |
GroupMetricRules.N.Escalations.Warn.Threshold | String | No | 20 | The threshold for Warn-level alerts. Valid values of N: 1 to 200. Note You must select at least one of the Critical, Warn, and Info alert levels and specify the Statistics, ComparisonOperator, Threshold, and Times parameters for the selected alert level. |
GroupMetricRules.N.EffectiveInterval | String | No | 05:31-23:59 | The time period during which the alert rule is effective. Valid values of N: 1 to 200. |
GroupMetricRules.N.NoEffectiveInterval | String | No | 00:00-05:30 | The time period during which the alert rule is ineffective. Valid values of N: 1 to 200. |
GroupMetricRules.N.RuleId | String | Yes | 456789 | The ID of the alert rule. Valid values of N: 1 to 200. |
GroupMetricRules.N.Escalations.Critical.Times | Integer | No | 3 | The consecutive number of times for which the metric value meets the alert condition before a Critical-level alert is triggered. Valid values of N: 1 to 200. Note You must select at least one of the Critical, Warn, and Info alert levels and specify the Statistics, ComparisonOperator, Threshold, and Times parameters for the selected alert level. |
GroupMetricRules.N.Dimensions | String | No | [{"instanceId":"i-m5e1qg6uo38rztr4****"}] | The monitoring dimensions of the specified resource. Set the value to a collection of |
GroupMetricRules.N.Escalations.Critical.Threshold | String | No | 90 | The threshold for Critical-level alerts. Valid values of N: 1 to 200. Note You must select at least one of the Critical, Warn, and Info alert levels and specify the Statistics, ComparisonOperator, Threshold, and Times parameters for the selected alert level. |
GroupMetricRules.N.Escalations.Critical.Statistics | String | No | Average | The statistical method for Critical-level alerts. Valid values of N: 1 to 200. The value of this parameter is determined by the Note You must select at least one of the Critical, Warn, and Info alert levels and specify the Statistics, ComparisonOperator, Threshold, and Times parameters for the selected alert level. |
GroupMetricRules.N.Escalations.Warn.ComparisonOperator | String | No | GreaterThanOrEqualToThreshold | The operator that is used to compare the metric value with the threshold for Warn-level alerts. Valid values:
Valid values of N: 1 to 200. Note You must select at least one of the Critical, Warn, and Info alert levels and specify the Statistics, ComparisonOperator, Threshold, and Times parameters for the selected alert level. |
GroupMetricRules.N.Escalations.Info.Times | Integer | No | 1 | The consecutive number of times for which the metric value meets the alert condition before an Info-level alert is triggered. Valid values of N: 1 to 200. Note You must select at least one of the Critical, Warn, and Info alert levels and specify the Statistics, ComparisonOperator, Threshold, and Times parameters for the selected alert level. |
GroupMetricRules.N.SilenceTime | Integer | No | 86400 | The mute period during which new alerts are not sent even if the trigger conditions are met. Valid values of N: 1 to 200. Unit: seconds. Default value: 86400. Minimum value: 3600. |
GroupMetricRules.N.Webhook | String | No | https://www.aliyun.com | The callback URL. Valid values of N: 1 to 200. The callback URL must be accessible over the Internet. CloudMonitor sends a POST request to push an alert notification to the callback URL that you specify. Only HTTP requests are supported. |
GroupMetricRules.N.Namespace | String | Yes | acs_ecs_dashboard | The namespace of the cloud service. Valid values of N: 1 to 200. For information about how to obtain the namespace of a cloud service, see DescribeMetricMetaList or Appendix 1: Metrics. |
GroupMetricRules.N.EmailSubject | String | No | ECS instance | The subject of the alert notification email. Valid values of N: 1 to 200. |
GroupMetricRules.N.Period | String | No | 60 | The aggregation period of the metric data. Valid values of N: 1 to 200. Set the |
GroupMetricRules.N.RuleName | String | Yes | ECS_Rule1 | The name of the alert rule. Valid values of N: 1 to 200. |
GroupMetricRules.N.Escalations.Info.Statistics | String | No | Average | The statistical method for Info-level alerts. Valid values of N: 1 to 200. The value of this parameter is determined by the Note You must select at least one of the Critical, Warn, and Info alert levels and specify the Statistics, ComparisonOperator, Threshold, and Times parameters for the selected alert level. |
GroupMetricRules.N.Escalations.Warn.Times | Integer | No | 3 | The consecutive number of times for which the metric value meets the alert condition before a Warn-level alert is triggered. Valid values of N: 1 to 200. Note You must select at least one of the Critical, Warn, and Info alert levels and specify the Statistics, ComparisonOperator, Threshold, and Times parameters for the selected alert level. |
GroupMetricRules.N.Escalations.Info.ComparisonOperator | String | No | GreaterThanOrEqualToThreshold | The operator that is used to compare the metric value with the threshold for Info-level alerts. Valid values:
Valid values of N: 1 to 200. Note You must select at least one of the Critical, Warn, and Info alert levels and specify the Statistics, ComparisonOperator, Threshold, and Times parameters for the selected alert level. |
GroupMetricRules.N.Interval | String | No | 60 | The interval at which CloudMonitor checks whether the alert rule is triggered. Valid values of N: 1 to 200. Unit: seconds. The default value is the lowest frequency at which the metric is polled. Note We recommend that you set the interval to the data aggregation period. If the interval is shorter than the data aggregation period, alerts cannot be triggered due to insufficient data. |
GroupMetricRules.N.Category | String | Yes | ECS | 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 |
GroupMetricRules.N.Escalations.Critical.ComparisonOperator | String | No | GreaterThanOrEqualToThreshold | The operator that is used to compare the metric value with the threshold for Critical-level alerts. Valid values:
Valid values of N: 1 to 200. Note You must select at least one of the Critical, Warn, and Info alert levels and specify the Statistics, ComparisonOperator, Threshold, and Times parameters for the selected alert level. |
GroupMetricRules.N.Escalations.Warn.Statistics | String | No | Average | The statistical method for Warn-level alerts. Valid values of N: 1 to 200. The value of this parameter is determined by the Note You must select at least one of the Critical, Warn, and Info alert levels and specify the Statistics, ComparisonOperator, Threshold, and Times parameters for the selected alert level. |
GroupMetricRules.N.NoDataPolicy | String | No | KEEP_LAST_STATE | The method that is used to handle alerts when no monitoring data is found. Valid values:
Valid values of N: 1 to 200. |
GroupMetricRules.N.ContactGroups | String | No | ECS_Group | The alert contact group. Valid values of N: 1 to 200. For information about how to obtain alert contact groups, see DescribeContactGroupList. |
GroupMetricRules.N.Labels.N.Key | String | No | key1 | The tag key of the alert rule. The specified tag is contained in alert notifications. Valid values of N: 1 to 200. |
GroupMetricRules.N.Labels.N.Value | String | No | value1 | The tag value of the alert rule. The specified tag is contained in alert notifications. Valid values of N: 1 to 200. |
For more information about common request parameters, see Common parameters.
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
Code | Integer | 200 | The HTTP status code. Note The status code 200 indicates that the request was successful. |
Message | String | The Request is not authorization. | The error message. |
RequestId | String | 461CF2CD-2FC3-4B26-8645-7BD27E7D0F1D | The request ID. |
Success | Boolean | true | Indicates whether the request was successful. Valid values:
|
Resources | Array of AlertResult | The details of the alert rules. |
|
AlertResult | |||
Code | Integer | 200 | The status code that is returned for the alert rule. Note The status code 200 indicates that the request was successful. |
Message | String | Metric not found. | The error message that is returned for the alert rule. |
Success | Boolean | true | Indicates whether the alert rule is created. Valid values:
|
RuleName | String | ECS_Rule1 | The name of the alert rule. |
RuleId | String | 456789 | The ID of the alert rule. |
Examples
Sample requests
http(s)://[Endpoint]/?Action=CreateGroupMetricRules
&GroupId=123456
&GroupMetricRules.1.Category=ECS
&GroupMetricRules.1.MetricName=cpu_total
&GroupMetricRules.1.1amespace=acs_ecs_dashboard
&GroupMetricRules.1.RuleId=456789
&GroupMetricRules.1.RuleName=ECS_Rule1
&GroupMetricRules.1.Escalations.Critical.Statistics=Average
&GroupMetricRules.1.Escalations.Critical.ComparisonOperator=GreaterThanOrEqualToThreshold
&GroupMetricRules.1.Escalations.Critical.Threshold=90
&GroupMetricRules.1.Escalations.Critical.Times=3
&<Common request parameters>
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<CreateGroupMetricRulesResponse>
<RequestId>CED22B00-CFD8-5BDF-A645-CAF7B81FAE45</RequestId>
<Resources>
<AlertResult>
<RuleId>456789</RuleId>
<Code>200</Code>
<Success>true</Success>
<RuleName>ECS_Rule1</RuleName>
</AlertResult>
</Resources>
<Code>200</Code>
<Success>true</Success>
</CreateGroupMetricRulesResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "CED22B00-CFD8-5BDF-A645-CAF7B81FAE45",
"Resources" : {
"AlertResult" : [ {
"RuleId" : "456789",
"Code" : 200,
"Success" : true,
"RuleName" : "ECS_Rule1"
} ]
},
"Code" : 200,
"Success" : true
}
Error codes
For a list of error codes, see Service error codes.