resource "datadog_monitor" "postgresql_availability" { count = var.postgresql_availability_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] PostgreSQL server does not respond" message = coalesce(var.postgresql_availability_message, var.message) type = "service check" query = < ${var.postgresql_connection_threshold_critical} EOQ thresholds = { warning = var.postgresql_connection_threshold_warning critical = var.postgresql_connection_threshold_critical } evaluation_delay = var.evaluation_delay new_host_delay = var.new_host_delay notify_no_data = false renotify_interval = 0 require_full_window = true timeout_h = 0 include_tags = true 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.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${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 = "query alert" query = < ${var.postgresql_lock_threshold_critical} EOQ thresholds = { warning = var.postgresql_lock_threshold_warning critical = var.postgresql_lock_threshold_critical } evaluation_delay = var.evaluation_delay new_host_delay = var.new_host_delay notify_no_data = false renotify_interval = 0 require_full_window = true timeout_h = 0 include_tags = true tags = ["env:${var.environment}", "type:database", "provider:postgres", "resource:postgresql", "team:claranet", "created-by:terraform", var.postgresql_lock_extra_tags] }