我想创建一个变量,以便用户可以在 Datadog 监视器消息部分中添加自定义消息。只是不确定最好的方法是什么。
监控代码:
resource "datadog_monitor" "aurora_postgres_cpu_utilization_monitor_tf" {
count = var.aurora_postgres_cpu_utilization.deploy ? 1 : 0
name = "${var.unique_prefix} - Aurora PostgreSQL RDS CPU Utilization"
type = "query alert"
query = "avg(last_${var.aurora_postgres_cpu_utilization.query_time}):avg:aws.rds.cpuutilization{%{~if local.monitor_query_string == ""}*%{else}${local.monitor_query_string}%{endif~}} by {region,dbinstanceidentifier} >= ${var.aurora_postgres_cpu_utilization.critical_threshold}"
message = <<EOF
RDS CPU Usage is averaging {{value}}, which breached current thresholds {{#is_alert}}{{threshold}}{{/is_alert}}{{#is_warning}}{{warn_threshold}}{{/is_warning}}
Percentage of CPU utilization. Recommended metric for standard monitoring. Available for Aurora DBs.
* __Severity__: {{#is_alert}}**Alert**{{/is_alert}}{{#is_warning}}**Warning**{{/is_warning}}
* __Value__: {{value}}
* __Alert threshold__: {{#is_alert}}{{threshold}}{{/is_alert}}{{#is_warning}}{{warn_threshold}}{{/is_warning}}
* __Last triggered at__: {{last_triggered_at}} ({{last_triggered_at_epoch}})
${local.notification_string}
EOF
tags = local.monitor_tags
include_tags = "true"
notification_preset_name = "hide_handles"
priority = var.aurora_postgres_cpu_utilization.priority_level
restricted_roles = var.aurora_postgres_cpu_utilization.restricted_roles
monitor_thresholds {
critical = var.aurora_postgres_cpu_utilization.critical_threshold
warning = var.aurora_postgres_cpu_utilization.warning_threshold
}
}
我将按照 @RuiJarimba 的建议进行操作并使用
${var.myvariable}
。