resource "datadog_monitor" "postgresql_availability" { count = "${var.postgresql_availability_enabled == "true" ? 1 : 0}" name = "[${var.environment}] PostgreSQL server does not respond" message = "${coalesce(var.postgresql_availability_message, var.message)}" type = "service check" query = < ${var.postgresql_connection_threshold_critical} EOF evaluation_delay = "${var.evaluation_delay}" new_host_delay = "${var.new_host_delay}" thresholds { warning = "${var.postgresql_connection_threshold_warning}" critical = "${var.postgresql_connection_threshold_critical}" } notify_no_data = false renotify_interval = 0 require_full_window = true timeout_h = 0 include_tags = true silenced = "${var.postgresql_connection_silenced}" tags = ["env:${var.environment}", "type:database", "provider:postgres", "resource:postgresql", "team:claranet", "created-by:terraform", "${var.postgresql_connection_extra_tags}"] } resource "datadog_monitor" "postgresql_too_many_locks" { count = "${var.postgresql_lock_enabled == "true" ? 1 : 0}" name = "[${var.environment}] PostgreSQL too many locks {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}" message = "${coalesce(var.postgresql_lock_message, var.message)}" type = "metric alert" query = < ${var.postgresql_lock_threshold_critical} EOF evaluation_delay = "${var.evaluation_delay}" new_host_delay = "${var.new_host_delay}" thresholds { warning = "${var.postgresql_lock_threshold_warning}" critical = "${var.postgresql_lock_threshold_critical}" } notify_no_data = false renotify_interval = 0 require_full_window = true timeout_h = 0 include_tags = true silenced = "${var.posgresql_lock_silenced}" tags = ["env:${var.environment}", "type:database", "provider:postgres", "resource:postgresql", "team:claranet", "created-by:terraform", "${var.postgresql_lock_extra_tags}"] }