ALIYUN::CMS::MetricRuleTemplate is used to create an alert rule template.
Syntax
{
"Type": "ALIYUN::CMS::MetricRuleTemplate",
"Properties": {
"AlertTemplates": List,
"Description": String,
"RestVersion": Integer,
"TemplateId": Integer,
"Name": String
}
}
Properties
Property | Type | Required | Editable | Description | Constraint |
Name | String | Yes | No | The name of the alert rule template. | None. |
AlertTemplates | List | No | Yes | Details of the alert rule template. | You can specify up to 200 alert rules in an alert rule template. For more information, see AlertTemplates properties. |
Description | String | No | Yes | The description of the alert rule template. | None. |
RestVersion | Integer | No | No | The version of the alert rule template. | Default value: 0. |
TemplateId | Integer | No | No | The ID of the template that you want to clone. | None. |
AlertTemplates syntax
"AlertTemplates": [
{
"MetricName": String,
"Category": String,
"Escalations": Map,
"Period": Integer,
"Webhook": String,
"Namespace": String,
"RuleName": String,
"Selector": String
}
]
AlertTemplates properties
Property | Type | Required | Editable | Description | Constraint |
Category | String | Yes | Yes | The abbreviation of the service name or feature. | Valid values:
|
MetricName | String | Yes | Yes | The name of the metric. | None. |
Namespace | String | Yes | Yes | The namespace of the cloud service. | For more information, see DescribeMetricMetaList or Usage notes. |
RuleName | String | Yes | Yes | The name of the alert rule. | None. |
Escalations | Map | No | No | The alert settings. | For more information, see Escalations properties. |
Period | Integer | No | Yes | The aggregation period of the metric data. | The default value is the lowest frequency at which the metric is polled. In most cases, you do not need to specify the aggregation period. Unit: seconds. |
Selector | String | No | Yes | The extended field selector. | None. |
Webhook | String | No | No | The webhook address to which a request is sent when an alert is triggered. | None. |
Escalations syntax
"Escalations": {
"Critical": Map,
"Info": Map,
"Warn": Map
}
Escalations properties
Property | Type | Required | Editable | Description | Constraint |
Critical | Map | Yes | Yes | The settings for critical-level alerts. | For more information, see Critical properties. |
Info | Map | No | Yes | The settings for info-level alerts. | For more information, see Info properties. |
Warn | Map | No | Yes | The settings for warn-level alerts. | For more information, see Warn properties. |
Critical syntax
"Critical": {
"ComparisonOperator": String,
"Times": Integer,
"Statistics": String,
"Threshold": String
}
Critical properties
Property | Type | Required | Editable | Description | Constraint |
ComparisonOperator | String | Yes | Yes | The comparison operator of the threshold. | Valid values:
|
Statistics | String | Yes | Yes | The method used to calculate the metric value based on which alerts are triggered. | None. |
Threshold | String | Yes | Yes | The alert threshold. | None. |
Times | Integer | Yes | Yes | The consecutive number of times for which the metric value meets the alert condition before an alert is triggered. | None. |
Info syntax
"Info": {
"ComparisonOperator": String,
"Times": Integer,
"Statistics": String,
"Threshold": String
}
Info properties
Property | Type | Required | Editable | Description | Constraint |
ComparisonOperator | String | Yes | Yes | The comparison operator of the threshold. | Valid values:
|
Statistics | String | Yes | Yes | The method used to calculate the metric value based on which alerts are triggered. | None. |
Threshold | String | Yes | Yes | The alert threshold. | None. |
Times | Integer | Yes | Yes | The consecutive number of times for which the metric value meets the alert condition before an alert is triggered. | None. |
Warn syntax
"Warn": {
"ComparisonOperator": String,
"Times": Integer,
"Statistics": String,
"Threshold": String
}
Warn properties
Property | Type | Required | Editable | Description | Constraint |
ComparisonOperator | String | Yes | Yes | The comparison operator of the threshold. | Valid values:
|
Statistics | String | Yes | Yes | The method used to calculate the metric value based on which alerts are triggered. | None. |
Threshold | String | Yes | Yes | The alert threshold. | None. |
Times | Integer | Yes | Yes | The consecutive number of times for which the metric value meets the alert condition before an alert is triggered. | None. |
Return values
Fn::GetAtt
Id: the ID of the alert rule template.
Examples
YAML
ROSTemplateFormatVersion: '2015-09-01'
Parameters: {}
Resources:
MetricRuleTemplate:
Type: ALIYUN::CMS::MetricRuleTemplate
Properties:
AlertTemplates:
- Category: ecs
Namespace: acs_ecs_dashboard
Period: 60
Webhook: http://ww.aliyun.com
RuleName: CPU monitoring
Selector: ''
MetricName: cpu_total
Escalations:
Critical:
Statistics: Average
Threshold: '90'
ComparisonOperator: GreaterThanOrEqualToThreshold
Times: 3
Warn:
Statistics: Average
Threshold: '80'
ComparisonOperator: GreaterThanOrEqualToThreshold
Times: 3
Info:
Statistics: Average
Threshold: '70'
ComparisonOperator: GreaterThanOrEqualToThreshold
Times: 3
- Category: ecs
Namespace: acs_ecs_dashboard
Period: 60
RuleName: Disk monitoring
Selector: '{"disk":"/"}'
MetricName: diskusage_total
Escalations:
Critical:
Statistics: Average
Threshold: '500'
ComparisonOperator: GreaterThanOrEqualToThreshold
Times: 5
Name: TestMetricRuleTemplate
Outputs:
Id:
Description: Alarm template ID.
Value:
Fn::GetAtt:
- MetricRuleTemplate
- Id
JSON
{
"ROSTemplateFormatVersion": "2015-09-01",
"Parameters": {
},
"Resources": {
"MetricRuleTemplate": {
"Type": "ALIYUN::CMS::MetricRuleTemplate",
"Properties": {
"AlertTemplates": [
{
"Category": "ecs",
"Namespace": "acs_ecs_dashboard",
"Period": 60,
"Webhook": "http://ww.aliyun.com",
"RuleName": "CPU monitoring",
"Selector": "",
"MetricName": "cpu_total",
"Escalations": {
"Critical": {
"Statistics": "Average",
"Threshold": "90",
"ComparisonOperator": "GreaterThanOrEqualToThreshold",
"Times": 3
},
"Warn": {
"Statistics": "Average",
"Threshold": "80",
"ComparisonOperator": "GreaterThanOrEqualToThreshold",
"Times": 3
},
"Info": {
"Statistics": "Average",
"Threshold": "70",
"ComparisonOperator": "GreaterThanOrEqualToThreshold",
"Times": 3
}
}
},
{
"Category": "ecs",
"Namespace": "acs_ecs_dashboard",
"Period": 60,
"RuleName": "Disk monitoring",
"Selector": "{\"disk\":\"/\"}",
"MetricName": "diskusage_total",
"Escalations": {
"Critical": {
"Statistics": "Average",
"Threshold": "500",
"ComparisonOperator": "GreaterThanOrEqualToThreshold",
"Times": 5
}
}
}
],
"Name": "TestMetricRuleTemplate"
}
}
},
"Outputs": {
"Id": {
"Description": "Alarm template ID.",
"Value": {
"Fn::GetAtt": [
"MetricRuleTemplate",
"Id"
]
}
}
}
}