data "template_file" "filter" { template = "$${filter}" vars { filter = "${var.filter_tags_use_defaults == "true" ? format("dd_monitoring:enabled,dd_aws_red:enabled,env:%s", var.environment) : "${var.filter_tags_custom}"}" } } module "datadog-monitors-aws-elasticcache-common" { source = "../common" message = "${var.message}" environment = "${var.environment}" filter_tags = "${data.template_file.filter.rendered}" resource = "redis" } resource "datadog_monitor" "redis_cache_hits" { name = "[${var.environment}] Elasticache redis cache hits {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" message = "${coalesce(var.cache_hits_message, var.message)}" type = "metric alert" query = < ${var.cpu_high_threshold_critical / element(values(local.core), count.index)} EOF 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 = false new_host_delay = "${var.delay}" silenced = "${var.cpu_high_silenced}" tags = ["env:${var.environment}", "engine:redis", "team:aws", "provider:aws"] } resource "datadog_monitor" "redis_swap" { name = "[${var.environment}] Elasticache redis is starting to swap ({{value}}MB)" message = "${coalesce(var.swap_message, var.message)}" type = "metric alert" query = < 0 EOF 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 = false new_host_delay = "${var.delay}" silenced = "${var.swap_silenced}" tags = ["env:${var.environment}", "engine:redis", "team:aws", "provider:aws"] } resource "datadog_monitor" "redis_replication_lag" { name = "[${var.environment}] Elasticache redis replication lag {{#is_alert}}{{{comparator}}} {{threshold}}s ({{value}}s){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}s ({{value}}s){{/is_warning}}" message = "${coalesce(var.replication_lag_message, var.message)}" type = "metric alert" query = < ${var.replication_lag_threshold_critical} EOF thresholds { warning = "${var.replication_lag_threshold_warning}" critical = "${var.replication_lag_threshold_critical}" } 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 = false new_host_delay = "${var.delay}" silenced = "${var.replication_lag_silenced}" tags = ["env:${var.environment}", "engine:redis", "team:aws", "provider:aws"] } resource "datadog_monitor" "redis_commands" { name = "[${var.environment}] Elasticache redis is receiving no commands" message = "${coalesce(var.commands_message, var.message)}" type = "metric alert" query = <