### Elasticsearch cluster status monitor ### /* Note about the query - If aws.es.cluster_statusred is 1 --> query value (= 2.1) > 2 : critical - If aws.es.cluster_statusyellow is 1 --> 1 < query value (=1.1) < 2 : warning Workaround : in the query, we add "0.1" to the result and we use the comparator ">=". No alert was triggered without that. */ resource "datadog_monitor" "es_cluster_status" { count = "${var.es_cluster_status_enabled == "true" ? 1 : 0}" name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] ElasticSearch cluster status is not green" message = "${coalesce(var.es_cluster_status_message, var.message)}" type = "query alert" query = <= 2 EOQ thresholds { warning = 1 critical = 2 } notify_no_data = true evaluation_delay = "${var.evaluation_delay}" renotify_interval = 0 notify_audit = false timeout_h = 0 include_tags = true locked = false require_full_window = false new_host_delay = "${var.new_host_delay}" tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:elasticsearch", "team:claranet", "created-by:terraform", "${var.es_cluster_status_extra_tags}"] } ### Elasticsearch cluster free storage space monitor ### resource "datadog_monitor" "es_free_space_low" { count = "${var.diskspace_enabled == "true" ? 1 : 0}" name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] ElasticSearch cluster free storage space {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" message = "${coalesce(var.diskspace_message, var.message)}" type = "query alert" query = < ${var.cpu_threshold_critical} EOQ thresholds { warning = "${var.cpu_threshold_warning}" critical = "${var.cpu_threshold_critical}" } notify_no_data = false evaluation_delay = "${var.evaluation_delay}" renotify_interval = 0 notify_audit = false timeout_h = 0 include_tags = true locked = false require_full_window = false new_host_delay = "${var.new_host_delay}" tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:elasticsearch", "team:claranet", "created-by:terraform", "${var.cpu_extra_tags}"] }