Provides a Cloud Monitor Service Metric Rule Template resource.
For information about Cloud Monitor Service Metric Rule Template and how to use it, see What is Metric Rule Template.
Basic Usage
variable "name" {
default = "tf-example"
}
resource "alicloud_cms_metric_rule_template" "example" {
metric_rule_template_name = var.name
alert_templates {
category = "ecs"
metric_name = "cpu_total"
namespace = "acs_ecs_dashboard"
rule_name = "tf_example"
escalations {
critical {
comparison_operator = "GreaterThanThreshold"
statistics = "Average"
threshold = "90"
times = "3"
}
}
}
}
The following arguments are supported:
alert_templates
- (Optional) The details of alert rules that are generated based on the alert template. See alert_templates
below. apply_mode
- (Optional) The mode in which the alert template is applied. Valid values:GROUP_INSTANCE_FIRST
or ALARM_TEMPLATE_FIRST
. GROUP_INSTANCE_FIRST: The metrics in the application group take precedence. If a metric specified in the alert template does not exist in the application group, the system does not generate an alert rule for the metric based on the alert template. ALARM_TEMPLATE_FIRST: The metrics specified in the alert template take precedence. If a metric specified in the alert template does not exist in the application group, the system still generates an alert rule for the metric based on the alert template.description
- (Optional) The description of the alert template.enable_end_time
- (Optional) The end of the time period during which the alert rule is effective. Valid values: 00 to 23. The value 00 indicates 00:59 and the value 23 indicates 23:59.enable_start_time
- (Optional) The beginning of the time period during which the alert rule is effective. Valid values: 00 to 23. The value 00 indicates 00:00 and the value 23 indicates 23:00.group_id
- (Optional) The ID of the application group.metric_rule_template_name
- (Required, ForceNew) The name of the alert template.notify_level
- (Optional) The alert notification method. Valid values:Set the value to 4. The value 4 indicates that alert notifications are sent by using TradeManager and DingTalk chatbots.rest_version
- (Optional) The version of the alert template to be modified.alert_templates
The alert_templates supports the following:
category
- (Required) The abbreviation of the service name. Valid values: ecs
, rds
, ads
, slb
, vpc
, apigateway
, cdn
, cs
, dcdn
, ddos
, eip
, elasticsearch
, emr
, ess
, hbase
, iot_edge
, kvstore_sharding
, kvstore_splitrw
, kvstore_standard
, memcache
, mns
, mongodb
, mongodb_cluster
, mongodb_sharding
, mq_topic
, ocs
, opensearch
, oss
, polardb
, petadata
, scdn
, sharebandwidthpackages
, sls
, vpn
.escalations
- (Optional) The information about the trigger condition based on the alert level. See escalations
below. metric_name
- (Required) The name of the metric.alert_templates-escalations
The escalations supports the following:
critical
- (Optional) The condition for triggering critical-level alerts. See critical
below. info
- (Optional) The condition for triggering info-level alerts. See info
below. warn
- (Optional) The condition for triggering warn-level alerts. See warn
below. alert_templates-escalations-warn
The warn supports the following:
comparison_operator
- (Optional) The comparison operator of the threshold for warn-level alerts. Valid values: GreaterThanOrEqualToThreshold
, GreaterThanThreshold
, LessThanOrEqualToThreshold
, LessThanThreshold
, NotEqualToThreshold
, GreaterThanYesterday
, LessThanYesterday
, GreaterThanLastWeek
, LessThanLastWeek
, GreaterThanLastPeriod
, LessThanLastPeriod
.statistics
- (Optional) The statistical aggregation method for warn-level alerts.threshold
- (Optional) The threshold for warn-level alerts.times
- (Optional) The consecutive number of times for which the metric value is measured before a warn-level alert is triggered.alert_templates-escalations-info
The info supports the following:
comparison_operator
- (Optional) The comparison operator of the threshold for info-level alerts. Valid values: GreaterThanOrEqualToThreshold
, GreaterThanThreshold
, LessThanOrEqualToThreshold
, LessThanThreshold
, NotEqualToThreshold
, GreaterThanYesterday
, LessThanYesterday
, GreaterThanLastWeek
, LessThanLastWeek
, GreaterThanLastPeriod
, LessThanLastPeriod
.statistics
- (Optional) The statistical aggregation method for info-level alerts.threshold
- (Optional) The threshold for info-level alerts.times
- (Optional) The consecutive number of times for which the metric value is measured before an info-level alert is triggered.alert_templates-escalations-critical
The critical supports the following:
comparison_operator
- (Optional) The comparison operator of the threshold for critical-level alerts. Valid values: GreaterThanOrEqualToThreshold
, GreaterThanThreshold
, LessThanOrEqualToThreshold
, LessThanThreshold
, NotEqualToThreshold
, GreaterThanYesterday
, LessThanYesterday
, GreaterThanLastWeek
, LessThanLastWeek
, GreaterThanLastPeriod
, LessThanLastPeriod
.statistics
- (Optional) The statistical aggregation method for critical-level alerts.threshold
- (Optional) The threshold for critical-level alerts.times
- (Optional) The consecutive number of times for which the metric value is measured before a critical-level alert is triggered.The following attributes are exported:
id
- The resource ID in terraform of Metric Rule Template.Cloud Monitor Service Metric Rule Template can be imported using the id, e.g.
$ terraform import alicloud_cms_metric_rule_template.example <id>