ALIYUN::CMS::ResourceMetricRule is used to create an alert rule for a metric of a resource.
Syntax
{
"Type": "ALIYUN::CMS::ResourceMetricRule",
"Properties": {
"NoEffectiveInterval": String,
"ContactGroups": List,
"SilenceTime": Integer,
"RuleId": String,
"Period": Integer,
"Prometheus": Map,
"Labels": List,
"EffectiveInterval": String,
"NoDataPolicy": String,
"Namespace": String,
"MetricName": String,
"DeletionForce": Boolean,
"Escalations": Map,
"EmailSubject": String,
"CompositeExpression": Map,
"Webhook": String,
"Resources": List,
"RuleName": String,
"Interval": Integer
}
}
Properties
Property | Type | Required | Editable | Description | Constraint |
---|---|---|---|---|---|
NoEffectiveInterval | String | No | Yes | The time period during which the alert rule is ineffective. | Example: 00:00-23:59. |
ContactGroups | List | Yes | Yes | The alert contact groups. | CloudMonitor sends alert notifications to the alert contacts that belong to the alert
contact groups.
Note An alert contact group can contain one or more alert contacts. For more information
about how to create an alert contact and an alert contact group, see PutContact and PutContactGroup.
|
SilenceTime | Integer | No | Yes | The mute period during which a new alert notification is not sent even if the trigger conditions are met. | Unit: seconds. Default value: 86400.
Note If an alert is not cleared within the mute period, a new alert notification is sent
when the mute period ends.
|
RuleId | String | No | No | The ID of the alert rule. | You can specify a new alert rule ID or the ID of an existing alert rule. For more
information about how to query the ID of an alert rule, see DescribeMetricRuleList.
Note If you specify a new ID, a threshold-triggered alert rule is created.
|
Period | Integer | No | Yes | The statistical period of the metric. | Unit: seconds. The default value is the interval at which the monitoring data of the
metric is collected.
Note For more information about how to query the statistical period of a metric, see Overview.
|
Prometheus | Map | No | Yes | The Prometheus alert rule. | For more information, see Prometheus properties.
Note This property is required if you create a Prometheus alert rule for Hybrid Cloud Monitoring.
|
Labels | List | No | Yes | The tags. | For more information, see Labels properties. |
EffectiveInterval | String | No | Yes | The time period during which the alert rule is effective. | Example: 00:00-23:59. |
NoDataPolicy | String | No | Yes | The method that you want to use to handle alerts when no monitoring data is found. | Default value: KEEP_LAST_STATE. Valid values:
|
Namespace | String | Yes | Yes | The namespace of the cloud service. | For more information about how to query the namespace of a cloud service, see Overview.
Note If you create a Prometheus alert rule for Hybrid Cloud Monitoring, you must set this
property to acs_prometheus.
|
MetricName | String | Yes | Yes | The name of the metric. | For more information about how to query the name of a metric, see Overview.
Note If you create a Prometheus alert rule for Hybrid Cloud Monitoring, you must set this
property to the name of a namespace. For more information about how to query the name
of a namespace, see DescribeHybridMonitorNamespaceList.
|
DeletionForce | Boolean | No | Yes | Specifies whether to forcefully delete the alert rule. | Valid values:
|
Escalations | Map | Yes | Yes | Details of the alerts. | For more information, see Escalations properties. |
EmailSubject | String | No | Yes | The subject of the alert notification email. | None. |
CompositeExpression | Map | No | Yes | The trigger conditions for multiple metrics. | For more information, see CompositeExpression properties.
Note The trigger conditions for a single metric and multiple metrics are mutually exclusive.
You cannot specify the same trigger conditions for a single metric and multiple metrics.
|
Webhook | String | No | Yes | The callback URL to which a POST request is sent when an alert is triggered based on the alert rule. | None. |
Resources | List | Yes | Yes | The information about the resource. | Example: [{"instanceId":"i-uf6j91r34rnwawoo****"}] or [{"userId":"100931896542****"}] . For more information about the dimensions based on which you can query resources,
see Overview.
|
RuleName | String | No | Yes | The name of the alert rule. | You can specify a new alert rule name or the name of an existing alert rule in CloudMonitor.
For more information about how to query the name of an alert rule, see DescribeMetricRuleList.
Note If you specify a new name, a threshold-triggered alert rule is created.
|
Interval | Integer | No | Yes | The interval at which the alert rule is triggered. | Unit: seconds.
Note For more information about how to query the statistical period of a metric, see Overview.
|
Prometheus syntax
"Prometheus": {
"Annotations": List,
"PromQL": String,
"Times": Integer,
"Level": String
}
Prometheus properties
Property | Type | Required | Editable | Description | Constraint |
---|---|---|---|---|---|
Annotations | List | No | Yes | The annotations of the Prometheus alert rule. When a Prometheus alert is triggered, the system renders the keys and values of the annotations. | For more information, see Annotations properties.
Note This property has the same effect as the Annotations property in the Prometheus property.
|
PromQL | String | Yes | Yes | The PromQL query statement. | None. |
Times | Integer | Yes | Yes | The number of consecutive times for which the metric values must meet the trigger conditions before CloudMonitor sends alert notifications. | None. |
Level | String | Yes | Yes | The level of the alert. | Valid values:
|
Annotations syntax
"Annotations": [
{
"Value": String,
"Key": String
}
]
Annotations properties
Property | Type | Required | Editable | Description | Constraint |
---|---|---|---|---|---|
Value | String | No | Yes | The value of the annotation. | None. |
Key | String | No | Yes | The key of the annotation. | None. |
Labels syntax
"Labels": [
{
"Value": String,
"Key": String
}
]
Labels properties
Property | Type | Required | Editable | Description | Constraint |
---|---|---|---|---|---|
Value | String | No | Yes | The key of the tag. | None. |
Key | String | Yes | Yes | The value of the tag. | None. |
Escalations syntax
"Escalations": {
"Critical": Map,
"Info": Map,
"Warn": Map
}
Escalations properties
Property | Type | Required | Editable | Description | Constraint |
---|---|---|---|---|---|
Critical | Map | No | Yes | Details of the Critical-level alert. | For more information, see Critical properties. |
Info | Map | No | Yes | Details of the Info-level alert. | For more information, see Info properties. |
Warn | Map | No | Yes | Details of the Warn-level alert. | 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 for the Critical-level alert. | Valid values:
Note You must configure at least one of the Critical, Warn, and Info alert levels and specify
the Statistics, ComparisonOperator, Threshold, and Times properties for the alert
level.
|
Times | Integer | Yes | Yes | The number of consecutive times for which the metric value must meet the trigger condition before the Critical-level alert is triggered. |
Note You must configure at least one of the Critical, Warn, and Info alert levels and specify
the Statistics, ComparisonOperator, Threshold, and Times properties for the alert
level.
|
Statistics | String | Yes | Yes | The statistical method for the Critical-level alert. | Valid values:
Note You must configure at least one of the Critical, Warn, and Info alert levels and specify
the Statistics, ComparisonOperator, Threshold, and Times properties for the alert
level.
|
Threshold | String | Yes | Yes | The threshold for the Critical-level alert. |
Note You must configure at least one of the Critical, Warn, and Info alert levels and specify
the Statistics, ComparisonOperator, Threshold, and Times properties for the alert
level.
|
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 for the Info-level alert. | Valid values:
Note You must configure at least one of the Critical, Warn, and Info alert levels and specify
the Statistics, ComparisonOperator, Threshold, and Times properties for the alert
level.
|
Times | Integer | Yes | Yes | The number of consecutive times for which the metric value must meet the trigger condition before the Info-level alert is triggered. |
Note You must configure at least one of the Critical, Warn, and Info alert levels and specify
the Statistics, ComparisonOperator, Threshold, and Times properties for the alert
level.
|
Statistics | String | Yes | Yes | The statistical method for the Info-level alert. | Valid values:
Note You must configure at least one of the Critical, Warn, and Info alert levels and specify
the Statistics, ComparisonOperator, Threshold, and Times properties for the alert
level.
|
Threshold | String | Yes | Yes | The threshold for the Info-level alert. |
Note You must configure at least one of the Critical, Warn, and Info alert levels and specify
the Statistics, ComparisonOperator, Threshold, and Times properties for the alert
level.
|
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 for the Warn-level alert. | Valid values:
Note You must configure at least one of the Critical, Warn, and Info alert levels and specify
the Statistics, ComparisonOperator, Threshold, and Times properties for the alert
level.
|
Times | Integer | Yes | Yes | The number of consecutive times for which the metric value must meet the trigger condition before the Warn-level alert is triggered. |
Note You must configure at least one of the Critical, Warn, and Info alert levels and
specify the Statistics, ComparisonOperator, Threshold, and Times properties for the
alert level.
|
Statistics | String | Yes | Yes | The statistical method for the Warn-level alert. | Valid values:
Note You must configure at least one of the Critical, Warn, and Info alert levels and specify
the Statistics, ComparisonOperator, Threshold, and Times properties for the alert
level.
|
Threshold | String | Yes | Yes | The threshold for the Warn-level alert. |
Note You must configure at least one of the Critical, Warn, and Info alert levels and specify
the Statistics, ComparisonOperator, Threshold, and Times properties for the alert
level.
|
CompositeExpression syntax
"CompositeExpression": {
"Times": Integer,
"ExpressionRaw": String,
"ExpressionListJoin": String,
"Level": String,
"ExpressionList": List
}
CompositeExpression properties
Property | Type | Required | Editable | Description | Constraint |
---|---|---|---|---|---|
Times | Integer | Yes | Yes | The number of consecutive times for which the metric values must meet the trigger conditions before CloudMonitor sends alert notifications. | None. |
ExpressionRaw | String | No | Yes | The trigger conditions that are created by using expressions. | You can use expressions to create trigger conditions in the following scenarios:
|
ExpressionListJoin | String | No | Yes | The relationship between the trigger conditions for multiple metrics. | Valid values:
|
Level | String | Yes | Yes | The level of the alert. | Valid values:
|
ExpressionList | List | No | Yes | The trigger conditions that are created in standard mode. | For more information, see ExpressionList properties. |
ExpressionList syntax
"ExpressionList": [
{
"MetricName": String,
"ComparisonOperator": String,
"Period": Integer,
"Statistics": String,
"Threshold": String
}
]
ExpressionList properties
Property | Type | Required | Editable | Description | Constraint |
---|---|---|---|---|---|
MetricName | String | Yes | Yes | The name of the metric of a cloud service. | None. |
ComparisonOperator | String | Yes | Yes | The comparison operator of the threshold. | Valid values:
|
Period | Integer | Yes | Yes | The aggregation period of the metric. | Unit: seconds. |
Statistics | String | Yes | Yes | The statistical method of the metric. | Valid values:
Note $ is the prefix of the metric. For more information about the cloud services that
are supported by CloudMonitor, see Overview.
|
Threshold | String | Yes | Yes | The alert threshold. | None. |
Return values
Fn::GetAtt
- RuleId: the ID of the alert rule.
- RuleName: the name of the alert rule.
Examples
JSON
format
{
"ROSTemplateFormatVersion": "2015-09-01",
"Parameters": {
"ContactGroups": {
"Type": "Json",
"Description": "The alert contact group.\nThe alert notifications are sent to the contacts that belong to the alert contact group.\nNote: An alert contact group can contain one or more alert contacts. For information about how to create alert contacts and alert contact groups, see PutContact and PutContactGroup.",
"MinLength": 1
},
"Namespace": {
"Type": "String",
"Description": "The namespace of the cloud service.\nFor information about how to query the namespace of a cloud service, Appendix 1: Metrics.\nNote: If you create a Prometheus alert rule for Hybrid Cloud Monitoring, you must set this parameter to acs_prometheus."
},
"MetricName": {
"Type": "String",
"Description": "The name of the metric.\nFor information about how to query the name of a metric, see Appendix 1: Metrics.\nNote: If you create a Prometheus alert rule for Hybrid Cloud Monitoring, you must set this parameter to the name of the namespace. For information about how to obtain the name of a namespace, see DescribeHybridMonitorNamespaceList."
},
"Escalations": {
"Type": "Json",
"Description": "You must select at least one of the Critical, Warn, and Info alert levels.",
"MinLength": 1
},
"Resources": {
"Type": "Json",
"Description": "The information about the resource.\nExamples: [{\"instanceId\":\"i-uf6j91r34rnwawoo****\"}] and [{\"userId\":\"100931896542****\"}].\nFor information about the supported dimensions that are used to query resources, see Appendix 1: Metrics.",
"MinLength": 1
}
},
"Resources": {
"ResourceMetricRule": {
"Type": "ALIYUN::CMS::ResourceMetricRule",
"Properties": {
"ContactGroups": {
"Ref": "ContactGroups"
},
"Namespace": {
"Ref": "Namespace"
},
"MetricName": {
"Ref": "MetricName"
},
"Resources": {
"Ref": "Resources"
},
"Escalations": {
"Ref": "Escalations"
}
}
}
},
"Outputs": {
"RuleId": {
"Description": "The ID of the alert rule.",
"Value": {
"Fn::GetAtt": [
"ResourceMetricRule",
"RuleId"
]
}
},
"RuleName": {
"Description": "The name of the alert rule.",
"Value": {
"Fn::GetAtt": [
"ResourceMetricRule",
"RuleName"
]
}
}
}
}