data "template_file" "filter" { template = "$${filter}" vars { filter = "${var.filter_tags_use_defaults == "true" ? format("subscription_id:%s", var.subscription_id) : "${var.filter_tags_custom}"}" } } resource "datadog_monitor" "cosmos_db_4xx_requests" { name = "[${var.environment}] Cosmos DB 4xx requests rate is too low {{#is_alert}}{{comparator}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{comparator}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" message = "${coalesce(var.cosmos_db_4xx_requests_message, var.message)}" query = < ${var.cosmos_db_4xx_request_rate_threshold_critical} EOF type = "metric alert" thresholds { critical = "${var.cosmos_db_4xx_request_rate_threshold_critical}" warning = "${var.cosmos_db_4xx_request_rate_threshold_warning}" } silenced = "${var.cosmos_db_4xx_requests_silenced}" notify_no_data = false evaluation_delay = "${var.delay}" renotify_interval = 0 notify_audit = false timeout_h = 0 include_tags = true locked = false require_full_window = true new_host_delay = "${var.delay}" no_data_timeframe = 20 tags = ["env:${var.environment}", "resource:cosmos_db", "team:azure", "provider:azure"] } resource "datadog_monitor" "cosmos_db_5xx_requests" { name = "[${var.environment}] Cosmos DB 5xx requests rate is too low {{#is_alert}}{{comparator}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{comparator}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" message = "${coalesce(var.cosmos_db_5xx_requests_message, var.message)}" query = < ${var.cosmos_db_5xx_request_rate_threshold_critical} EOF type = "metric alert" thresholds { critical = "${var.cosmos_db_5xx_request_rate_threshold_critical}" warning = "${var.cosmos_db_5xx_request_rate_threshold_warning}" } silenced = "${var.cosmos_db_5xx_requests_silenced}" notify_no_data = false evaluation_delay = "${var.delay}" renotify_interval = 0 notify_audit = false timeout_h = 0 include_tags = true locked = false require_full_window = true new_host_delay = "${var.delay}" no_data_timeframe = 20 tags = ["env:${var.environment}", "resource:cosmos_db", "team:azure", "provider:azure"] } resource "datadog_monitor" "cosmos_db_success_no_data" { name = "[${var.environment}] Cosmos DB has no request" message = "${coalesce(var.cosmos_db_no_request_message, var.message)}" query = <