resource "datadog_monitor" "mongodb_primary" { count = "${var.mongodb_primary_enabled == "true" ? 1 : 0}" name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] MongoDB primary state" message = "${coalesce(var.mongodb_primary_message, var.message)}" query = <= 2 EOQ type = "metric alert" notify_no_data = true renotify_interval = 0 evaluation_delay = "${var.evaluation_delay}" new_host_delay = "${var.new_host_delay}" notify_audit = false timeout_h = 0 include_tags = true require_full_window = true tags = ["env:${var.environment}", "type:database", "provider:mongo", "resource:mongodb", "team:claranet", "created-by:terraform", "${var.mongodb_primary_extra_tags}"] } resource "datadog_monitor" "mongodb_secondary" { count = "${var.mongodb_secondary_enabled == "true" ? 1 : 0}" name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] MongoDB secondary missing" message = "${coalesce(var.mongodb_secondary_message, var.message)}" query = < 1 EOQ thresholds { critical = 1 warning = 0 } type = "metric alert" notify_no_data = false renotify_interval = 0 evaluation_delay = "${var.evaluation_delay}" new_host_delay = "${var.new_host_delay}" notify_audit = false timeout_h = 0 include_tags = true require_full_window = true tags = ["env:${var.environment}", "type:database", "provider:mongo", "resource:mongodb", "team:claranet", "created-by:terraform", "${var.mongodb_secondary_extra_tags}"] } resource "datadog_monitor" "mongodb_server_count" { count = "${var.mongodb_server_count_enabled == "true" ? 1 : 0}" name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] MongoDB too much servers or wrong monitoring config" message = "${coalesce(var.mongodb_server_count_message, var.message)}" query = < 99 EOQ thresholds { critical = 99 warning = "${var.mongodb_desired_servers_count}" } type = "metric alert" notify_no_data = false renotify_interval = 0 evaluation_delay = "${var.evaluation_delay}" new_host_delay = "${var.new_host_delay}" notify_audit = false timeout_h = 0 include_tags = true require_full_window = true tags = ["env:${var.environment}", "type:database", "provider:mongo", "resource:mongodb", "team:claranet", "created-by:terraform", "${var.mongodb_secondary_extra_tags}"] } resource "datadog_monitor" "mongodb_replication" { count = "${var.mongodb_replication_enabled == "true" ? 1 : 0}" name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] MongoDB replication lag" message = "${coalesce(var.mongodb_replication_message, var.message)}" query = < ${var.mongodb_lag_critical} EOQ thresholds { critical = "${var.mongodb_lag_critical}" warning = "${var.mongodb_lag_warning}" } type = "metric alert" notify_no_data = false renotify_interval = 0 evaluation_delay = "${var.evaluation_delay}" new_host_delay = "${var.new_host_delay}" notify_audit = false timeout_h = 0 include_tags = true require_full_window = true tags = ["env:${var.environment}", "type:database", "provider:mongo", "resource:mongodb", "team:claranet", "created-by:terraform", "${var.mongodb_replication_extra_tags}"] }