data "template_file" "filter" { template = "$${filter}" vars { filter = "${var.filter_tags_use_defaults == "true" ? format("dd_monitoring:enabled,dd_mysql:enabled,db_env:%s", var.environment) : "${var.filter_tags_custom}"}" } } resource "datadog_monitor" "mysql_connection_too_high" { name = "[${var.environment}] Mysql Connections {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" message = "${coalesce(var.mysql_connection_message, var.message)}" type = "metric alert" query = < ${var.mysql_connection_threshold_critical} EOF evaluation_delay = "${var.delay}" new_host_delay = "${var.delay}" thresholds { warning = "${var.mysql_connection_threshold_warning}" critical = "${var.mysql_connection_threshold_critical}" } notify_no_data = true renotify_interval = 0 require_full_window = true timeout_h = 0 include_tags = true silenced = "${var.mysql_connection_silenced}" tags = ["env:${var.environment}", "resource:mysql"] } resource "datadog_monitor" "mysql_thread_too_high" { name = "[${var.environment}] Mysql threads {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}" message = "${coalesce(var.mysql_thread_message, var.message)}" type = "metric alert" query = < ${var.mysql_thread_threshold_critical} EOF evaluation_delay = "${var.delay}" new_host_delay = "${var.delay}" thresholds { warning = "${var.mysql_thread_threshold_warning}" critical = "${var.mysql_thread_threshold_critical}" } notify_no_data = true renotify_interval = 0 require_full_window = true timeout_h = 0 include_tags = true silenced = "${var.mysql_thread_silenced}" tags = ["env:${var.environment}", "resource:mysql"] }