alicloud_cms_metric_rule_template
更新时间:
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.
-> NOTE: Available since v1.134.0.
Example Usage
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"
}
}
}
}
Argument Reference
The following arguments are supported:
metric_rule_template_name- (Required, ForceNew) The name of the alert template.description- (Optional) The description of the alert template.group_id- (Optional) The ID of the application group.apply_mode- (Optional) The mode in which the alert template is applied. Valid values:GROUP_INSTANCE_FIRST: The metrics in the application group take precedence.ALARM_TEMPLATE_FIRST: The metrics specified in the alert template take precedence.
notify_level- (Optional) The alert notification method. Valid values:2: Alert notifications are sent by using Phone, SMS, Email, TradeManager and DingTalk chatbots.3: Alert notifications are sent by using SMS, Email, TradeManager and DingTalk chatbots.4: Alert notifications are sent by using TradeManager and DingTalk chatbots.
silence_time- (Optional, Int) The mute period during which notifications are not repeatedly sent for an alert. Unit: seconds. Default value:86400. Valid values:0to86400.webhook- (Optional) The callback URL to which a POST request is sent when an alert is triggered based on the alert rule.enable_start_time- (Optional) The beginning of the time period during which the alert rule is effective. Valid values:00to23. The value00indicates 00:00 and the value23indicates 23:00.enable_end_time- (Optional) The end of the time period during which the alert rule is effective. Valid values:00to23. The value00indicates 00:59 and the value23indicates 23:59.alert_templates- (Optional, Set) The details of alert rules that are generated based on the alert template. Seealert_templatesbelow.
alert_templates
The alert_templates supports the following:
rule_name- (Required) The name of the alert rule.metric_name- (Required) The name of the metric. -> NOTE: For more information, see DescribeMetricMetaList or Appendix 1: Metrics.namespace- (Required) The namespace of the cloud service. -> NOTE: For more information, see DescribeMetricMetaList or Appendix 1: Metrics.category- (Required) The abbreviation of the Alibaba Cloud service name. -> NOTE: To obtain the abbreviation of an Alibaba Cloud service name, call the DescribeProjectMeta operation. The metricCategory tag in the Labels response parameter indicates the abbreviation of the Alibaba Cloud service name.webhook- (Optional) The callback URL to which a POST request is sent when an alert is triggered based on the alert rule.escalations- (Optional, Set) The information about the trigger condition based on the alert level. Seeescalationsbelow.
alert_templates-escalations
The escalations supports the following:
critical- (Optional, Set) The condition for triggering critical-level alerts. Seecriticalbelow.info- (Optional, Set) The condition for triggering info-level alerts. Seeinfobelow.warn- (Optional, Set) The condition for triggering warn-level alerts. Seewarnbelow.
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.
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-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.
Attributes Reference
The following attributes are exported:
id- The resource ID in terraform of Metric Rule Template.rest_version- The version of the alert template.
Import
Cloud Monitor Service Metric Rule Template can be imported using the id, e.g.
$ terraform import alicloud_cms_metric_rule_template.example <id>
该文章对您有帮助吗?