56 lines
2.5 KiB
HCL
Executable File

locals {
recipients_message = "${length(var.recipients) > 0 ? " @" : ""}${join(" @", var.recipients)}"
alert_message = length(var.alert_recipients) > 0 ? "{{#is_alert}} @${join(" @", var.alert_recipients)}{{/is_alert}}" : ""
alert_recovery_message = length(var.alert_recipients) > 0 ? "{{#is_alert_recovery}} @${join(" @", var.alert_recipients)}{{/is_alert_recovery}}" : ""
warning_message = length(var.warning_recipients) > 0 ? "{{#is_warning}} @${join(" @", var.warning_recipients)}{{/is_warning}}" : ""
warning_recovery_message = length(var.warning_recipients) > 0 ? "{{#is_warning_recovery}} @${join(" @", var.warning_recipients)}{{/is_warning_recovery}}" : ""
#full_message = <<EOF
#${var.message}
#${var.dashboard_id != "" ? "Dashboard: https://app.datadoghq.com/dashboard/${var.dashboard_id}" : ""}
#${var.dashboard_id == "" && var.timeboard_id != "" ? "Timeboard: https://app.datadoghq.com/dash/${var.timeboard_id}" : ""}
#Related timeboards: https://app.datadoghq.com/dashboard/lists?q=${join("+-+", list(var.application, var.service, var.environment))}
full_message = <<EOF
Related monitors: https://app.datadoghq.com/monitors/manage?q=tag%3A%28%22${join("%22%20AND%20%22", local.tags)}%22%29
Notification recipients:${local.recipients_message}${local.alert_message}${local.alert_recovery_message}${local.warning_message}${local.warning_recovery_message}
EOF
tags = ["team:${var.team}", "stage:${var.stage}", "application:${var.application}"]
}
#resource "datadog_monitor" "template" {
# for_each = local.rdsgraphs
#
# name = "${each.key}-${var.application}-${var.stage}"
# type = "metric alert"
#
# query = each.value
# #thresholds = "${each.value.thresholds}"
# #evaluation_delay = each.value.evaluation_delay
# evaluation_delay = 0
#
# message = local.full_message
# #escalation_message = each.value.escalation_message
# escalation_message = "Response time for aler ${each.key} is expired"
#
# #renotify_interval = each.value.renotify_interval
# renotify_interval = 0
# #notify_audit = each.value.notify_audit
# notify_audit = false
# #include_tags = each.value.include_tags
# include_tags = true
#
# #require_full_window = each.value.require_full_window
# require_full_window = true
#
# #tags = "concat(local.tags)"
# tags = local.tags
#
#
# monitor_thresholds {
# warning = "2"
# warning_recovery = "1"
# critical = "4"
# critical_recovery = "3"
# }
#}