Creates an alert template.
This topic provides an example to show how to create an alert template named Template_test
and create an alert rule for the cpu_total
metric of Elastic Compute Service (ECS) in the template. The name of the alert rule
is Rule_test
. The alert level is Critical
. The statistical method is Average
. The alert threshold comparator is GreaterThanOrEqualToThreshold
. The alert threshold is 90
. The number of alert retries is 3
. The response shows that the alert template is created and the alert template ID
is 12345
.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | CreateMetricRuleTemplate |
The operation that you want to perform. Set the value to CreateMetricRuleTemplate. |
Name | String | Yes | Template_test |
The name of the alert template. |
AlertTemplates.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. |
AlertTemplates.N.RuleName | String | Yes | Rule_test |
The name of the alert rule. Valid values of N: 1 to 200. |
AlertTemplates.N.Category | String | Yes | ecs |
The abbreviation of the service name. Valid values of N: 1 to 200. Valid values:
|
AlertTemplates.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. |
Description | String | No | ECS_Template1 |
The description of the alert template. |
AlertTemplates.N.Period | Integer | No | 60 |
The aggregation period of the metric data. Valid values of N: 1 to 200. Set the |
AlertTemplates.N.Selector | String | No | {"disk":"/"} |
The extended field selectors. Valid values of N: 1 to 200. |
AlertTemplates.N.Escalations.Critical.Statistics | String | No | Average |
The statistical methods for Critical-level alerts. Separate multiple statistical methods with commas (,). Valid values of N: 1 to 200. Valid values:
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.
|
AlertTemplates.N.Escalations.Critical.ComparisonOperator | String | No | GreaterThanOrEqualToThreshold |
The comparison operator that is used to compare the metric value with the threshold. Valid values of N: 1 to 200. Valid values:
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.
|
AlertTemplates.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.
|
AlertTemplates.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.
|
AlertTemplates.N.Escalations.Warn.Statistics | String | No | Average |
The statistical methods for Warn-level alerts. Separate multiple statistical methods with commas (,). Valid values of N: 1 to 200. Valid values:
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.
|
AlertTemplates.N.Escalations.Warn.ComparisonOperator | String | No | GreaterThanOrEqualToThreshold |
The comparison operator that is used to compare the metric value with the threshold. Valid values of N: 1 to 200. Valid values:
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.
|
AlertTemplates.N.Escalations.Warn.Threshold | String | No | 90 |
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.
|
AlertTemplates.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.
|
AlertTemplates.N.Escalations.Info.Statistics | String | No | Average |
The statistical methods for Info-level alerts. Separate multiple statistical methods with commas (,). Valid values of N: 1 to 200. Valid values:
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.
|
AlertTemplates.N.Escalations.Info.ComparisonOperator | String | No | GreaterThanOrEqualToThreshold |
The comparison operator that is used to compare the metric value with the threshold. Valid values of N: 1 to 200. Valid values:
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.
|
AlertTemplates.N.Escalations.Info.Threshold | String | No | 90 |
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.
|
AlertTemplates.N.Escalations.Info.Times | Integer | No | 3 |
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.
|
AlertTemplates.N.Webhook | String | No | http://ww.aliyun.com |
The callback URL. Valid values of N: 1 to 200. The callback URL must be accessible over the Internet. CloudMonitor pushes an alert notification to the specified callback URL by sending an HTTP POST request. Only the HTTP protocol is supported. |
For more information about common request parameters, see Common parameters.
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
RequestId | String | 9763ED1A-4D09-41BF-851E-310421750204 |
The ID of the request. |
Success | Boolean | true |
Indicates whether the call is successful. Valid values:
|
Code | Integer | 200 |
The HTTP status code. Note The status code 200 indicates that the call is successful.
|
Id | Long | 12345 |
The ID of the alert template. |
Message | String | The Request is not authorization. |
The error message. |
Examples
Sample requests
http(s)://[Endpoint]/?Action=CreateMetricRuleTemplate
&Name=Template_test
&AlertTemplates.1.MetricName=cpu_total
&AlertTemplates.1.RuleName=Rule_test
&AlertTemplates.1.Category=ecs
&AlertTemplates.1.1amespace=acs_ecs_dashboard
&<Common request parameters>
Sample success responses
XML
format
<CreateMetricRuleTemplateResponse>
<RequestId>9763ED1A-4D09-41BF-851E-310421750204</RequestId>
<Id>12345</Id>
<Success>true</Success>
<Code>200</Code>
</CreateMetricRuleTemplateResponse>
JSON
format
{
"RequestId": "9763ED1A-4D09-41BF-851E-310421750204",
"Id": 12345,
"Success": true,
"Code": 200
}
Error codes
For a list of error codes, visit the API Error Center.