diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4ec2c9c..c2f5f05 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,7 +11,7 @@ before_script: - apk add --no-cache curl auto_update: - image: hashicorp/terraform:0.11.14 + image: hashicorp/terraform:0.12.1 stage: test script: - apk add --no-cache bash git grep coreutils diff --git a/caas/kubernetes/ark/inputs.tf b/caas/kubernetes/ark/inputs.tf index 2e5d4cc..c62fb1c 100644 --- a/caas/kubernetes/ark/inputs.tf +++ b/caas/kubernetes/ark/inputs.tf @@ -42,25 +42,25 @@ variable "prefix_slug" { variable "ark_schedules_monitor_message" { description = "Custom message for Ark schedules monitor" - type = "string" + type = string default = "" } variable "ark_schedules_monitor_timeframe" { description = "Monitor timeframe for Ark schedules monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_1d" } variable "ark_schedules_enabled" { description = "Flag to enable Ark schedules monitor" - type = "string" + type = string default = "true" } variable "ark_schedules_extra_tags" { description = "Extra tags for Ark schedules monitor" - type = "list" + type = list(string) default = [] } @@ -68,3 +68,4 @@ variable "ark_schedules_monitor_no_data_timeframe" { description = "No data timeframe in minutes" default = 1440 } + diff --git a/caas/kubernetes/ark/modules.tf b/caas/kubernetes/ark/modules.tf index 1271818..d3f43ff 100644 --- a/caas/kubernetes/ark/modules.tf +++ b/caas/kubernetes/ark/modules.tf @@ -1,9 +1,10 @@ module "filter-tags" { source = "../../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "ark" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded } + diff --git a/caas/kubernetes/ark/monitors-ark.tf b/caas/kubernetes/ark/monitors-ark.tf index 5a502b2..60306af 100644 --- a/caas/kubernetes/ark/monitors-ark.tf +++ b/caas/kubernetes/ark/monitors-ark.tf @@ -1,29 +1,30 @@ resource "datadog_monitor" "ark_schedules_monitor" { - count = "${var.ark_schedules_enabled == "true" ? 1 : 0}" + count = var.ark_schedules_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Ark backup failed" type = "query alert" - message = "${coalesce(var.ark_schedules_monitor_message, var.message)}" + message = coalesce(var.ark_schedules_monitor_message, var.message) query = < 1 - EOQ +EOQ - thresholds { + thresholds = { critical = 1 - warning = 0 + warning = 0 } - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" - no_data_timeframe = "${var.ark_schedules_monitor_no_data_timeframe}" + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay + no_data_timeframe = var.ark_schedules_monitor_no_data_timeframe - notify_no_data = true - renotify_interval = 0 - notify_audit = false - timeout_h = 0 - include_tags = true - locked = false + notify_no_data = true + renotify_interval = 0 + notify_audit = false + timeout_h = 0 + include_tags = true + locked = false require_full_window = false - tags = ["env:${var.environment}", "type:caas", "provider:prometheus", "resource:ark", "team:claranet", "created-by:terraform", "${var.ark_schedules_extra_tags}"] + tags = ["env:${var.environment}", "type:caas", "provider:prometheus", "resource:ark", "team:claranet", "created-by:terraform", var.ark_schedules_extra_tags] } + diff --git a/caas/kubernetes/ark/outputs.tf b/caas/kubernetes/ark/outputs.tf index 5ff741d..1c588cd 100644 --- a/caas/kubernetes/ark/outputs.tf +++ b/caas/kubernetes/ark/outputs.tf @@ -1,4 +1,5 @@ output "ark_schedules_monitor_id" { description = "id for monitor ark_schedules_monitor" - value = "${datadog_monitor.ark_schedules_monitor.*.id}" + value = datadog_monitor.ark_schedules_monitor.*.id } + diff --git a/caas/kubernetes/ark/versions.tf b/caas/kubernetes/ark/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/caas/kubernetes/ark/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/caas/kubernetes/cluster/inputs.tf b/caas/kubernetes/cluster/inputs.tf index 8f7cdb7..519f563 100644 --- a/caas/kubernetes/cluster/inputs.tf +++ b/caas/kubernetes/cluster/inputs.tf @@ -42,24 +42,25 @@ variable "prefix_slug" { variable "apiserver_enabled" { description = "Flag to enable API server monitor" - type = "string" + type = string default = "true" } variable "apiserver_extra_tags" { description = "Extra tags for API server monitor" - type = "list" + type = list(string) default = [] } variable "apiserver_message" { description = "Custom message for API server monitor" - type = "string" + type = string default = "" } variable "apiserver_threshold_warning" { description = "API server monitor (warning threshold)" - type = "string" + type = string default = 3 } + diff --git a/caas/kubernetes/cluster/modules.tf b/caas/kubernetes/cluster/modules.tf index ad6b115..a57cf43 100644 --- a/caas/kubernetes/cluster/modules.tf +++ b/caas/kubernetes/cluster/modules.tf @@ -1,9 +1,10 @@ module "filter-tags" { source = "../../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "kubernetes" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded } + diff --git a/caas/kubernetes/cluster/monitors-k8s-cluster.tf b/caas/kubernetes/cluster/monitors-k8s-cluster.tf index ea97fc5..8a1e0a1 100644 --- a/caas/kubernetes/cluster/monitors-k8s-cluster.tf +++ b/caas/kubernetes/cluster/monitors-k8s-cluster.tf @@ -1,27 +1,28 @@ resource "datadog_monitor" "apiserver" { - count = "${var.apiserver_enabled == "true" ? 1 : 0}" + count = var.apiserver_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Kubernetes API server does not respond" - message = "${coalesce(var.apiserver_message, var.message)}" + message = coalesce(var.apiserver_message, var.message) type = "service check" query = < ${var.ingress_5xx_threshold_critical} - EOQ +EOQ type = "query alert" - thresholds { - warning = "${var.ingress_5xx_threshold_warning}" - critical = "${var.ingress_5xx_threshold_critical}" + thresholds = { + warning = var.ingress_5xx_threshold_warning + critical = var.ingress_5xx_threshold_critical } - notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" - renotify_interval = 0 - notify_audit = false - timeout_h = 0 - include_tags = true - locked = false + notify_no_data = false + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay + renotify_interval = 0 + notify_audit = false + timeout_h = 0 + include_tags = true + locked = false require_full_window = true - tags = ["env:${var.environment}", "type:caas", "provider:prometheus", "resource:nginx-ingress-controller", "team:claranet", "created-by:terraform", "${var.ingress_5xx_extra_tags}"] + tags = ["env:${var.environment}", "type:caas", "provider:prometheus", "resource:nginx-ingress-controller", "team:claranet", "created-by:terraform", var.ingress_5xx_extra_tags] } resource "datadog_monitor" "nginx_ingress_too_many_4xx" { - count = "${var.ingress_4xx_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Nginx Ingress 4xx errors {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.ingress_4xx_message, var.message)}" + count = var.ingress_4xx_enabled == "true" ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Nginx Ingress 4xx errors {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" + message = coalesce(var.ingress_4xx_message, var.message) query = < ${var.ingress_4xx_threshold_critical} - EOQ +EOQ - type = "query alert" +type = "query alert" - thresholds { - warning = "${var.ingress_4xx_threshold_warning}" - critical = "${var.ingress_4xx_threshold_critical}" - } - - notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" - renotify_interval = 0 - notify_audit = false - timeout_h = 0 - include_tags = true - locked = false - require_full_window = true - - tags = ["env:${var.environment}", "type:caas", "provider:prometheus", "resource:nginx-ingress-controller", "team:claranet", "created-by:terraform", "${var.ingress_4xx_extra_tags}"] +thresholds = { +warning = var.ingress_4xx_threshold_warning +critical = var.ingress_4xx_threshold_critical } + +notify_no_data = false +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay +renotify_interval = 0 +notify_audit = false +timeout_h = 0 +include_tags = true +locked = false +require_full_window = true + +tags = ["env:${var.environment}", "type:caas", "provider:prometheus", "resource:nginx-ingress-controller", "team:claranet", "created-by:terraform", var.ingress_4xx_extra_tags] +} + diff --git a/caas/kubernetes/ingress/vts/outputs.tf b/caas/kubernetes/ingress/vts/outputs.tf index 28582f8..9c7e495 100644 --- a/caas/kubernetes/ingress/vts/outputs.tf +++ b/caas/kubernetes/ingress/vts/outputs.tf @@ -1,9 +1,10 @@ output "nginx_ingress_too_many_5xx_id" { description = "id for monitor nginx_ingress_too_many_5xx" - value = "${datadog_monitor.nginx_ingress_too_many_5xx.*.id}" + value = datadog_monitor.nginx_ingress_too_many_5xx.*.id } output "nginx_ingress_too_many_4xx_id" { description = "id for monitor nginx_ingress_too_many_4xx" - value = "${datadog_monitor.nginx_ingress_too_many_4xx.*.id}" + value = datadog_monitor.nginx_ingress_too_many_4xx.*.id } + diff --git a/caas/kubernetes/ingress/vts/versions.tf b/caas/kubernetes/ingress/vts/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/caas/kubernetes/ingress/vts/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/caas/kubernetes/node/inputs.tf b/caas/kubernetes/node/inputs.tf index 02f8148..967b8d9 100644 --- a/caas/kubernetes/node/inputs.tf +++ b/caas/kubernetes/node/inputs.tf @@ -42,175 +42,175 @@ variable "prefix_slug" { variable "disk_pressure_enabled" { description = "Flag to enable Disk pressure monitor" - type = "string" + type = string default = "true" } variable "disk_pressure_extra_tags" { description = "Extra tags for Disk pressure monitor" - type = "list" + type = list(string) default = [] } variable "disk_pressure_message" { description = "Custom message for Disk pressure monitor" - type = "string" + type = string default = "" } variable "disk_pressure_threshold_warning" { description = "Disk pressure monitor (warning threshold)" - type = "string" + type = string default = 3 } variable "disk_out_enabled" { description = "Flag to enable Out of disk monitor" - type = "string" + type = string default = "true" } variable "disk_out_extra_tags" { description = "Extra tags for Out of disk monitor" - type = "list" + type = list(string) default = [] } variable "disk_out_message" { description = "Custom message for Out of disk monitor" - type = "string" + type = string default = "" } variable "disk_out_threshold_warning" { description = "Out of disk monitor (warning threshold)" - type = "string" + type = string default = 3 } variable "memory_pressure_enabled" { description = "Flag to enable Memory pressure monitor" - type = "string" + type = string default = "true" } variable "memory_pressure_extra_tags" { description = "Extra tags for Memory pressure monitor" - type = "list" + type = list(string) default = [] } variable "memory_pressure_message" { description = "Custom message for Memory pressure monitor" - type = "string" + type = string default = "" } variable "memory_pressure_threshold_warning" { description = "Memory pressure monitor (warning threshold)" - type = "string" + type = string default = 3 } variable "ready_enabled" { description = "Flag to enable Node ready monitor" - type = "string" + type = string default = "true" } variable "ready_extra_tags" { description = "Extra tags for Node ready monitor" - type = "list" + type = list(string) default = [] } variable "ready_message" { description = "Custom message for Node ready monitor" - type = "string" + type = string default = "" } variable "ready_threshold_warning" { description = "Node ready monitor (warning threshold)" - type = "string" + type = string default = 3 } variable "kubelet_ping_enabled" { description = "Flag to enable Kubelet ping monitor" - type = "string" + type = string default = "true" } variable "kubelet_ping_extra_tags" { description = "Extra tags for Kubelet ping monitor" - type = "list" + type = list(string) default = [] } variable "kubelet_ping_message" { description = "Custom message for Kubelet ping monitor" - type = "string" + type = string default = "" } variable "kubelet_ping_threshold_warning" { description = "Kubelet ping monitor (warning threshold)" - type = "string" + type = string default = 3 } variable "kubelet_syncloop_enabled" { description = "Flag to enable Kubelet sync loop monitor" - type = "string" + type = string default = "true" } variable "kubelet_syncloop_extra_tags" { description = "Extra tags for Kubelet sync loop monitor" - type = "list" + type = list(string) default = [] } variable "kubelet_syncloop_message" { description = "Custom message for Kubelet sync loop monitor" - type = "string" + type = string default = "" } variable "kubelet_syncloop_threshold_warning" { description = "Kubelet sync loop monitor (warning threshold)" - type = "string" + type = string default = 3 } variable "unregister_net_device_enabled" { description = "Flag to enable Unregister net device monitor" - type = "string" + type = string default = "true" } variable "unregister_net_device_extra_tags" { description = "Extra tags for Unregister net device monitor" - type = "list" + type = list(string) default = [] } variable "unregister_net_device_message" { description = "Custom message for Unregister net device monitor" - type = "string" + type = string default = "" } variable "unregister_net_device_time_aggregator" { description = "Monitor aggregator for Unregister net device [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "unregister_net_device_timeframe" { description = "Monitor timeframe for Unregister net device [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "15m" } @@ -221,61 +221,61 @@ variable "unregister_net_device_threshold_critical" { variable "node_unschedulable_enabled" { description = "Flag to enable node unschedulable monitor" - type = "string" + type = string default = "true" } variable "node_unschedulable_extra_tags" { description = "Extra tags for node unschedulable monitor" - type = "list" + type = list(string) default = [] } variable "node_unschedulable_message" { description = "Custom message for node unschedulable monitor" - type = "string" + type = string default = "" } variable "node_unschedulable_time_aggregator" { description = "Monitor aggregator for node unschedulable [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "node_unschedulable_timeframe" { description = "Monitor timeframe for node unschedulable [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_1h" } variable "volume_space_enabled" { description = "Flag to enable Volume space monitor" - type = "string" + type = string default = "true" } variable "volume_space_extra_tags" { description = "Extra tags for Volume space monitor" - type = "list" + type = list(string) default = [] } variable "volume_space_message" { description = "Custom message for Volume space monitor" - type = "string" + type = string default = "" } variable "volume_space_time_aggregator" { description = "Monitor aggregator for Volume space [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "volume_space_timeframe" { description = "Monitor timeframe for Volume space [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -291,31 +291,31 @@ variable "volume_space_threshold_warning" { variable "volume_inodes_enabled" { description = "Flag to enable Volume inodes monitor" - type = "string" + type = string default = "true" } variable "volume_inodes_extra_tags" { description = "Extra tags for Volume inodes monitor" - type = "list" + type = list(string) default = [] } variable "volume_inodes_message" { description = "Custom message for Volume inodes monitor" - type = "string" + type = string default = "" } variable "volume_inodes_time_aggregator" { description = "Monitor aggregator for Volume inodes [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "volume_inodes_timeframe" { description = "Monitor timeframe for Volume inodes [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -328,3 +328,4 @@ variable "volume_inodes_threshold_warning" { default = 90 description = "Volume inodes warning threshold" } + diff --git a/caas/kubernetes/node/modules.tf b/caas/kubernetes/node/modules.tf index 0dee522..20f05b0 100644 --- a/caas/kubernetes/node/modules.tf +++ b/caas/kubernetes/node/modules.tf @@ -1,20 +1,21 @@ module "filter-tags" { source = "../../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "kubernetes" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded } module "filter-tags-unschedulable" { source = "../../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "kubernetes" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded extra_tags = ["status:unschedulable"] } + diff --git a/caas/kubernetes/node/monitors-k8s-node.tf b/caas/kubernetes/node/monitors-k8s-node.tf index cca6ed1..23e82cd 100644 --- a/caas/kubernetes/node/monitors-k8s-node.tf +++ b/caas/kubernetes/node/monitors-k8s-node.tf @@ -1,104 +1,104 @@ resource "datadog_monitor" "disk_pressure" { - count = "${var.disk_pressure_enabled == "true" ? 1 : 0}" + count = var.disk_pressure_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Kubernetes Node Disk pressure" - message = "${coalesce(var.disk_pressure_message, var.message)}" + message = coalesce(var.disk_pressure_message, var.message) type = "service check" query = < ${var.unregister_net_device_threshold_critical} - EOQ +EOQ - new_host_delay = "${var.new_host_delay}" +new_host_delay = var.new_host_delay - notify_no_data = false - renotify_interval = 0 - notify_audit = false - timeout_h = 0 - include_tags = true - locked = false +notify_no_data = false +renotify_interval = 0 +notify_audit = false +timeout_h = 0 +include_tags = true +locked = false - tags = ["env:${var.environment}", "type:caas", "provider:kubernetes", "resource:kubernetes-node", "team:claranet", "created-by:terraform", "${var.unregister_net_device_extra_tags}"] +tags = ["env:${var.environment}", "type:caas", "provider:kubernetes", "resource:kubernetes-node", "team:claranet", "created-by:terraform", var.unregister_net_device_extra_tags] } resource "datadog_monitor" "node_unschedulable" { - count = "${var.node_unschedulable_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Kubernetes Node unschedulable" - type = "metric alert" - message = "${coalesce(var.node_unschedulable_message, var.message)}" +count = var.node_unschedulable_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Kubernetes Node unschedulable" +type = "metric alert" +message = coalesce(var.node_unschedulable_message, var.message) - query = < 0 - EOQ +EOQ - thresholds { + thresholds = { critical = 0 } - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay notify_no_data = false renotify_interval = 0 @@ -215,69 +215,70 @@ resource "datadog_monitor" "node_unschedulable" { locked = false require_full_window = true - tags = ["env:${var.environment}", "type:caas", "provider:kubernetes", "resource:kubernetes-node", "team:claranet", "created-by:terraform", "${var.node_unschedulable_extra_tags}"] + tags = ["env:${var.environment}", "type:caas", "provider:kubernetes", "resource:kubernetes-node", "team:claranet", "created-by:terraform", var.node_unschedulable_extra_tags] } resource "datadog_monitor" "volume_space" { - count = "${var.volume_space_enabled == "true" ? 1 : 0}" + count = var.volume_space_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Kubernetes Node volume space usage {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" type = "query alert" - message = "${coalesce(var.volume_space_message, var.message)}" + message = coalesce(var.volume_space_message, var.message) query = < ${var.volume_space_threshold_critical} - EOQ +EOQ - thresholds { - critical = "${var.volume_space_threshold_critical}" - warning = "${var.volume_space_threshold_warning}" + thresholds = { + critical = var.volume_space_threshold_critical + warning = var.volume_space_threshold_warning } - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay - notify_no_data = false - renotify_interval = 0 - notify_audit = false - timeout_h = 0 - include_tags = true - locked = false + notify_no_data = false + renotify_interval = 0 + notify_audit = false + timeout_h = 0 + include_tags = true + locked = false require_full_window = true - tags = ["env:${var.environment}", "type:caas", "provider:kubernetes", "resource:kubernetes-node", "team:claranet", "created-by:terraform", "${var.volume_space_extra_tags}"] + tags = ["env:${var.environment}", "type:caas", "provider:kubernetes", "resource:kubernetes-node", "team:claranet", "created-by:terraform", var.volume_space_extra_tags] } resource "datadog_monitor" "volume_inodes" { - count = "${var.volume_inodes_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Kubernetes Node volume inodes usage {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" + count = var.volume_inodes_enabled == "true" ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Kubernetes Node volume inodes usage {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" type = "query alert" - message = "${coalesce(var.volume_inodes_message, var.message)}" + message = coalesce(var.volume_inodes_message, var.message) query = < ${var.volume_inodes_threshold_critical} - EOQ +EOQ - thresholds { - critical = "${var.volume_inodes_threshold_critical}" - warning = "${var.volume_inodes_threshold_warning}" - } - - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" - - notify_no_data = false - renotify_interval = 0 - notify_audit = false - timeout_h = 0 - include_tags = true - locked = false - require_full_window = true - - tags = ["env:${var.environment}", "type:caas", "provider:kubernetes", "resource:kubernetes-node", "team:claranet", "created-by:terraform", "${var.volume_inodes_extra_tags}"] +thresholds = { +critical = var.volume_inodes_threshold_critical +warning = var.volume_inodes_threshold_warning } + +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay + +notify_no_data = false +renotify_interval = 0 +notify_audit = false +timeout_h = 0 +include_tags = true +locked = false +require_full_window = true + +tags = ["env:${var.environment}", "type:caas", "provider:kubernetes", "resource:kubernetes-node", "team:claranet", "created-by:terraform", var.volume_inodes_extra_tags] +} + diff --git a/caas/kubernetes/node/outputs.tf b/caas/kubernetes/node/outputs.tf index b88a1d3..af39519 100644 --- a/caas/kubernetes/node/outputs.tf +++ b/caas/kubernetes/node/outputs.tf @@ -1,49 +1,50 @@ output "disk_pressure_id" { description = "id for monitor disk_pressure" - value = "${datadog_monitor.disk_pressure.*.id}" + value = datadog_monitor.disk_pressure.*.id } output "disk_out_id" { description = "id for monitor disk_out" - value = "${datadog_monitor.disk_out.*.id}" + value = datadog_monitor.disk_out.*.id } output "memory_pressure_id" { description = "id for monitor memory_pressure" - value = "${datadog_monitor.memory_pressure.*.id}" + value = datadog_monitor.memory_pressure.*.id } output "ready_id" { description = "id for monitor ready" - value = "${datadog_monitor.ready.*.id}" + value = datadog_monitor.ready.*.id } output "kubelet_ping_id" { description = "id for monitor kubelet_ping" - value = "${datadog_monitor.kubelet_ping.*.id}" + value = datadog_monitor.kubelet_ping.*.id } output "kubelet_syncloop_id" { description = "id for monitor kubelet_syncloop" - value = "${datadog_monitor.kubelet_syncloop.*.id}" + value = datadog_monitor.kubelet_syncloop.*.id } output "unregister_net_device_id" { description = "id for monitor unregister_net_device" - value = "${datadog_monitor.unregister_net_device.*.id}" + value = datadog_monitor.unregister_net_device.*.id } output "node_unschedulable_id" { description = "id for monitor node_unschedulable" - value = "${datadog_monitor.node_unschedulable.*.id}" + value = datadog_monitor.node_unschedulable.*.id } output "volume_space_id" { description = "id for monitor volume_space" - value = "${datadog_monitor.volume_space.*.id}" + value = datadog_monitor.volume_space.*.id } output "volume_inodes_id" { description = "id for monitor volume_inodes" - value = "${datadog_monitor.volume_inodes.*.id}" + value = datadog_monitor.volume_inodes.*.id } + diff --git a/caas/kubernetes/node/versions.tf b/caas/kubernetes/node/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/caas/kubernetes/node/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/caas/kubernetes/pod/inputs.tf b/caas/kubernetes/pod/inputs.tf index 69b56af..73f74da 100644 --- a/caas/kubernetes/pod/inputs.tf +++ b/caas/kubernetes/pod/inputs.tf @@ -42,61 +42,61 @@ variable "prefix_slug" { variable "pod_phase_status_enabled" { description = "Flag to enable Pod phase status monitor" - type = "string" + type = string default = "true" } variable "pod_phase_status_extra_tags" { description = "Extra tags for Pod phase status monitor" - type = "list" + type = list(string) default = [] } variable "pod_phase_status_message" { description = "Custom message for Pod phase status monitor" - type = "string" + type = string default = "" } variable "pod_phase_status_time_aggregator" { description = "Monitor aggregator for Pod phase status [available values: min, max or avg]" - type = "string" + type = string default = "max" } variable "pod_phase_status_timeframe" { description = "Monitor timeframe for Pod phase status [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } variable "error_enabled" { description = "Flag to enable Pod errors monitor" - type = "string" + type = string default = "true" } variable "error_extra_tags" { description = "Extra tags for Pod errors monitor" - type = "list" + type = list(string) default = [] } variable "error_message" { description = "Custom message for Pod errors monitor" - type = "string" + type = string default = "" } variable "error_time_aggregator" { description = "Monitor aggregator for Pod errors [available values: min, max or avg]" - type = "string" + type = string default = "sum" } variable "error_timeframe" { description = "Monitor timeframe for Pod errors [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_15m" } @@ -109,3 +109,4 @@ variable "error_threshold_warning" { default = 0 description = "error warning threshold" } + diff --git a/caas/kubernetes/pod/modules.tf b/caas/kubernetes/pod/modules.tf index 07c1c59..eb818f5 100644 --- a/caas/kubernetes/pod/modules.tf +++ b/caas/kubernetes/pod/modules.tf @@ -1,31 +1,32 @@ module "filter-tags" { source = "../../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "kubernetes" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded } module "filter-tags-phase" { source = "../../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "kubernetes" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded extra_tags_excluded = ["phase:pending,phase:running,phase:succeeded,phase:unknown"] } module "filter-tags-nocontainercreating" { source = "../../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "kubernetes" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded extra_tags_excluded = ["reason:containercreating"] } + diff --git a/caas/kubernetes/pod/monitors-k8s-pod.tf b/caas/kubernetes/pod/monitors-k8s-pod.tf index 2ca4830..d98d036 100644 --- a/caas/kubernetes/pod/monitors-k8s-pod.tf +++ b/caas/kubernetes/pod/monitors-k8s-pod.tf @@ -1,59 +1,60 @@ resource "datadog_monitor" "pod_phase_status" { - count = "${var.pod_phase_status_enabled == "true" ? 1 : 0}" + count = var.pod_phase_status_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Kubernetes Pod phase status failed" type = "metric alert" - message = "${coalesce(var.pod_phase_status_message, var.message)}" + message = coalesce(var.pod_phase_status_message, var.message) query = < 0 - EOQ +EOQ - thresholds { + thresholds = { critical = 0 } - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay - notify_no_data = false - renotify_interval = 0 - notify_audit = false - timeout_h = 0 - include_tags = true - locked = false + notify_no_data = false + renotify_interval = 0 + notify_audit = false + timeout_h = 0 + include_tags = true + locked = false require_full_window = true - tags = ["env:${var.environment}", "type:caas", "provider:kubernetes", "resource:kubernetes-pod", "team:claranet", "created-by:terraform", "${var.pod_phase_status_extra_tags}"] + tags = ["env:${var.environment}", "type:caas", "provider:kubernetes", "resource:kubernetes-pod", "team:claranet", "created-by:terraform", var.pod_phase_status_extra_tags] } resource "datadog_monitor" "error" { - count = "${var.error_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Kubernetes Pod waiting errors" + count = var.error_enabled == "true" ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Kubernetes Pod waiting errors" type = "query alert" - message = "${coalesce(var.error_message, var.message)}" + message = coalesce(var.error_message, var.message) query = < ${var.error_threshold_critical} - EOQ +EOQ - thresholds { - critical = "${var.error_threshold_critical}" - warning = "${var.error_threshold_warning}" - } - - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" - - notify_no_data = false - renotify_interval = 0 - notify_audit = false - timeout_h = 0 - include_tags = true - locked = false - require_full_window = true - - tags = ["env:${var.environment}", "type:caas", "provider:kubernetes", "resource:kubernetes-pod", "team:claranet", "created-by:terraform", "${var.error_extra_tags}"] +thresholds = { +critical = var.error_threshold_critical +warning = var.error_threshold_warning } + +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay + +notify_no_data = false +renotify_interval = 0 +notify_audit = false +timeout_h = 0 +include_tags = true +locked = false +require_full_window = true + +tags = ["env:${var.environment}", "type:caas", "provider:kubernetes", "resource:kubernetes-pod", "team:claranet", "created-by:terraform", var.error_extra_tags] +} + diff --git a/caas/kubernetes/pod/outputs.tf b/caas/kubernetes/pod/outputs.tf index 2aceb97..70cf2f9 100644 --- a/caas/kubernetes/pod/outputs.tf +++ b/caas/kubernetes/pod/outputs.tf @@ -1,9 +1,10 @@ output "pod_phase_status_id" { description = "id for monitor pod_phase_status" - value = "${datadog_monitor.pod_phase_status.*.id}" + value = datadog_monitor.pod_phase_status.*.id } output "error_id" { description = "id for monitor error" - value = "${datadog_monitor.error.*.id}" + value = datadog_monitor.error.*.id } + diff --git a/caas/kubernetes/pod/versions.tf b/caas/kubernetes/pod/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/caas/kubernetes/pod/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/caas/kubernetes/workload/inputs.tf b/caas/kubernetes/workload/inputs.tf index 25d2a7e..c1d4598 100644 --- a/caas/kubernetes/workload/inputs.tf +++ b/caas/kubernetes/workload/inputs.tf @@ -42,79 +42,79 @@ variable "prefix_slug" { variable "job_enabled" { description = "Flag to enable Job monitor" - type = "string" + type = string default = "true" } variable "job_extra_tags" { description = "Extra tags for Job monitor" - type = "list" + type = list(string) default = [] } variable "job_message" { description = "Custom message for Job monitor" - type = "string" + type = string default = "" } variable "job_threshold_warning" { description = "Job monitor (warning threshold)" - type = "string" + type = string default = 3 } variable "cronjob_enabled" { description = "Flag to enable Cronjob monitor" - type = "string" + type = string default = "true" } variable "cronjob_extra_tags" { description = "Extra tags for Cronjob monitor" - type = "list" + type = list(string) default = [] } variable "cronjob_message" { description = "Custom message for Cronjob monitor" - type = "string" + type = string default = "" } variable "cronjob_threshold_warning" { description = "Cronjob monitor (warning threshold)" - type = "string" + type = string default = 3 } variable "replica_available_enabled" { description = "Flag to enable Available replica monitor" - type = "string" + type = string default = "true" } variable "replica_available_extra_tags" { description = "Extra tags for Available replicamonitor" - type = "list" + type = list(string) default = [] } variable "replica_available_message" { description = "Custom message for Available replica monitor" - type = "string" + type = string default = "" } variable "replica_available_time_aggregator" { description = "Monitor aggregator for Available replica [available values: min, max or avg]" - type = "string" + type = string default = "max" } variable "replica_available_timeframe" { description = "Monitor timeframe for Available replica [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_15m" } @@ -125,31 +125,31 @@ variable "replica_available_threshold_critical" { variable "replica_ready_enabled" { description = "Flag to enable Ready replica monitor" - type = "string" + type = string default = "true" } variable "replica_ready_extra_tags" { description = "Extra tags for Ready replica monitor" - type = "list" + type = list(string) default = [] } variable "replica_ready_message" { description = "Custom message for Ready replica monitor" - type = "string" + type = string default = "" } variable "replica_ready_time_aggregator" { description = "Monitor aggregator for Ready replica [available values: min, max or avg]" - type = "string" + type = string default = "max" } variable "replica_ready_timeframe" { description = "Monitor timeframe for Ready replica [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -160,31 +160,31 @@ variable "replica_ready_threshold_critical" { variable "replica_current_enabled" { description = "Flag to enable Current replica monitor" - type = "string" + type = string default = "true" } variable "replica_current_extra_tags" { description = "Extra tags for Current replica monitor" - type = "list" + type = list(string) default = [] } variable "replica_current_message" { description = "Custom message for Current replica monitor" - type = "string" + type = string default = "" } variable "replica_current_time_aggregator" { description = "Monitor aggregator for Current replica [available values: min, max or avg]" - type = "string" + type = string default = "max" } variable "replica_current_timeframe" { description = "Monitor timeframe for Current replica [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_15m" } @@ -192,3 +192,4 @@ variable "replica_current_threshold_critical" { default = 1 description = "Current replica critical threshold" } + diff --git a/caas/kubernetes/workload/modules.tf b/caas/kubernetes/workload/modules.tf index ad6b115..a57cf43 100644 --- a/caas/kubernetes/workload/modules.tf +++ b/caas/kubernetes/workload/modules.tf @@ -1,9 +1,10 @@ module "filter-tags" { source = "../../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "kubernetes" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded } + diff --git a/caas/kubernetes/workload/monitors-k8s-workload.tf b/caas/kubernetes/workload/monitors-k8s-workload.tf index bcfdcb6..6cc5561 100644 --- a/caas/kubernetes/workload/monitors-k8s-workload.tf +++ b/caas/kubernetes/workload/monitors-k8s-workload.tf @@ -1,109 +1,109 @@ resource "datadog_monitor" "job" { - count = "${var.job_enabled == "true" ? 1 : 0}" + count = var.job_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Kubernetes job failed" - message = "${coalesce(var.job_message, var.message)}" + message = coalesce(var.job_message, var.message) type = "service check" query = < ${var.latency_threshold_critical} - EOQ +EOQ - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" +thresholds = { +critical = var.latency_threshold_critical +warning = var.latency_threshold_warning +} - thresholds { - critical = "${var.latency_threshold_critical}" - warning = "${var.latency_threshold_warning}" - } +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay +notify_no_data = false +renotify_interval = 0 +require_full_window = false +timeout_h = 0 +include_tags = true - notify_no_data = false - renotify_interval = 0 - require_full_window = false - timeout_h = 0 - include_tags = true - - tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:alb", "team:claranet", "created-by:terraform", "${var.latency_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:alb", "team:claranet", "created-by:terraform", var.latency_extra_tags] } resource "datadog_monitor" "ALB_httpcode_5xx" { - count = "${var.httpcode_alb_5xx_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] ALB HTTP code 5xx {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +count = var.httpcode_alb_5xx_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] ALB HTTP code 5xx {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +message = coalesce(var.httpcode_alb_5xx_message, var.message) type = "query alert" - message = "${coalesce(var.httpcode_alb_5xx_message, var.message)}" - query = < ${var.httpcode_alb_5xx_threshold_critical} - EOQ +EOQ - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" +thresholds = { +critical = var.httpcode_alb_5xx_threshold_critical +warning = var.httpcode_alb_5xx_threshold_warning +} - thresholds { - critical = "${var.httpcode_alb_5xx_threshold_critical}" - warning = "${var.httpcode_alb_5xx_threshold_warning}" - } +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay +notify_no_data = false +renotify_interval = 0 +require_full_window = false +timeout_h = 0 +include_tags = true - notify_no_data = false - renotify_interval = 0 - require_full_window = false - timeout_h = 0 - include_tags = true - - tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:alb", "team:claranet", "created-by:terraform", "${var.httpcode_alb_5xx_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:alb", "team:claranet", "created-by:terraform", var.httpcode_alb_5xx_extra_tags] } resource "datadog_monitor" "ALB_httpcode_4xx" { - count = "${var.httpcode_alb_4xx_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] ALB HTTP code 4xx {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +count = var.httpcode_alb_4xx_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] ALB HTTP code 4xx {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +message = coalesce(var.httpcode_alb_4xx_message, var.message) type = "query alert" - message = "${coalesce(var.httpcode_alb_4xx_message, var.message)}" - query = < ${var.httpcode_alb_4xx_threshold_critical} - EOQ +EOQ - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" - - thresholds { - critical = "${var.httpcode_alb_4xx_threshold_critical}" - warning = "${var.httpcode_alb_4xx_threshold_warning}" + thresholds = { + critical = var.httpcode_alb_4xx_threshold_critical + warning = var.httpcode_alb_4xx_threshold_warning } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay notify_no_data = false renotify_interval = 0 require_full_window = false timeout_h = 0 include_tags = true - tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:alb", "team:claranet", "created-by:terraform", "${var.httpcode_alb_4xx_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:alb", "team:claranet", "created-by:terraform", var.httpcode_alb_4xx_extra_tags] } resource "datadog_monitor" "ALB_httpcode_target_5xx" { - count = "${var.httpcode_target_5xx_enabled == "true" ? 1 : 0}" + count = var.httpcode_target_5xx_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] ALB target HTTP code 5xx {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" + message = coalesce(var.httpcode_target_5xx_message, var.message) type = "query alert" - message = "${coalesce(var.httpcode_target_5xx_message, var.message)}" query = < ${var.httpcode_target_5xx_threshold_critical} - EOQ +EOQ - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" - - thresholds { - critical = "${var.httpcode_target_5xx_threshold_critical}" - warning = "${var.httpcode_target_5xx_threshold_warning}" + thresholds = { + critical = var.httpcode_target_5xx_threshold_critical + warning = var.httpcode_target_5xx_threshold_warning } - notify_no_data = false - renotify_interval = 0 + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay + notify_no_data = false + renotify_interval = 0 require_full_window = false - timeout_h = 0 - include_tags = true - - tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:alb", "team:claranet", "created-by:terraform", "${var.httpcode_target_5xx_extra_tags}"] + timeout_h = 0 + include_tags = true + tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:alb", "team:claranet", "created-by:terraform", var.httpcode_target_5xx_extra_tags] } resource "datadog_monitor" "ALB_httpcode_target_4xx" { - count = "${var.httpcode_target_4xx_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] ALB target HTTP code 4xx {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" + count = var.httpcode_target_4xx_enabled == "true" ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] ALB target HTTP code 4xx {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" + message = coalesce(var.httpcode_target_4xx_message, var.message) type = "query alert" - message = "${coalesce(var.httpcode_target_4xx_message, var.message)}" query = < ${var.httpcode_target_4xx_threshold_critical} - EOQ +EOQ - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" - - thresholds { - critical = "${var.httpcode_target_4xx_threshold_critical}" - warning = "${var.httpcode_target_4xx_threshold_warning}" - } - - notify_no_data = false - renotify_interval = 0 - require_full_window = false - timeout_h = 0 - include_tags = true - - tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:alb", "team:claranet", "created-by:terraform", "${var.httpcode_target_4xx_extra_tags}"] +thresholds = { +critical = var.httpcode_target_4xx_threshold_critical +warning = var.httpcode_target_4xx_threshold_warning } + +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay +notify_no_data = false +renotify_interval = 0 +require_full_window = false +timeout_h = 0 +include_tags = true + +tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:alb", "team:claranet", "created-by:terraform", var.httpcode_target_4xx_extra_tags] +} + diff --git a/cloud/aws/alb/outputs.tf b/cloud/aws/alb/outputs.tf index 9a88a81..dee5705 100644 --- a/cloud/aws/alb/outputs.tf +++ b/cloud/aws/alb/outputs.tf @@ -1,29 +1,30 @@ output "ALB_no_healthy_instances_id" { description = "id for monitor ALB_no_healthy_instances" - value = "${datadog_monitor.ALB_no_healthy_instances.*.id}" + value = datadog_monitor.ALB_no_healthy_instances.*.id } output "ALB_latency_id" { description = "id for monitor ALB_latency" - value = "${datadog_monitor.ALB_latency.*.id}" + value = datadog_monitor.ALB_latency.*.id } output "ALB_httpcode_5xx_id" { description = "id for monitor ALB_httpcode_5xx" - value = "${datadog_monitor.ALB_httpcode_5xx.*.id}" + value = datadog_monitor.ALB_httpcode_5xx.*.id } output "ALB_httpcode_4xx_id" { description = "id for monitor ALB_httpcode_4xx" - value = "${datadog_monitor.ALB_httpcode_4xx.*.id}" + value = datadog_monitor.ALB_httpcode_4xx.*.id } output "ALB_httpcode_target_5xx_id" { description = "id for monitor ALB_httpcode_target_5xx" - value = "${datadog_monitor.ALB_httpcode_target_5xx.*.id}" + value = datadog_monitor.ALB_httpcode_target_5xx.*.id } output "ALB_httpcode_target_4xx_id" { description = "id for monitor ALB_httpcode_target_4xx" - value = "${datadog_monitor.ALB_httpcode_target_4xx.*.id}" + value = datadog_monitor.ALB_httpcode_target_4xx.*.id } + diff --git a/cloud/aws/alb/versions.tf b/cloud/aws/alb/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/cloud/aws/alb/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/cloud/aws/apigateway/inputs.tf b/cloud/aws/apigateway/inputs.tf index b572377..9158d78 100644 --- a/cloud/aws/apigateway/inputs.tf +++ b/cloud/aws/apigateway/inputs.tf @@ -1,6 +1,6 @@ variable "environment" { description = "Environment" - type = "string" + type = string } variable "filter_tags" { @@ -33,31 +33,31 @@ variable "prefix_slug" { variable "latency_enabled" { description = "Flag to enable API Gateway latency monitor" - type = "string" + type = string default = "true" } variable "latency_extra_tags" { description = "Extra tags for API Gateway latency monitor" - type = "list" + type = list(string) default = [] } variable "latency_message" { description = "Custom message for API Gateway latency monitor" - type = "string" + type = string default = "" } variable "latency_time_aggregator" { description = "Monitor aggregator for API Gateway latency [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "latency_timeframe" { description = "Monitor timeframe for API latency [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -77,31 +77,31 @@ variable "latency_threshold_warning" { variable "http_5xx_requests_enabled" { description = "Flag to enable API Gateway HTTP 5xx requests monitor" - type = "string" + type = string default = "true" } variable "http_5xx_requests_extra_tags" { description = "Extra tags for API Gateway HTTP 5xx requests monitor" - type = "list" + type = list(string) default = [] } variable "http_5xx_requests_message" { description = "Custom message for API Gateway HTTP 5xx requests monitor" - type = "string" + type = string default = "" } variable "http_5xx_requests_time_aggregator" { description = "Monitor aggregator for API HTTP 5xx requests [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "http_5xx_requests_timeframe" { description = "Monitor timeframe for API HTTP 5xx requests [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -121,31 +121,31 @@ variable "http_5xx_requests_threshold_warning" { variable "http_4xx_requests_enabled" { description = "Flag to enable API Gateway HTTP 4xx requests monitor" - type = "string" + type = string default = "true" } variable "http_4xx_requests_extra_tags" { description = "Extra tags for API Gateway HTTP 4xx requests monitor" - type = "list" + type = list(string) default = [] } variable "http_4xx_requests_message" { description = "Custom message for API Gateway HTTP 4xx requests monitor" - type = "string" + type = string default = "" } variable "http_4xx_requests_time_aggregator" { description = "Monitor aggregator for API HTTP 4xx requests [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "http_4xx_requests_timeframe" { description = "Monitor timeframe for API HTTP 4xx requests [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -163,3 +163,4 @@ variable "artificial_requests_count" { default = 5 description = "Number of false requests used to mitigate false positive in case of low trafic" } + diff --git a/cloud/aws/apigateway/monitors-api.tf b/cloud/aws/apigateway/monitors-api.tf index 8352d10..948afce 100644 --- a/cloud/aws/apigateway/monitors-api.tf +++ b/cloud/aws/apigateway/monitors-api.tf @@ -1,91 +1,92 @@ # Monitoring Api Gateway latency resource "datadog_monitor" "API_Gateway_latency" { - count = "${var.latency_enabled == "true" ? 1 : 0}" + count = var.latency_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] API Gateway latency {{#is_alert}}{{{comparator}}} {{threshold}}ms ({{value}}ms){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}ms ({{value}}ms){{/is_warning}}" type = "query alert" - message = "${coalesce(var.latency_message, var.message)}" + message = coalesce(var.latency_message, var.message) query = < ${var.latency_threshold_critical} - EOQ +EOQ - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay - thresholds { - warning = "${var.latency_threshold_warning}" - critical = "${var.latency_threshold_critical}" + thresholds = { + warning = var.latency_threshold_warning + critical = var.latency_threshold_critical } - notify_no_data = false # Will NOT notify when no data is received - renotify_interval = 0 + notify_no_data = false + renotify_interval = 0 require_full_window = false - timeout_h = 0 - include_tags = true + timeout_h = 0 + include_tags = true - tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:apigateway", "team:claranet", "created-by:terraform", "${var.latency_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:apigateway", "team:claranet", "created-by:terraform", var.latency_extra_tags] } # Monitoring API Gateway 5xx errors percent resource "datadog_monitor" "API_http_5xx_errors_count" { - count = "${var.http_5xx_requests_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] API Gateway HTTP 5xx errors {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" + count = var.http_5xx_requests_enabled == "true" ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] API Gateway HTTP 5xx errors {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" type = "query alert" - message = "${coalesce(var.http_5xx_requests_message, var.message)}" + message = coalesce(var.http_5xx_requests_message, var.message) query = < ${var.http_5xx_requests_threshold_critical} - EOQ +EOQ - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay - thresholds { - warning = "${var.http_5xx_requests_threshold_warning}" - critical = "${var.http_5xx_requests_threshold_critical}" - } +thresholds = { +warning = var.http_5xx_requests_threshold_warning +critical = var.http_5xx_requests_threshold_critical +} - notify_no_data = false # Will NOT notify when no data is received - renotify_interval = 0 - require_full_window = false - timeout_h = 1 - include_tags = true +notify_no_data = false +renotify_interval = 0 +require_full_window = false +timeout_h = 1 +include_tags = true - tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:apigateway", "team:claranet", "created-by:terraform", "${var.http_5xx_requests_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:apigateway", "team:claranet", "created-by:terraform", var.http_5xx_requests_extra_tags] } # Monitoring API Gateway 4xx errors percent resource "datadog_monitor" "API_http_4xx_errors_count" { - count = "${var.http_4xx_requests_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] API Gateway HTTP 4xx errors {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +count = var.http_4xx_requests_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] API Gateway HTTP 4xx errors {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" type = "query alert" - message = "${coalesce(var.http_4xx_requests_message, var.message)}" +message = coalesce(var.http_4xx_requests_message, var.message) - query = < ${var.http_4xx_requests_threshold_critical} - EOQ +EOQ - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay - thresholds { - warning = "${var.http_4xx_requests_threshold_warning}" - critical = "${var.http_4xx_requests_threshold_critical}" - } - - notify_no_data = false # Will NOT notify when no data is received - renotify_interval = 0 - require_full_window = false - timeout_h = 1 - include_tags = true - - tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:apigateway", "team:claranet", "created-by:terraform", "${var.http_4xx_requests_extra_tags}"] +thresholds = { +warning = var.http_4xx_requests_threshold_warning +critical = var.http_4xx_requests_threshold_critical } + +notify_no_data = false +renotify_interval = 0 +require_full_window = false +timeout_h = 1 +include_tags = true + +tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:apigateway", "team:claranet", "created-by:terraform", var.http_4xx_requests_extra_tags] +} + diff --git a/cloud/aws/apigateway/outputs.tf b/cloud/aws/apigateway/outputs.tf index cfcce70..3c08888 100644 --- a/cloud/aws/apigateway/outputs.tf +++ b/cloud/aws/apigateway/outputs.tf @@ -1,14 +1,15 @@ output "API_Gateway_latency_id" { description = "id for monitor API_Gateway_latency" - value = "${datadog_monitor.API_Gateway_latency.*.id}" + value = datadog_monitor.API_Gateway_latency.*.id } output "API_http_5xx_errors_count_id" { description = "id for monitor API_http_5xx_errors_count" - value = "${datadog_monitor.API_http_5xx_errors_count.*.id}" + value = datadog_monitor.API_http_5xx_errors_count.*.id } output "API_http_4xx_errors_count_id" { description = "id for monitor API_http_4xx_errors_count" - value = "${datadog_monitor.API_http_4xx_errors_count.*.id}" + value = datadog_monitor.API_http_4xx_errors_count.*.id } + diff --git a/cloud/aws/apigateway/versions.tf b/cloud/aws/apigateway/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/cloud/aws/apigateway/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/cloud/aws/elasticache/common/inputs.tf b/cloud/aws/elasticache/common/inputs.tf index 6641020..6997bcf 100644 --- a/cloud/aws/elasticache/common/inputs.tf +++ b/cloud/aws/elasticache/common/inputs.tf @@ -1,7 +1,7 @@ # Global Terraform variable "environment" { description = "Infrastructure Environment" - type = "string" + type = string } # Global DataDog @@ -43,222 +43,223 @@ variable "filter_tags_custom_excluded" { variable "eviction_enabled" { description = "Flag to enable Elasticache eviction monitor" - type = "string" + type = string default = "true" } variable "eviction_extra_tags" { description = "Extra tags for Elasticache eviction monitor" - type = "list" + type = list(string) default = [] } variable "eviction_message" { description = "Custom message for Elasticache eviction monitor" - type = "string" + type = string default = "" } variable "eviction_timeframe" { description = "Monitor timeframe for Elasticache eviction [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_15m" } variable "eviction_threshold_warning" { description = "Elasticache free memory warning threshold in percentage" - type = "string" + type = string default = 0 } variable "eviction_threshold_critical" { description = "Elasticache free memory critical threshold in percentage" - type = "string" + type = string default = 30 } variable "max_connection_enabled" { description = "Flag to enable Elasticache max connection monitor" - type = "string" + type = string default = "true" } variable "max_connection_extra_tags" { description = "Extra tags for Elasticache max connection monitor" - type = "list" + type = list(string) default = [] } variable "max_connection_message" { description = "Custom message for Elasticache max connection monitor" - type = "string" + type = string default = "" } variable "max_connection_time_aggregator" { description = "Monitor aggregator for Elasticache max connection [available values: min, max or avg]" - type = "string" + type = string default = "max" } variable "max_connection_timeframe" { description = "Monitor timeframe for Elasticache max connection [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } variable "no_connection_enabled" { description = "Flag to enable Elasticache no connection monitor" - type = "string" + type = string default = "true" } variable "no_connection_extra_tags" { description = "Extra tags for Elasticache no connection monitor" - type = "list" + type = list(string) default = [] } variable "no_connection_message" { description = "Custom message for Elasticache no connection monitor" - type = "string" + type = string default = "" } variable "no_connection_time_aggregator" { description = "Monitor aggregator for Elasticache no connection [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "no_connection_timeframe" { description = "Monitor timeframe for Elasticache no connection [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } variable "swap_enabled" { description = "Flag to enable Elasticache swap monitor" - type = "string" + type = string default = "true" } variable "swap_extra_tags" { description = "Extra tags for Elasticache swap monitor" - type = "list" + type = list(string) default = [] } variable "swap_message" { description = "Custom message for Elasticache swap monitor" - type = "string" + type = string default = "" } variable "swap_time_aggregator" { description = "Monitor aggregator for Elasticache memcached swap [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "swap_timeframe" { description = "Monitor timeframe for Elasticache swap [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } variable "swap_threshold_warning" { description = "Elasticache swap warning threshold in bytes" - type = "string" + type = string default = 0 } variable "swap_threshold_critical" { description = "Elasticache swap critical threshold in bytes" - type = "string" + type = string default = 50000000 } variable "free_memory_enabled" { description = "Flag to enable Elasticache free memory monitor" - type = "string" + type = string default = "true" } variable "free_memory_extra_tags" { description = "Extra tags for Elasticache free memory monitor" - type = "list" + type = list(string) default = [] } variable "free_memory_message" { description = "Custom message for Elasticache free memory monitor" - type = "string" + type = string default = "" } variable "free_memory_condition_timeframe" { description = "Monitor condition timeframe for Elasticache free memory [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_15m" } variable "free_memory_timeframe" { description = "Monitor timeframe for Elasticache free memory [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_15m" } variable "free_memory_threshold_warning" { description = "Elasticache free memory warning threshold in percentage" - type = "string" + type = string default = -50 } variable "free_memory_threshold_critical" { description = "Elasticache free memory critical threshold in percentage" - type = "string" + type = string default = -70 } variable "eviction_growing_enabled" { description = "Flag to enable Elasticache eviction growing monitor" - type = "string" + type = string default = "true" } variable "eviction_growing_extra_tags" { description = "Extra tags for Elasticache eviction growing monitor" - type = "list" + type = list(string) default = [] } variable "eviction_growing_message" { description = "Custom message for Elasticache eviction growing monitor" - type = "string" + type = string default = "" } variable "eviction_growing_condition_timeframe" { description = "Monitor condition timeframe for Elasticache eviction growing [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } variable "eviction_growing_timeframe" { description = "Monitor timeframe for Elasticache eviction growing [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } variable "eviction_growing_threshold_warning" { description = "Elasticache eviction growing warning threshold in percentage" - type = "string" + type = string default = 10 } variable "eviction_growing_threshold_critical" { description = "Elasticache eviction growing critical threshold in percentage" - type = "string" + type = string default = 30 } + diff --git a/cloud/aws/elasticache/common/modules.tf b/cloud/aws/elasticache/common/modules.tf index 081ad25..1b317be 100644 --- a/cloud/aws/elasticache/common/modules.tf +++ b/cloud/aws/elasticache/common/modules.tf @@ -1,9 +1,10 @@ module "filter-tags" { source = "../../../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "aws_elasticache" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded } + diff --git a/cloud/aws/elasticache/common/monitors-elasticache.tf b/cloud/aws/elasticache/common/monitors-elasticache.tf index 64e4ba7..284dc44 100644 --- a/cloud/aws/elasticache/common/monitors-elasticache.tf +++ b/cloud/aws/elasticache/common/monitors-elasticache.tf @@ -1,175 +1,170 @@ resource "datadog_monitor" "elasticache_eviction" { - count = "${var.eviction_enabled == "true" ? 1 : 0}" + count = var.eviction_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticache eviction {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}" - message = "${coalesce(var.eviction_message, var.message)}" - + message = coalesce(var.eviction_message, var.message) type = "query alert" query = < ${var.eviction_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.eviction_threshold_warning}" - critical = "${var.eviction_threshold_critical}" + thresholds = { + warning = var.eviction_threshold_warning + critical = var.eviction_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 + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay + notify_no_data = false + 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:elasticache", "team:claranet", "created-by:terraform", "${var.eviction_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:elasticache", "team:claranet", "created-by:terraform", var.eviction_extra_tags] } resource "datadog_monitor" "elasticache_max_connection" { - count = "${var.max_connection_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticache max connections reached {{#is_alert}}{{{comparator}}} {{threshold}} {{/is_alert}}" - message = "${coalesce(var.max_connection_message, var.message)}" - + count = var.max_connection_enabled == "true" ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticache max connections reached {{#is_alert}}{{{comparator}}} {{threshold}} {{/is_alert}}" + message = coalesce(var.max_connection_message, var.message) type = "query alert" query = <= 65000 - EOQ +EOQ - 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}" +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay +notify_no_data = true +renotify_interval = 0 +notify_audit = false +timeout_h = 0 +include_tags = true +locked = false +require_full_window = false - tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:elasticache", "team:claranet", "created-by:terraform", "${var.max_connection_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:elasticache", "team:claranet", "created-by:terraform", var.max_connection_extra_tags] } resource "datadog_monitor" "elasticache_no_connection" { - count = "${var.no_connection_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticache connections {{#is_alert}}{{{comparator}}} {{threshold}} {{/is_alert}}" - message = "${coalesce(var.no_connection_message, var.message)}" +count = var.no_connection_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticache connections {{#is_alert}}{{{comparator}}} {{threshold}} {{/is_alert}}" +message = coalesce(var.no_connection_message, var.message) +type = "query alert" - type = "query alert" - - query = < ${var.swap_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.swap_threshold_warning}" - critical = "${var.swap_threshold_critical}" + thresholds = { + warning = var.swap_threshold_warning + critical = var.swap_threshold_critical } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay 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:elasticache", "team:claranet", "created-by:terraform", "${var.swap_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:elasticache", "team:claranet", "created-by:terraform", var.swap_extra_tags] } resource "datadog_monitor" "elasticache_free_memory" { - count = "${var.free_memory_enabled == "true" ? 1 : 0}" + count = var.free_memory_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticache free memory {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.free_memory_message, var.message)}" - + message = coalesce(var.free_memory_message, var.message) type = "query alert" query = < ${var.eviction_growing_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.eviction_growing_threshold_warning}" - critical = "${var.eviction_growing_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:elasticache", "team:claranet", "created-by:terraform", "${var.eviction_growing_extra_tags}"] +thresholds = { +warning = var.eviction_growing_threshold_warning +critical = var.eviction_growing_threshold_critical } + +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay +notify_no_data = false +renotify_interval = 0 +notify_audit = false +timeout_h = 0 +include_tags = true +locked = false +require_full_window = false + +tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:elasticache", "team:claranet", "created-by:terraform", var.eviction_growing_extra_tags] +} + diff --git a/cloud/aws/elasticache/common/outputs.tf b/cloud/aws/elasticache/common/outputs.tf index 5268c4d..2dbc16a 100644 --- a/cloud/aws/elasticache/common/outputs.tf +++ b/cloud/aws/elasticache/common/outputs.tf @@ -1,29 +1,30 @@ output "elasticache_eviction_id" { description = "id for monitor elasticache_eviction" - value = "${datadog_monitor.elasticache_eviction.*.id}" + value = datadog_monitor.elasticache_eviction.*.id } output "elasticache_max_connection_id" { description = "id for monitor elasticache_max_connection" - value = "${datadog_monitor.elasticache_max_connection.*.id}" + value = datadog_monitor.elasticache_max_connection.*.id } output "elasticache_no_connection_id" { description = "id for monitor elasticache_no_connection" - value = "${datadog_monitor.elasticache_no_connection.*.id}" + value = datadog_monitor.elasticache_no_connection.*.id } output "elasticache_swap_id" { description = "id for monitor elasticache_swap" - value = "${datadog_monitor.elasticache_swap.*.id}" + value = datadog_monitor.elasticache_swap.*.id } output "elasticache_free_memory_id" { description = "id for monitor elasticache_free_memory" - value = "${datadog_monitor.elasticache_free_memory.*.id}" + value = datadog_monitor.elasticache_free_memory.*.id } output "elasticache_eviction_growing_id" { description = "id for monitor elasticache_eviction_growing" - value = "${datadog_monitor.elasticache_eviction_growing.*.id}" + value = datadog_monitor.elasticache_eviction_growing.*.id } + diff --git a/cloud/aws/elasticache/common/versions.tf b/cloud/aws/elasticache/common/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/cloud/aws/elasticache/common/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/cloud/aws/elasticache/memcached/inputs.tf b/cloud/aws/elasticache/memcached/inputs.tf index b0cca66..25b63a4 100644 --- a/cloud/aws/elasticache/memcached/inputs.tf +++ b/cloud/aws/elasticache/memcached/inputs.tf @@ -1,7 +1,7 @@ # Global Terraform variable "environment" { description = "Infrastructure Environment" - type = "string" + type = string } # Global DataDog @@ -43,84 +43,85 @@ variable "filter_tags_custom_excluded" { variable "get_hits_enabled" { description = "Flag to enable Elasticache memcached get hits monitor" - type = "string" + type = string default = "true" } variable "get_hits_extra_tags" { description = "Extra tags for Elasticache memcached get hits monitor" - type = "list" + type = list(string) default = [] } variable "get_hits_message" { description = "Custom message for Elasticache memcached get hits monitor" - type = "string" + type = string default = "" } variable "get_hits_time_aggregator" { description = "Monitor aggregator for Elasticache memcached get hits [available values: min, max or avg]" - type = "string" + type = string default = "max" } variable "get_hits_timeframe" { description = "Monitor timeframe for Elasticache memcached get hits [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_15m" } variable "get_hits_threshold_warning" { description = "Elasticache memcached get hits warning threshold in percentage" - type = "string" + type = string default = 80 } variable "get_hits_threshold_critical" { description = "Elasticache memcached get hits critical threshold in percentage" - type = "string" + type = string default = 60 } variable "cpu_high_enabled" { description = "Flag to enable Elasticache memcached cpu high monitor" - type = "string" + type = string default = "true" } variable "cpu_high_extra_tags" { description = "Extra tags for Elasticache memcached cpu high monitor" - type = "list" + type = list(string) default = [] } variable "cpu_high_message" { description = "Custom message for Elasticache memcached cpu high monitor" - type = "string" + type = string default = "" } variable "cpu_high_time_aggregator" { description = "Monitor aggregator for Elasticache memcached cpu high [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "cpu_high_timeframe" { description = "Monitor timeframe for Elasticache memcached cpu high [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_15m" } variable "cpu_high_threshold_warning" { description = "Elasticache memcached cpu high warning threshold in percentage" - type = "string" + type = string default = 75 } variable "cpu_high_threshold_critical" { description = "Elasticache memcached cpu high critical threshold in percentage" - type = "string" + type = string default = 90 } + diff --git a/cloud/aws/elasticache/memcached/modules.tf b/cloud/aws/elasticache/memcached/modules.tf index 081ad25..1b317be 100644 --- a/cloud/aws/elasticache/memcached/modules.tf +++ b/cloud/aws/elasticache/memcached/modules.tf @@ -1,9 +1,10 @@ module "filter-tags" { source = "../../../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "aws_elasticache" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded } + diff --git a/cloud/aws/elasticache/memcached/monitors-memcached.tf b/cloud/aws/elasticache/memcached/monitors-memcached.tf index 07839b1..3006253 100644 --- a/cloud/aws/elasticache/memcached/monitors-memcached.tf +++ b/cloud/aws/elasticache/memcached/monitors-memcached.tf @@ -1,7 +1,7 @@ resource "datadog_monitor" "memcached_get_hits" { - count = "${var.get_hits_enabled == "true" ? 1 : 0}" + count = var.get_hits_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticache memcached cache hit ratio {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.get_hits_message, var.message)}" + message = coalesce(var.get_hits_message, var.message) type = "query alert" @@ -11,30 +11,30 @@ resource "datadog_monitor" "memcached_get_hits" { default(avg:aws.elasticache.get_hits${module.filter-tags.query_alert} by {region,cacheclusterid,cachenodeid}.as_rate(), 0) + default(avg:aws.elasticache.get_misses${module.filter-tags.query_alert} by {region,cacheclusterid,cachenodeid}.as_rate(), 0)) ) * 100 < ${var.get_hits_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.get_hits_threshold_warning}" - critical = "${var.get_hits_threshold_critical}" + thresholds = { + warning = var.get_hits_threshold_warning + critical = var.get_hits_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 + 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}" + new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:elasticache-memcached", "team:claranet", "created-by:terraform", "engine:memcached", "${var.get_hits_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:elasticache-memcached", "team:claranet", "created-by:terraform", "engine:memcached", var.get_hits_extra_tags] } resource "datadog_monitor" "memcached_cpu_high" { - count = "${var.cpu_high_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticache memcached CPU {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.cpu_high_message, var.message)}" + count = var.cpu_high_enabled == "true" ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticache memcached CPU {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" + message = coalesce(var.cpu_high_message, var.message) type = "query alert" @@ -42,22 +42,23 @@ resource "datadog_monitor" "memcached_cpu_high" { ${var.cpu_high_time_aggregator}(${var.cpu_high_timeframe}): ( avg:aws.elasticache.cpuutilization${module.filter-tags.query_alert} by {region,cacheclusterid,cachenodeid} ) > ${var.cpu_high_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.cpu_high_threshold_warning}" - critical = "${var.cpu_high_threshold_critical}" - } - - 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:elasticache-memcached", "team:claranet", "created-by:terraform", "engine:memcached", "${var.cpu_high_extra_tags}"] +thresholds = { +warning = var.cpu_high_threshold_warning +critical = var.cpu_high_threshold_critical } + +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:elasticache-memcached", "team:claranet", "created-by:terraform", "engine:memcached", var.cpu_high_extra_tags] +} + diff --git a/cloud/aws/elasticache/memcached/outputs.tf b/cloud/aws/elasticache/memcached/outputs.tf index 7beb0d5..68b8ada 100644 --- a/cloud/aws/elasticache/memcached/outputs.tf +++ b/cloud/aws/elasticache/memcached/outputs.tf @@ -1,9 +1,10 @@ output "memcached_get_hits_id" { description = "id for monitor memcached_get_hits" - value = "${datadog_monitor.memcached_get_hits.*.id}" + value = datadog_monitor.memcached_get_hits.*.id } output "memcached_cpu_high_id" { description = "id for monitor memcached_cpu_high" - value = "${datadog_monitor.memcached_cpu_high.*.id}" + value = datadog_monitor.memcached_cpu_high.*.id } + diff --git a/cloud/aws/elasticache/memcached/versions.tf b/cloud/aws/elasticache/memcached/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/cloud/aws/elasticache/memcached/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/cloud/aws/elasticache/redis/inputs.tf b/cloud/aws/elasticache/redis/inputs.tf index d17347a..ed61e74 100644 --- a/cloud/aws/elasticache/redis/inputs.tf +++ b/cloud/aws/elasticache/redis/inputs.tf @@ -1,7 +1,7 @@ # Global Terraform variable "environment" { description = "Infrastructure Environment" - type = "string" + type = string } # Global DataDog @@ -43,150 +43,151 @@ variable "filter_tags_custom_excluded" { variable "cache_hits_enabled" { description = "Flag to enable Elasticache redis cache hits monitor" - type = "string" + type = string default = "true" } variable "cache_hits_extra_tags" { description = "Extra tags for Elasticache redis cache hits monitor" - type = "list" + type = list(string) default = [] } variable "cache_hits_message" { description = "Custom message for Elasticache redis cache hits monitor" - type = "string" + type = string default = "" } variable "cache_hits_time_aggregator" { description = "Monitor aggregator for Elasticache redis cache hits [available values: min, max or avg]" - type = "string" + type = string default = "max" } variable "cache_hits_timeframe" { description = "Monitor timeframe for Elasticache redis cache hits [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_15m" } variable "cache_hits_threshold_warning" { description = "Elasticache redis cache hits warning threshold in percentage" - type = "string" + type = string default = 80 } variable "cache_hits_threshold_critical" { description = "Elasticache redis cache hits critical threshold in percentage" - type = "string" + type = string default = 60 } variable "cpu_high_enabled" { description = "Flag to enable Elasticache redis cpu high monitor" - type = "string" + type = string default = "true" } variable "cpu_high_extra_tags" { description = "Extra tags for Elasticache redis cpu high monitor" - type = "list" + type = list(string) default = [] } variable "cpu_high_message" { description = "Custom message for Elasticache redis cpu high monitor" - type = "string" + type = string default = "" } variable "cpu_high_time_aggregator" { description = "Monitor aggregator for Elasticache redis cpu high [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "cpu_high_timeframe" { description = "Monitor timeframe for Elasticache redis cpu high [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_15m" } variable "cpu_high_threshold_warning" { description = "Elasticache redis cpu high warning threshold in percentage" - type = "string" + type = string default = 75 } variable "cpu_high_threshold_critical" { description = "Elasticache redis cpu high critical threshold in percentage" - type = "string" + type = string default = 90 } variable "replication_lag_enabled" { description = "Flag to enable Elasticache redis replication lag monitor" - type = "string" + type = string default = "true" } variable "replication_lag_extra_tags" { description = "Extra tags for Elasticache redis replication lag monitor" - type = "list" + type = list(string) default = [] } variable "replication_lag_message" { description = "Custom message for Elasticache redis replication lag monitor" - type = "string" + type = string default = "" } variable "replication_lag_time_aggregator" { description = "Monitor aggregator for Elasticache redis replication lag [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "replication_lag_timeframe" { description = "Monitor timeframe for Elasticache redis replication lag [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_10m" } variable "replication_lag_threshold_warning" { description = "Elasticache redis replication lag warning threshold in seconds" - type = "string" + type = string default = 90 } variable "replication_lag_threshold_critical" { description = "Elasticache redis replication lag critical threshold in seconds" - type = "string" + type = string default = 180 } variable "commands_enabled" { description = "Flag to enable Elasticache redis commands monitor" - type = "string" + type = string default = "true" } variable "commands_extra_tags" { description = "Extra tags for Elasticache redis commands monitor" - type = "list" + type = list(string) default = [] } variable "commands_message" { description = "Custom message for Elasticache redis commands monitor" - type = "string" + type = string default = "" } variable "commands_timeframe" { description = "Monitor timeframe for Elasticache redis commands [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } + diff --git a/cloud/aws/elasticache/redis/modules.tf b/cloud/aws/elasticache/redis/modules.tf index 081ad25..1b317be 100644 --- a/cloud/aws/elasticache/redis/modules.tf +++ b/cloud/aws/elasticache/redis/modules.tf @@ -1,9 +1,10 @@ module "filter-tags" { source = "../../../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "aws_elasticache" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded } + diff --git a/cloud/aws/elasticache/redis/monitors-redis.tf b/cloud/aws/elasticache/redis/monitors-redis.tf index 6489660..479d414 100644 --- a/cloud/aws/elasticache/redis/monitors-redis.tf +++ b/cloud/aws/elasticache/redis/monitors-redis.tf @@ -1,7 +1,7 @@ resource "datadog_monitor" "redis_cache_hits" { - count = "${var.cache_hits_enabled == "true" ? 1 : 0}" + count = var.cache_hits_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticache redis cache hit ratio {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.cache_hits_message, var.message)}" + message = coalesce(var.cache_hits_message, var.message) type = "query alert" @@ -11,30 +11,30 @@ resource "datadog_monitor" "redis_cache_hits" { avg:aws.elasticache.cache_hits${module.filter-tags.query_alert} by {region,cacheclusterid,cachenodeid}.as_rate() + avg:aws.elasticache.cache_misses${module.filter-tags.query_alert} by {region,cacheclusterid,cachenodeid}.as_rate()) * 100, 100) < ${var.cache_hits_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.cache_hits_threshold_warning}" - critical = "${var.cache_hits_threshold_critical}" + thresholds = { + warning = var.cache_hits_threshold_warning + critical = var.cache_hits_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 + 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}" + new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:elasticache-redis", "team:claranet", "created-by:terraform", "engine:redis", "${var.cache_hits_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:elasticache-redis", "team:claranet", "created-by:terraform", "engine:redis", var.cache_hits_extra_tags] } resource "datadog_monitor" "redis_cpu_high" { - count = "${var.cpu_high_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticache redis CPU {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.cpu_high_message, var.message)}" + count = var.cpu_high_enabled == "true" ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticache redis CPU {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" + message = coalesce(var.cpu_high_message, var.message) type = "query alert" @@ -42,75 +42,76 @@ resource "datadog_monitor" "redis_cpu_high" { ${var.cpu_high_time_aggregator}(${var.cpu_high_timeframe}): ( avg:aws.elasticache.engine_cpuutilization${module.filter-tags.query_alert} by {region,cacheclusterid,cachenodeid} ) > ${var.cpu_high_threshold_critical} - EOQ +EOQ - 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}" +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:elasticache-redis", "team:claranet", "created-by:terraform", "engine:redis", "${var.cpu_high_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:elasticache-redis", "team:claranet", "created-by:terraform", "engine:redis", var.cpu_high_extra_tags] } resource "datadog_monitor" "redis_replication_lag" { - count = "${var.replication_lag_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${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)}" +count = var.replication_lag_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${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 = "query alert" - query = < ${var.replication_lag_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.replication_lag_threshold_warning}" - critical = "${var.replication_lag_threshold_critical}" - } +thresholds = { +warning = var.replication_lag_threshold_warning +critical = var.replication_lag_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}" +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:elasticache-redis", "team:claranet", "created-by:terraform", "engine:redis", "${var.replication_lag_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:elasticache-redis", "team:claranet", "created-by:terraform", "engine:redis", var.replication_lag_extra_tags] } resource "datadog_monitor" "redis_commands" { - count = "${var.commands_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticache redis is receiving no commands" - message = "${coalesce(var.commands_message, var.message)}" +count = var.commands_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticache redis is receiving no commands" +message = coalesce(var.commands_message, var.message) type = "query alert" - query = < 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}" + 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)}" - + message = coalesce(var.es_cluster_status_message, var.message) type = "query alert" query = <= 2 - EOQ +EOQ - thresholds { - warning = 1 + 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 + 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}" + 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}"] + 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)}" - + 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 +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}"] +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] +} + diff --git a/cloud/aws/elasticsearch/outputs.tf b/cloud/aws/elasticsearch/outputs.tf index dc12393..602541e 100644 --- a/cloud/aws/elasticsearch/outputs.tf +++ b/cloud/aws/elasticsearch/outputs.tf @@ -1,14 +1,15 @@ output "es_cluster_status_id" { description = "id for monitor es_cluster_status" - value = "${datadog_monitor.es_cluster_status.*.id}" + value = datadog_monitor.es_cluster_status.*.id } output "es_free_space_low_id" { description = "id for monitor es_free_space_low" - value = "${datadog_monitor.es_free_space_low.*.id}" + value = datadog_monitor.es_free_space_low.*.id } output "es_cpu_90_15min_id" { description = "id for monitor es_cpu_90_15min" - value = "${datadog_monitor.es_cpu_90_15min.*.id}" + value = datadog_monitor.es_cpu_90_15min.*.id } + diff --git a/cloud/aws/elasticsearch/versions.tf b/cloud/aws/elasticsearch/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/cloud/aws/elasticsearch/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/cloud/aws/elb/inputs.tf b/cloud/aws/elb/inputs.tf index 08ce711..014fdc5 100644 --- a/cloud/aws/elb/inputs.tf +++ b/cloud/aws/elb/inputs.tf @@ -1,7 +1,7 @@ # Global Terraform variable "environment" { description = "Architecture Environment" - type = "string" + type = string } # Global DataDog @@ -43,55 +43,55 @@ variable "filter_tags_custom_excluded" { variable "elb_no_healthy_instance_enabled" { description = "Flag to enable ELB no healty instance monitor" - type = "string" + type = string default = "true" } variable "elb_no_healthy_instance_extra_tags" { description = "Extra tags for ELB no healty instance monitor" - type = "list" + type = list(string) default = [] } variable "elb_no_healthy_instance_message" { description = "Custom message for ELB no healty instance monitor" - type = "string" + type = string default = "" } variable "elb_no_healthy_instance_time_aggregator" { description = "Monitor aggregator for ELB no healty instance [available values: min or max]" - type = "string" + type = string default = "min" } variable "elb_no_healthy_instance_timeframe" { description = "Monitor timeframe for ELB no healty instance [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } variable "elb_4xx_enabled" { description = "Flag to enable ELB 4xx errors monitor" - type = "string" + type = string default = "true" } variable "elb_4xx_extra_tags" { description = "Extra tags for ELB 4xx errors monitor" - type = "list" + type = list(string) default = [] } variable "elb_4xx_message" { description = "Custom message for ELB 4xx errors monitor" - type = "string" + type = string default = "" } variable "elb_4xx_timeframe" { description = "Monitor timeframe for ELB 4xx errors [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -107,25 +107,25 @@ variable "elb_4xx_threshold_critical" { variable "elb_5xx_enabled" { description = "Flag to enable ELB 5xx errors monitor" - type = "string" + type = string default = "true" } variable "elb_5xx_extra_tags" { description = "Extra tags for ELB 5xx errors monitor" - type = "list" + type = list(string) default = [] } variable "elb_5xx_message" { description = "Custom message for ELB 5xx errors monitor" - type = "string" + type = string default = "" } variable "elb_5xx_timeframe" { description = "Monitor timeframe for ELB 5xx errors [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -141,25 +141,25 @@ variable "elb_5xx_threshold_critical" { variable "elb_backend_4xx_enabled" { description = "Flag to enable ELB backend 4xx errors monitor" - type = "string" + type = string default = "true" } variable "elb_backend_4xx_extra_tags" { description = "Extra tags for ELB backend 4xx errors monitor" - type = "list" + type = list(string) default = [] } variable "elb_backend_4xx_message" { description = "Custom message for ELB backend 4xx errors monitor" - type = "string" + type = string default = "" } variable "elb_backend_4xx_timeframe" { description = "Monitor timeframe for ELB backend 4xx errors [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -175,25 +175,25 @@ variable "elb_backend_4xx_threshold_critical" { variable "elb_backend_5xx_enabled" { description = "Flag to enable ELB backend 5xx errors monitor" - type = "string" + type = string default = "true" } variable "elb_backend_5xx_extra_tags" { description = "Extra tags for ELB backend 5xx errors monitor" - type = "list" + type = list(string) default = [] } variable "elb_backend_5xx_message" { description = "Custom message for ELB backend 5xx errors monitor" - type = "string" + type = string default = "" } variable "elb_backend_5xx_timeframe" { description = "Monitor timeframe for ELB backend 5xx errors [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -209,31 +209,31 @@ variable "elb_backend_5xx_threshold_critical" { variable "elb_backend_latency_enabled" { description = "Flag to enable ELB backend latency monitor" - type = "string" + type = string default = "true" } variable "elb_backend_latency_extra_tags" { description = "Extra tags for ELB backend latency monitor" - type = "list" + type = list(string) default = [] } variable "elb_backend_latency_message" { description = "Custom message for ELB backend latency monitor" - type = "string" + type = string default = "" } variable "elb_backend_latency_time_aggregator" { description = "Monitor aggregator for ELB backend latency [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "elb_backend_latency_timeframe" { description = "Monitor timeframe for ELB backend latency [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -251,3 +251,4 @@ variable "artificial_requests_count" { default = 5 description = "Number of false requests used to mitigate false positive in case of low trafic" } + diff --git a/cloud/aws/elb/modules.tf b/cloud/aws/elb/modules.tf index b6ad8ae..9d396f6 100644 --- a/cloud/aws/elb/modules.tf +++ b/cloud/aws/elb/modules.tf @@ -1,9 +1,10 @@ module "filter-tags" { source = "../../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "aws_elb" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded } + diff --git a/cloud/aws/elb/monitors-elb.tf b/cloud/aws/elb/monitors-elb.tf index 04bc028..310cf10 100644 --- a/cloud/aws/elb/monitors-elb.tf +++ b/cloud/aws/elb/monitors-elb.tf @@ -1,7 +1,8 @@ resource "datadog_monitor" "ELB_no_healthy_instances" { - count = "${var.elb_no_healthy_instance_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] ELB healthy instances {{#is_alert}}is at 0{{/is_alert}}{{#is_warning}}is at {{value}}%{{/is_warning}}" - message = "${coalesce(var.elb_no_healthy_instance_message, var.message)}" + count = var.elb_no_healthy_instance_enabled == "true" ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] ELB healthy instances {{#is_alert}}is at 0{{/is_alert}}{{#is_warning}}is at {{value}}%%{{/is_warning}}" + message = coalesce(var.elb_no_healthy_instance_message, var.message) + type = "query alert" query = < ${var.elb_4xx_threshold_critical} - EOQ +EOQ - type = "query alert" +thresholds = { +warning = var.elb_4xx_threshold_warning +critical = var.elb_4xx_threshold_critical +} - thresholds { - warning = "${var.elb_4xx_threshold_warning}" - critical = "${var.elb_4xx_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 - 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:elb", "team:claranet", "created-by:terraform", "${var.elb_4xx_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:elb", "team:claranet", "created-by:terraform", var.elb_4xx_extra_tags] } resource "datadog_monitor" "ELB_too_much_5xx" { - count = "${var.elb_5xx_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] ELB 5xx errors too high {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.elb_5xx_message, var.message)}" +count = var.elb_5xx_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] ELB 5xx errors too high {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +message = coalesce(var.elb_5xx_message, var.message) + type = "query alert" - query = < ${var.elb_5xx_threshold_critical} - EOQ +EOQ - type = "query alert" +thresholds = { +warning = var.elb_5xx_threshold_warning +critical = var.elb_5xx_threshold_critical +} - thresholds { - warning = "${var.elb_5xx_threshold_warning}" - critical = "${var.elb_5xx_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 - 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:elb", "team:claranet", "created-by:terraform", "${var.elb_5xx_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:elb", "team:claranet", "created-by:terraform", var.elb_5xx_extra_tags] } resource "datadog_monitor" "ELB_too_much_4xx_backend" { - count = "${var.elb_backend_4xx_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] ELB backend 4xx errors too high {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.elb_backend_4xx_message, var.message)}" +count = var.elb_backend_4xx_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] ELB backend 4xx errors too high {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +message = coalesce(var.elb_backend_4xx_message, var.message) + type = "query alert" - query = < ${var.elb_backend_4xx_threshold_critical} - EOQ +EOQ - type = "query alert" - - thresholds { - warning = "${var.elb_backend_4xx_threshold_warning}" - critical = "${var.elb_backend_4xx_threshold_critical}" + thresholds = { + warning = var.elb_backend_4xx_threshold_warning + critical = var.elb_backend_4xx_threshold_critical } notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" + 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}" + new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:elb", "team:claranet", "created-by:terraform", "${var.elb_backend_4xx_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:elb", "team:claranet", "created-by:terraform", var.elb_backend_4xx_extra_tags] } resource "datadog_monitor" "ELB_too_much_5xx_backend" { - count = "${var.elb_backend_5xx_enabled == "true" ? 1 : 0}" + count = var.elb_backend_5xx_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] ELB backend 5xx errors too high {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.elb_backend_5xx_message, var.message)}" + message = coalesce(var.elb_backend_5xx_message, var.message) + type = "query alert" query = < ${var.elb_backend_5xx_threshold_critical} - EOQ +EOQ - type = "query alert" - - thresholds { - warning = "${var.elb_backend_5xx_threshold_warning}" - critical = "${var.elb_backend_5xx_threshold_critical}" + thresholds = { + warning = var.elb_backend_5xx_threshold_warning + critical = var.elb_backend_5xx_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 + 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}" + new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:elb", "team:claranet", "created-by:terraform", "${var.elb_backend_5xx_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:elb", "team:claranet", "created-by:terraform", var.elb_backend_5xx_extra_tags] } resource "datadog_monitor" "ELB_backend_latency" { - count = "${var.elb_backend_latency_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] ELB latency too high {{#is_alert}}{{{comparator}}} {{threshold}}s ({{value}}s){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}s ({{value}}s){{/is_warning}}" - message = "${coalesce(var.elb_backend_latency_message, var.message)}" + count = var.elb_backend_latency_enabled == "true" ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] ELB latency too high {{#is_alert}}{{{comparator}}} {{threshold}}s ({{value}}s){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}s ({{value}}s){{/is_warning}}" + message = coalesce(var.elb_backend_latency_message, var.message) + type = "query alert" query = < ${var.elb_backend_latency_critical} - EOQ +EOQ - type = "query alert" - - thresholds { - warning = "${var.elb_backend_latency_warning}" - critical = "${var.elb_backend_latency_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:elb", "team:claranet", "created-by:terraform", "${var.elb_backend_latency_extra_tags}"] +thresholds = { +warning = var.elb_backend_latency_warning +critical = var.elb_backend_latency_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:elb", "team:claranet", "created-by:terraform", var.elb_backend_latency_extra_tags] +} + diff --git a/cloud/aws/elb/outputs.tf b/cloud/aws/elb/outputs.tf index d657bc4..8b115d2 100644 --- a/cloud/aws/elb/outputs.tf +++ b/cloud/aws/elb/outputs.tf @@ -1,29 +1,30 @@ output "ELB_no_healthy_instances_id" { description = "id for monitor ELB_no_healthy_instances" - value = "${datadog_monitor.ELB_no_healthy_instances.*.id}" + value = datadog_monitor.ELB_no_healthy_instances.*.id } output "ELB_too_much_4xx_id" { description = "id for monitor ELB_too_much_4xx" - value = "${datadog_monitor.ELB_too_much_4xx.*.id}" + value = datadog_monitor.ELB_too_much_4xx.*.id } output "ELB_too_much_5xx_id" { description = "id for monitor ELB_too_much_5xx" - value = "${datadog_monitor.ELB_too_much_5xx.*.id}" + value = datadog_monitor.ELB_too_much_5xx.*.id } output "ELB_too_much_4xx_backend_id" { description = "id for monitor ELB_too_much_4xx_backend" - value = "${datadog_monitor.ELB_too_much_4xx_backend.*.id}" + value = datadog_monitor.ELB_too_much_4xx_backend.*.id } output "ELB_too_much_5xx_backend_id" { description = "id for monitor ELB_too_much_5xx_backend" - value = "${datadog_monitor.ELB_too_much_5xx_backend.*.id}" + value = datadog_monitor.ELB_too_much_5xx_backend.*.id } output "ELB_backend_latency_id" { description = "id for monitor ELB_backend_latency" - value = "${datadog_monitor.ELB_backend_latency.*.id}" + value = datadog_monitor.ELB_backend_latency.*.id } + diff --git a/cloud/aws/elb/versions.tf b/cloud/aws/elb/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/cloud/aws/elb/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/cloud/aws/kinesis-firehose/inputs.tf b/cloud/aws/kinesis-firehose/inputs.tf index 3e60557..5fbd2a3 100644 --- a/cloud/aws/kinesis-firehose/inputs.tf +++ b/cloud/aws/kinesis-firehose/inputs.tf @@ -1,7 +1,7 @@ # Global Terraform variable "environment" { description = "Environment" - type = "string" + type = string } # Global DataDog @@ -43,19 +43,19 @@ variable "filter_tags_custom_excluded" { variable "incoming_records_enabled" { description = "Flag to enable Kinesis Firehorse incoming records monitor" - type = "string" + type = string default = "true" } variable "incoming_records_extra_tags" { description = "Extra tags for Kinesis Firehorse incoming records monitor" - type = "list" + type = list(string) default = [] } variable "incoming_records_message" { description = "Custom message for Kinesis Firehorse incoming records monitor" - type = "string" + type = string default = "" } @@ -63,3 +63,4 @@ variable "incoming_records_timeframe" { description = "Monitor timeframe for incoming records metrics evaluation [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" default = "last_15m" } + diff --git a/cloud/aws/kinesis-firehose/modules.tf b/cloud/aws/kinesis-firehose/modules.tf index f3a1d71..f9113f5 100644 --- a/cloud/aws/kinesis-firehose/modules.tf +++ b/cloud/aws/kinesis-firehose/modules.tf @@ -1,9 +1,10 @@ module "filter-tags" { source = "../../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "aws_kinesis-firehose" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded } + diff --git a/cloud/aws/kinesis-firehose/monitors-kinesis-firehose.tf b/cloud/aws/kinesis-firehose/monitors-kinesis-firehose.tf index 633e22a..8c6cbbd 100644 --- a/cloud/aws/kinesis-firehose/monitors-kinesis-firehose.tf +++ b/cloud/aws/kinesis-firehose/monitors-kinesis-firehose.tf @@ -1,30 +1,30 @@ ### Kinesis Firehose Incoming records ### resource "datadog_monitor" "firehose_incoming_records" { - count = "${var.incoming_records_enabled == "true" ? 1 : 0}" + count = var.incoming_records_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Kinesis Firehose No incoming records" - message = "${coalesce(var.incoming_records_message, var.message)}" - + message = coalesce(var.incoming_records_message, var.message) type = "query alert" query = < ${var.aurora_replicalag_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.aurora_replicalag_threshold_warning}" - critical = "${var.aurora_replicalag_threshold_critical}" + thresholds = { + warning = var.aurora_replicalag_threshold_warning + critical = var.aurora_replicalag_threshold_critical } - notify_no_data = true - evaluation_delay = "${var.evaluation_delay}" - notify_audit = false - timeout_h = 0 - include_tags = true - locked = false + notify_no_data = true + evaluation_delay = var.evaluation_delay + notify_audit = false + timeout_h = 0 + include_tags = true + locked = false require_full_window = false - new_host_delay = "${var.new_host_delay}" + new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:rds-aurora-mysql", "team:claranet", "created-by:terraform", "${var.aurora_replicalag_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:rds-aurora-mysql", "team:claranet", "created-by:terraform", var.aurora_replicalag_extra_tags] } + diff --git a/cloud/aws/rds/aurora/mysql/outputs.tf b/cloud/aws/rds/aurora/mysql/outputs.tf index dd13b44..f94f46d 100644 --- a/cloud/aws/rds/aurora/mysql/outputs.tf +++ b/cloud/aws/rds/aurora/mysql/outputs.tf @@ -1,4 +1,5 @@ output "rds_aurora_mysql_replica_lag_id" { description = "id for monitor rds_aurora_mysql_replica_lag" - value = "${datadog_monitor.rds_aurora_mysql_replica_lag.*.id}" + value = datadog_monitor.rds_aurora_mysql_replica_lag.*.id } + diff --git a/cloud/aws/rds/aurora/mysql/versions.tf b/cloud/aws/rds/aurora/mysql/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/cloud/aws/rds/aurora/mysql/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/cloud/aws/rds/aurora/postgresql/inputs.tf b/cloud/aws/rds/aurora/postgresql/inputs.tf index 6b07522..d8ebf55 100644 --- a/cloud/aws/rds/aurora/postgresql/inputs.tf +++ b/cloud/aws/rds/aurora/postgresql/inputs.tf @@ -1,7 +1,7 @@ # Global Terraform variable "environment" { description = "Architecture Environment" - type = "string" + type = string } # Global DataDog @@ -43,25 +43,25 @@ variable "filter_tags_custom_excluded" { variable "aurora_replicalag_enabled" { description = "Flag to enable RDS Aurora replica lag monitor" - type = "string" + type = string default = "true" } variable "aurora_replicalag_extra_tags" { description = "Extra tags for RDS Aurora replica lag monitor" - type = "list" + type = list(string) default = [] } variable "aurora_replicalag_message" { description = "Custom message for RDS Aurora replica lag monitor" - type = "string" + type = string default = "" } variable "aurora_replicalag_timeframe" { description = "Monitor timeframe for RDS Aurora replica lag monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -74,3 +74,4 @@ variable "aurora_replicalag_threshold_critical" { description = "Aurora replica lag in milliseconds (critical threshold)" default = "200" } + diff --git a/cloud/aws/rds/aurora/postgresql/modules.tf b/cloud/aws/rds/aurora/postgresql/modules.tf index e40637d..a5459e6 100644 --- a/cloud/aws/rds/aurora/postgresql/modules.tf +++ b/cloud/aws/rds/aurora/postgresql/modules.tf @@ -1,9 +1,10 @@ module "filter-tags" { source = "../../../../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "aws_rds" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded } + diff --git a/cloud/aws/rds/aurora/postgresql/monitors-rds-aurora-postgresql.tf b/cloud/aws/rds/aurora/postgresql/monitors-rds-aurora-postgresql.tf index e97638e..a29f0b9 100644 --- a/cloud/aws/rds/aurora/postgresql/monitors-rds-aurora-postgresql.tf +++ b/cloud/aws/rds/aurora/postgresql/monitors-rds-aurora-postgresql.tf @@ -1,30 +1,30 @@ ### RDS Aurora Postgresql Replica Lag monitor ### resource "datadog_monitor" "rds_aurora_postgresql_replica_lag" { - count = "${var.aurora_replicalag_enabled == "true" ? 1 : 0}" + count = var.aurora_replicalag_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] RDS Aurora PostgreSQL replica lag {{#is_alert}}{{{comparator}}} {{threshold}} ms ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ms ({{value}}%){{/is_warning}}" - message = "${coalesce(var.aurora_replicalag_message, var.message)}" - + message = coalesce(var.aurora_replicalag_message, var.message) type = "query alert" query = < ${var.aurora_replicalag_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.aurora_replicalag_threshold_warning}" - critical = "${var.aurora_replicalag_threshold_critical}" + thresholds = { + warning = var.aurora_replicalag_threshold_warning + critical = var.aurora_replicalag_threshold_critical } - notify_no_data = true - evaluation_delay = "${var.evaluation_delay}" - notify_audit = false - timeout_h = 0 - include_tags = true - locked = false + notify_no_data = true + evaluation_delay = var.evaluation_delay + notify_audit = false + timeout_h = 0 + include_tags = true + locked = false require_full_window = false - new_host_delay = "${var.new_host_delay}" + new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:rds-aurora-postgresql", "team:claranet", "created-by:terraform", "${var.aurora_replicalag_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:rds-aurora-postgresql", "team:claranet", "created-by:terraform", var.aurora_replicalag_extra_tags] } + diff --git a/cloud/aws/rds/aurora/postgresql/outputs.tf b/cloud/aws/rds/aurora/postgresql/outputs.tf index b88c1c4..118d6bb 100644 --- a/cloud/aws/rds/aurora/postgresql/outputs.tf +++ b/cloud/aws/rds/aurora/postgresql/outputs.tf @@ -1,4 +1,5 @@ output "rds_aurora_postgresql_replica_lag_id" { description = "id for monitor rds_aurora_postgresql_replica_lag" - value = "${datadog_monitor.rds_aurora_postgresql_replica_lag.*.id}" + value = datadog_monitor.rds_aurora_postgresql_replica_lag.*.id } + diff --git a/cloud/aws/rds/aurora/postgresql/versions.tf b/cloud/aws/rds/aurora/postgresql/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/cloud/aws/rds/aurora/postgresql/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/cloud/aws/rds/common/inputs.tf b/cloud/aws/rds/common/inputs.tf index 89c996d..f7e0796 100644 --- a/cloud/aws/rds/common/inputs.tf +++ b/cloud/aws/rds/common/inputs.tf @@ -1,7 +1,7 @@ # Global Terraform variable "environment" { description = "Architecture Environment" - type = "string" + type = string } # Global DataDog @@ -43,31 +43,31 @@ variable "filter_tags_custom_excluded" { variable "cpu_enabled" { description = "Flag to enable RDS CPU usage monitor" - type = "string" + type = string default = "true" } variable "cpu_extra_tags" { description = "Extra tags for RDS CPU usage monitor" - type = "list" + type = list(string) default = [] } variable "cpu_message" { description = "Custom message for RDS CPU usage monitor" - type = "string" + type = string default = "" } variable "cpu_time_aggregator" { description = "Monitor aggregator for RDS CPU usage [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "cpu_timeframe" { description = "Monitor timeframe for RDS CPU usage [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_15m" } @@ -83,31 +83,31 @@ variable "cpu_threshold_critical" { variable "diskspace_enabled" { description = "Flag to enable RDS free diskspace monitor" - type = "string" + type = string default = "true" } variable "diskspace_extra_tags" { description = "Extra tags for RDS free diskspace monitor" - type = "list" + type = list(string) default = [] } variable "diskspace_message" { description = "Custom message for RDS free diskspace monitor" - type = "string" + type = string default = "" } variable "diskspace_time_aggregator" { description = "Monitor aggregator for RDS free diskspace [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "diskspace_timeframe" { description = "Monitor timeframe for RDS free diskspace [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_15m" } @@ -123,25 +123,25 @@ variable "diskspace_threshold_critical" { variable "replicalag_enabled" { description = "Flag to enable RDS replica lag monitor" - type = "string" + type = string default = "true" } variable "replicalag_extra_tags" { description = "Extra tags for RDS replica lag monitor" - type = "list" + type = list(string) default = [] } variable "replicalag_message" { description = "Custom message for RDS replica lag monitor" - type = "string" + type = string default = "" } variable "replicalag_timeframe" { description = "Monitor timeframe for RDS replica lag monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -154,3 +154,4 @@ variable "replicalag_threshold_critical" { description = "replica lag in seconds (critical threshold)" default = "300" } + diff --git a/cloud/aws/rds/common/modules.tf b/cloud/aws/rds/common/modules.tf index 20f58c5..62fbd46 100644 --- a/cloud/aws/rds/common/modules.tf +++ b/cloud/aws/rds/common/modules.tf @@ -1,9 +1,10 @@ module "filter-tags" { source = "../../../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "aws_rds" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded } + diff --git a/cloud/aws/rds/common/monitors-rds-common.tf b/cloud/aws/rds/common/monitors-rds-common.tf index 098d6e6..fb526fa 100644 --- a/cloud/aws/rds/common/monitors-rds-common.tf +++ b/cloud/aws/rds/common/monitors-rds-common.tf @@ -1,40 +1,38 @@ ### RDS instance CPU monitor ### resource "datadog_monitor" "rds_cpu_90_15min" { - count = "${var.cpu_enabled == "true" ? 1 : 0}" + count = var.cpu_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] RDS instance CPU high {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.cpu_message, var.message)}" - + message = coalesce(var.cpu_message, var.message) type = "query alert" query = < ${var.cpu_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.cpu_threshold_warning}" - critical = "${var.cpu_threshold_critical}" + thresholds = { + warning = var.cpu_threshold_warning + critical = var.cpu_threshold_critical } - notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - notify_audit = false - timeout_h = 0 - include_tags = true - locked = false + notify_no_data = false + evaluation_delay = var.evaluation_delay + notify_audit = false + timeout_h = 0 + include_tags = true + locked = false require_full_window = false - new_host_delay = "${var.new_host_delay}" + new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:rds", "team:claranet", "created-by:terraform", "${var.cpu_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:rds", "team:claranet", "created-by:terraform", var.cpu_extra_tags] } ### RDS instance free space monitor ### resource "datadog_monitor" "rds_free_space_low" { - count = "${var.diskspace_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] RDS instance free space {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.diskspace_message, var.message)}" - + count = var.diskspace_enabled == "true" ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] RDS instance free 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.replicalag_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.replicalag_threshold_warning}" - critical = "${var.replicalag_threshold_critical}" - } - - notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - 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:rds", "team:claranet", "created-by:terraform", "${var.replicalag_extra_tags}"] +thresholds = { +warning = var.replicalag_threshold_warning +critical = var.replicalag_threshold_critical } + +notify_no_data = false +evaluation_delay = var.evaluation_delay +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:rds", "team:claranet", "created-by:terraform", var.replicalag_extra_tags] +} + diff --git a/cloud/aws/rds/common/outputs.tf b/cloud/aws/rds/common/outputs.tf index e112047..e70b9b6 100644 --- a/cloud/aws/rds/common/outputs.tf +++ b/cloud/aws/rds/common/outputs.tf @@ -1,14 +1,15 @@ output "rds_cpu_90_15min_id" { description = "id for monitor rds_cpu_90_15min" - value = "${datadog_monitor.rds_cpu_90_15min.*.id}" + value = datadog_monitor.rds_cpu_90_15min.*.id } output "rds_free_space_low_id" { description = "id for monitor rds_free_space_low" - value = "${datadog_monitor.rds_free_space_low.*.id}" + value = datadog_monitor.rds_free_space_low.*.id } output "rds_replica_lag_id" { description = "id for monitor rds_replica_lag" - value = "${datadog_monitor.rds_replica_lag.*.id}" + value = datadog_monitor.rds_replica_lag.*.id } + diff --git a/cloud/aws/rds/common/versions.tf b/cloud/aws/rds/common/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/cloud/aws/rds/common/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/cloud/aws/vpn/inputs.tf b/cloud/aws/vpn/inputs.tf index 2994bd3..b29e56c 100644 --- a/cloud/aws/vpn/inputs.tf +++ b/cloud/aws/vpn/inputs.tf @@ -1,7 +1,7 @@ # Global Terraform variable "environment" { description = "Architecture Environment" - type = "string" + type = string } # Global DataDog @@ -31,30 +31,31 @@ variable "filter_tags" { variable "vpn_status_enabled" { description = "Flag to enable VPN status monitor" - type = "string" + type = string default = "true" } variable "vpn_status_extra_tags" { description = "Extra tags for VPN status monitor" - type = "list" + type = list(string) default = [] } variable "vpn_status_message" { description = "Custom message for VPN status monitor" - type = "string" + type = string default = "" } variable "vpn_status_time_aggregator" { description = "Monitor aggregator for VPN status [available values: min, max or avg]" - type = "string" + type = string default = "max" } variable "vpn_status_timeframe" { description = "Monitor timeframe for VPN status [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } + diff --git a/cloud/aws/vpn/monitors-vpn.tf b/cloud/aws/vpn/monitors-vpn.tf index 2c30a33..e158992 100644 --- a/cloud/aws/vpn/monitors-vpn.tf +++ b/cloud/aws/vpn/monitors-vpn.tf @@ -1,24 +1,24 @@ resource "datadog_monitor" "VPN_status" { - count = "${var.vpn_status_enabled == "true" ? 1 : 0}" + count = var.vpn_status_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] VPN tunnel down" - message = "${coalesce(var.vpn_status_message, var.message)}" + message = coalesce(var.vpn_status_message, var.message) + type = "query alert" query = < ${var.failed_requests_threshold_critical} - EOQ +EOQ - thresholds { - critical = "${var.failed_requests_threshold_critical}" - warning = "${var.failed_requests_threshold_warning}" - } +thresholds = { +critical = var.failed_requests_threshold_critical +warning = var.failed_requests_threshold_warning +} - type = "query alert" - notify_no_data = false - notify_audit = false - timeout_h = 1 - include_tags = true - locked = false - require_full_window = false - new_host_delay = "${var.new_host_delay}" - evaluation_delay = "${var.evaluation_delay}" - renotify_interval = 0 +notify_no_data = false +notify_audit = false +timeout_h = 1 +include_tags = true +locked = false +require_full_window = false +new_host_delay = var.new_host_delay +evaluation_delay = var.evaluation_delay +renotify_interval = 0 - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:apimanagement", "team:claranet", "created-by:terraform", "${var.failed_requests_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:apimanagement", "team:claranet", "created-by:terraform", var.failed_requests_extra_tags] } resource "datadog_monitor" "apimgt_other_requests" { - count = "${var.other_requests_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] API Management too many other requests {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.other_requests_message, var.message)}" +count = var.other_requests_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] API Management too many other requests {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +message = coalesce(var.other_requests_message, var.message) + type = "query alert" - query = < ${var.other_requests_threshold_critical} - EOQ +EOQ - thresholds { - critical = "${var.other_requests_threshold_critical}" - warning = "${var.other_requests_threshold_warning}" - } +thresholds = { +critical = var.other_requests_threshold_critical +warning = var.other_requests_threshold_warning +} - type = "query alert" - notify_no_data = false - notify_audit = false - timeout_h = 1 - include_tags = true - locked = false - require_full_window = false - new_host_delay = "${var.new_host_delay}" - evaluation_delay = "${var.evaluation_delay}" - renotify_interval = 0 +notify_no_data = false +notify_audit = false +timeout_h = 1 +include_tags = true +locked = false +require_full_window = false +new_host_delay = var.new_host_delay +evaluation_delay = var.evaluation_delay +renotify_interval = 0 - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:apimanagement", "team:claranet", "created-by:terraform", "${var.other_requests_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:apimanagement", "team:claranet", "created-by:terraform", var.other_requests_extra_tags] } resource "datadog_monitor" "apimgt_unauthorized_requests" { - count = "${var.unauthorized_requests_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] API Management too many unauthorized requests {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.unauthorized_requests_message, var.message)}" +count = var.unauthorized_requests_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] API Management too many unauthorized requests {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +message = coalesce(var.unauthorized_requests_message, var.message) + type = "query alert" - query = < ${var.unauthorized_requests_threshold_critical} - EOQ +EOQ - thresholds { - critical = "${var.unauthorized_requests_threshold_critical}" - warning = "${var.unauthorized_requests_threshold_warning}" + thresholds = { + critical = var.unauthorized_requests_threshold_critical + warning = var.unauthorized_requests_threshold_warning } - type = "query alert" notify_no_data = false notify_audit = false timeout_h = 1 include_tags = true locked = false require_full_window = false - new_host_delay = "${var.new_host_delay}" - evaluation_delay = "${var.evaluation_delay}" + new_host_delay = var.new_host_delay + evaluation_delay = var.evaluation_delay renotify_interval = 0 - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:apimanagement", "team:claranet", "created-by:terraform", "${var.unauthorized_requests_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:apimanagement", "team:claranet", "created-by:terraform", var.unauthorized_requests_extra_tags] } resource "datadog_monitor" "apimgt_successful_requests" { - count = "${var.successful_requests_enabled == "true" ? 1 : 0}" + count = var.successful_requests_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] API Management successful requests rate too low {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.successful_requests_message, var.message)}" + message = coalesce(var.successful_requests_message, var.message) + type = "query alert" query = < ${var.response_time_threshold_critical} - EOQ +EOQ - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" - - thresholds { - warning = "${var.response_time_threshold_warning}" - critical = "${var.response_time_threshold_critical}" + thresholds = { + warning = var.response_time_threshold_warning + critical = var.response_time_threshold_critical } - notify_no_data = false # Will NOT notify when no data is received - renotify_interval = 0 + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay + notify_no_data = false + renotify_interval = 0 require_full_window = false - timeout_h = 0 - include_tags = true + timeout_h = 0 + include_tags = true - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:app-services", "team:claranet", "created-by:terraform", "${var.response_time_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:app-services", "team:claranet", "created-by:terraform", var.response_time_extra_tags] } # Monitoring App Services memory usage resource "datadog_monitor" "appservices_memory_usage_count" { - count = "${var.memory_usage_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] App Services memory usage {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}" + count = var.memory_usage_enabled == "true" ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] App Services memory usage {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}" type = "query alert" - message = "${coalesce(var.memory_usage_message, var.message)}" + message = coalesce(var.memory_usage_message, var.message) query = < ${var.memory_usage_threshold_critical} - EOQ +EOQ - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" +thresholds = { +warning = var.memory_usage_threshold_warning +critical = var.memory_usage_threshold_critical +} - thresholds { - warning = "${var.memory_usage_threshold_warning}" - critical = "${var.memory_usage_threshold_critical}" - } +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay +notify_no_data = false +renotify_interval = 0 +require_full_window = false +timeout_h = 0 +include_tags = true - notify_no_data = false # Will NOT notify when no data is received - renotify_interval = 0 - require_full_window = false - timeout_h = 0 - include_tags = true - - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:app-services", "team:claranet", "created-by:terraform", "${var.memory_usage_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:app-services", "team:claranet", "created-by:terraform", var.memory_usage_extra_tags] } # Monitoring App Services 5xx errors percent resource "datadog_monitor" "appservices_http_5xx_errors_count" { - count = "${var.http_5xx_requests_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] App Services HTTP 5xx errors too high {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +count = var.http_5xx_requests_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] App Services HTTP 5xx errors too high {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +message = coalesce(var.http_5xx_requests_message, var.message) type = "query alert" - message = "${coalesce(var.http_5xx_requests_message, var.message)}" - query = < ${var.http_5xx_requests_threshold_critical} - EOQ +EOQ - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" +thresholds = { +warning = var.http_5xx_requests_threshold_warning +critical = var.http_5xx_requests_threshold_critical +} - thresholds { - warning = "${var.http_5xx_requests_threshold_warning}" - critical = "${var.http_5xx_requests_threshold_critical}" - } +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay +notify_no_data = false +renotify_interval = 0 +require_full_window = false +timeout_h = 1 +include_tags = true - notify_no_data = false # Will NOT notify when no data is received - renotify_interval = 0 - require_full_window = false - timeout_h = 1 - include_tags = true - - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:app-services", "team:claranet", "created-by:terraform", "${var.http_5xx_requests_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:app-services", "team:claranet", "created-by:terraform", var.http_5xx_requests_extra_tags] } # Monitoring App Services 4xx errors percent resource "datadog_monitor" "appservices_http_4xx_errors_count" { - count = "${var.http_4xx_requests_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] App Services HTTP 4xx errors too high {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +count = var.http_4xx_requests_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] App Services HTTP 4xx errors too high {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" type = "query alert" - message = "${coalesce(var.http_4xx_requests_message, var.message)}" +message = coalesce(var.http_4xx_requests_message, var.message) - query = < ${var.http_4xx_requests_threshold_critical} - EOQ +EOQ - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" - - thresholds { - warning = "${var.http_4xx_requests_threshold_warning}" - critical = "${var.http_4xx_requests_threshold_critical}" + thresholds = { + warning = var.http_4xx_requests_threshold_warning + critical = var.http_4xx_requests_threshold_critical } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay notify_no_data = false # Will NOT notify when no data is received renotify_interval = 0 require_full_window = false timeout_h = 1 include_tags = true - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:app-services", "team:claranet", "created-by:terraform", "${var.http_4xx_requests_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:app-services", "team:claranet", "created-by:terraform", var.http_4xx_requests_extra_tags] } # Monitoring App Services HTTP 2xx & 3xx status pages percent resource "datadog_monitor" "appservices_http_success_status_rate" { - count = "${var.http_successful_requests_enabled == "true" ? 1 : 0}" + count = var.http_successful_requests_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] App Services HTTP successful responses too low {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" type = "query alert" - message = "${coalesce(var.http_successful_requests_message, var.message)}" + message = coalesce(var.http_successful_requests_message, var.message) query = < ${var.latency_threshold_critical} - EOQ +EOQ - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" - - thresholds { - warning = "${var.latency_threshold_warning}" - critical = "${var.latency_threshold_critical}" + thresholds = { + warning = var.latency_threshold_warning + critical = var.latency_threshold_critical } - notify_no_data = true # Will not notify when no data is received - renotify_interval = 0 + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay + notify_no_data = true + renotify_interval = 0 require_full_window = false - timeout_h = 0 - include_tags = true + timeout_h = 0 + include_tags = true - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:azure-search", "team:claranet", "created-by:terraform", "${var.latency_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:azure-search", "team:claranet", "created-by:terraform", var.latency_extra_tags] } # Monitoring Azure Search throttled queries resource "datadog_monitor" "azure_search_throttled_queries_rate" { - count = "${var.throttled_queries_rate_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Azure Search throttled queries rate is too high {{#is_alert}}{{{comparator}}} {{threshold}}s ({{value}}s){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}s ({{value}}s){{/is_warning}}" + count = var.throttled_queries_rate_enabled == "true" ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Azure Search throttled queries rate is too high {{#is_alert}}{{{comparator}}} {{threshold}}s ({{value}}s){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}s ({{value}}s){{/is_warning}}" + message = coalesce(var.throttled_queries_rate_message, var.message) type = "query alert" - message = "${coalesce(var.throttled_queries_rate_message, var.message)}" query = < ${var.throttled_queries_rate_threshold_critical} - EOQ +EOQ - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" - - thresholds { - warning = "${var.throttled_queries_rate_threshold_warning}" - critical = "${var.throttled_queries_rate_threshold_critical}" - } - - notify_no_data = false # Will notify when no data is received - renotify_interval = 0 - require_full_window = false - timeout_h = 0 - include_tags = true - - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:azure-search", "team:claranet", "created-by:terraform", "${var.throttled_queries_rate_extra_tags}"] +thresholds = { +warning = var.throttled_queries_rate_threshold_warning +critical = var.throttled_queries_rate_threshold_critical } + +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay +notify_no_data = false +renotify_interval = 0 +require_full_window = false +timeout_h = 0 +include_tags = true + +tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:azure-search", "team:claranet", "created-by:terraform", var.throttled_queries_rate_extra_tags] +} + diff --git a/cloud/azure/azure-search/outputs.tf b/cloud/azure/azure-search/outputs.tf index 8ab4045..c4e9e54 100644 --- a/cloud/azure/azure-search/outputs.tf +++ b/cloud/azure/azure-search/outputs.tf @@ -1,9 +1,10 @@ output "azure_search_latency_id" { description = "id for monitor azure_search_latency" - value = "${datadog_monitor.azure_search_latency.*.id}" + value = datadog_monitor.azure_search_latency.*.id } output "azure_search_throttled_queries_rate_id" { description = "id for monitor azure_search_throttled_queries_rate" - value = "${datadog_monitor.azure_search_throttled_queries_rate.*.id}" + value = datadog_monitor.azure_search_throttled_queries_rate.*.id } + diff --git a/cloud/azure/azure-search/versions.tf b/cloud/azure/azure-search/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/cloud/azure/azure-search/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/cloud/azure/cosmosdb/inputs.tf b/cloud/azure/cosmosdb/inputs.tf index 480f698..6c1c173 100644 --- a/cloud/azure/cosmosdb/inputs.tf +++ b/cloud/azure/cosmosdb/inputs.tf @@ -1,6 +1,6 @@ variable "environment" { description = "Architecture environment" - type = "string" + type = string } variable "filter_tags_use_defaults" { @@ -40,43 +40,43 @@ variable "prefix_slug" { # Azure CosmosDB specific variables variable "status_enabled" { description = "Flag to enable Cosmos DB status monitor" - type = "string" + type = string default = "true" } variable "status_extra_tags" { description = "Extra tags for Cosmos DB status monitor" - type = "list" + type = list(string) default = [] } variable "status_message" { description = "Custom message for Cosmos DB status monitor" - type = "string" + type = string default = "" } variable "status_time_aggregator" { description = "Monitor aggregator for Cosmos DB status [available values: min, max or avg]" - type = "string" + type = string default = "max" } variable "status_timeframe" { description = "Monitor timeframe for Cosmos DB status [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } variable "cosmos_db_4xx_requests_message" { description = "Custom message for Cosmos DB 4xx requests monitor" - type = "string" + type = string default = "" } variable "cosmos_db_4xx_requests_enabled" { description = "Flag to enable Cosmos DB 4xx requests monitor" - type = "string" + type = string default = "true" } @@ -92,31 +92,31 @@ variable "cosmos_db_4xx_request_rate_threshold_warning" { variable "cosmos_db_4xx_request_extra_tags" { description = "Extra tags for Cosmos DB 4xx requests monitor" - type = "list" + type = list(string) default = [] } variable "cosmos_db_4xx_request_time_aggregator" { description = "Monitor aggregator for Cosmos DB 4xx requests [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "cosmos_db_4xx_request_timeframe" { description = "Monitor timeframe for Cosmos DB 4xx requests [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } variable "cosmos_db_5xx_requests_message" { description = "Custom message for Cosmos DB 5xx requests monitor" - type = "string" + type = string default = "" } variable "cosmos_db_5xx_requests_enabled" { description = "Flag to enable Cosmos DB 5xx requests monitor" - type = "string" + type = string default = "true" } @@ -132,31 +132,31 @@ variable "cosmos_db_5xx_request_rate_threshold_warning" { variable "cosmos_db_5xx_request_rate_extra_tags" { description = "Extra tags for Cosmos DB 5xx requests monitor" - type = "list" + type = list(string) default = [] } variable "cosmos_db_5xx_request_time_aggregator" { description = "Monitor aggregator for Cosmos DB 5xx requests [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "cosmos_db_5xx_request_timeframe" { description = "Monitor timeframe for Cosmos DB 5xx requests [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } variable "cosmos_db_scaling_message" { description = "Custom message for Cosmos DB scaling monitor" - type = "string" + type = string default = "" } variable "cosmos_db_scaling_enabled" { description = "Flag to enable Cosmos DB scaling monitor" - type = "string" + type = string default = "true" } @@ -172,18 +172,19 @@ variable "cosmos_db_scaling_error_rate_threshold_warning" { variable "cosmos_db_scaling_extra_tags" { description = "Extra tags for Cosmos DB scaling monitor" - type = "list" + type = list(string) default = [] } variable "cosmos_db_scaling_time_aggregator" { description = "Monitor aggregator for Cosmos DB scaling [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "cosmos_db_scaling_timeframe" { description = "Monitor timeframe for Cosmos DB scaling [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } + diff --git a/cloud/azure/cosmosdb/modules.tf b/cloud/azure/cosmosdb/modules.tf index 8ad7f82..d54aaf2 100644 --- a/cloud/azure/cosmosdb/modules.tf +++ b/cloud/azure/cosmosdb/modules.tf @@ -1,20 +1,21 @@ module "filter-tags" { source = "../../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "azure_cosmosdb" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded } module "filter-tags-statuscode" { source = "../../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "azure_cosmosdb" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded extra_tags = ["statuscode:%s"] } + diff --git a/cloud/azure/cosmosdb/monitors-cosmosdb.tf b/cloud/azure/cosmosdb/monitors-cosmosdb.tf index 24d3df5..fe5c83a 100644 --- a/cloud/azure/cosmosdb/monitors-cosmosdb.tf +++ b/cloud/azure/cosmosdb/monitors-cosmosdb.tf @@ -1,39 +1,37 @@ resource "datadog_monitor" "cosmos_db_status" { - count = "${var.status_enabled == "true" ? 1 : 0}" - + count = var.status_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Cosmos DB is down" - message = "${coalesce(var.status_message, var.message)}" + message = coalesce(var.status_message, var.message) + type = "metric alert" query = < ${var.cosmos_db_4xx_request_rate_threshold_critical} - EOQ +EOQ - type = "query alert" +thresholds = { +critical = var.cosmos_db_4xx_request_rate_threshold_critical +warning = var.cosmos_db_4xx_request_rate_threshold_warning +} - thresholds { - critical = "${var.cosmos_db_4xx_request_rate_threshold_critical}" - warning = "${var.cosmos_db_4xx_request_rate_threshold_warning}" - } +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 - 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:azure", "resource:cosmos_db", "team:claranet", "created-by:terraform", "${var.cosmos_db_4xx_request_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:cosmos_db", "team:claranet", "created-by:terraform", var.cosmos_db_4xx_request_extra_tags] } resource "datadog_monitor" "cosmos_db_5xx_requests" { - count = "${var.cosmos_db_5xx_requests_enabled == "true" ? 1 : 0}" +count = var.cosmos_db_5xx_requests_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Cosmos DB 5xx requests rate is high {{#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) + type = "query alert" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Cosmos DB 5xx requests rate is high {{#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} - EOQ +EOQ - type = "query alert" +thresholds = { +critical = var.cosmos_db_5xx_request_rate_threshold_critical +warning = var.cosmos_db_5xx_request_rate_threshold_warning +} - thresholds { - critical = "${var.cosmos_db_5xx_request_rate_threshold_critical}" - warning = "${var.cosmos_db_5xx_request_rate_threshold_warning}" - } +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 - 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:azure", "resource:cosmos_db", "team:claranet", "created-by:terraform", "${var.cosmos_db_5xx_request_rate_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:cosmos_db", "team:claranet", "created-by:terraform", var.cosmos_db_5xx_request_rate_extra_tags] } resource "datadog_monitor" "cosmos_db_scaling" { - count = "${var.cosmos_db_scaling_enabled == "true" ? 1 : 0}" +count = var.cosmos_db_scaling_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Cosmos DB max scaling reached for collection {{#is_alert}}{{comparator}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{comparator}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +message = coalesce(var.cosmos_db_scaling_message, var.message) + type = "query alert" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Cosmos DB max scaling reached for collection {{#is_alert}}{{comparator}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{comparator}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.cosmos_db_scaling_message, var.message)}" - - # List of available status codes : https://docs.microsoft.com/en-us/rest/api/cosmos-db/http-status-codes-for-cosmosdb - query = < ${var.cosmos_db_scaling_error_rate_threshold_critical} - EOQ +EOQ - type = "query alert" - - thresholds { - critical = "${var.cosmos_db_scaling_error_rate_threshold_critical}" - warning = "${var.cosmos_db_scaling_error_rate_threshold_warning}" + thresholds = { + critical = var.cosmos_db_scaling_error_rate_threshold_critical + warning = var.cosmos_db_scaling_error_rate_threshold_warning } notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" + 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}" + new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:cosmos_db", "team:claranet", "created-by:terraform", "${var.cosmos_db_scaling_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:cosmos_db", "team:claranet", "created-by:terraform", var.cosmos_db_scaling_extra_tags] } + diff --git a/cloud/azure/cosmosdb/outputs.tf b/cloud/azure/cosmosdb/outputs.tf index 41bc5ec..126abf3 100644 --- a/cloud/azure/cosmosdb/outputs.tf +++ b/cloud/azure/cosmosdb/outputs.tf @@ -1,19 +1,20 @@ output "cosmos_db_status_id" { description = "id for monitor cosmos_db_status" - value = "${datadog_monitor.cosmos_db_status.*.id}" + value = datadog_monitor.cosmos_db_status.*.id } output "cosmos_db_4xx_requests_id" { description = "id for monitor cosmos_db_4xx_requests" - value = "${datadog_monitor.cosmos_db_4xx_requests.*.id}" + value = datadog_monitor.cosmos_db_4xx_requests.*.id } output "cosmos_db_5xx_requests_id" { description = "id for monitor cosmos_db_5xx_requests" - value = "${datadog_monitor.cosmos_db_5xx_requests.*.id}" + value = datadog_monitor.cosmos_db_5xx_requests.*.id } output "cosmos_db_scaling_id" { description = "id for monitor cosmos_db_scaling" - value = "${datadog_monitor.cosmos_db_scaling.*.id}" + value = datadog_monitor.cosmos_db_scaling.*.id } + diff --git a/cloud/azure/cosmosdb/versions.tf b/cloud/azure/cosmosdb/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/cloud/azure/cosmosdb/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/cloud/azure/datalakestore/inputs.tf b/cloud/azure/datalakestore/inputs.tf index 21ed4f1..846e90d 100644 --- a/cloud/azure/datalakestore/inputs.tf +++ b/cloud/azure/datalakestore/inputs.tf @@ -1,6 +1,6 @@ variable "environment" { description = "Architecture environment" - type = "string" + type = string } variable "filter_tags_use_defaults" { @@ -40,19 +40,19 @@ variable "prefix_slug" { # Azure Datalake Store specific variables variable "status_enabled" { description = "Flag to enable Datalake Store status monitor" - type = "string" + type = string default = "true" } variable "status_message" { description = "Custom message for Datalake Store status monitor" - type = "string" + type = string default = "" } variable "status_time_aggregator" { description = "Monitor aggregator for Datalake Store status [available values: min, max or avg]" - type = "string" + type = string default = "max" } @@ -63,6 +63,7 @@ variable "status_timeframe" { variable "status_extra_tags" { description = "Extra tags for Datalake Store status [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "list" + type = list(string) default = [] } + diff --git a/cloud/azure/datalakestore/modules.tf b/cloud/azure/datalakestore/modules.tf index e98fad1..b837d67 100644 --- a/cloud/azure/datalakestore/modules.tf +++ b/cloud/azure/datalakestore/modules.tf @@ -1,9 +1,10 @@ module "filter-tags" { source = "../../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "azure_datalakestore" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded } + diff --git a/cloud/azure/datalakestore/monitors-datalakestore.tf b/cloud/azure/datalakestore/monitors-datalakestore.tf index edf703e..c4efbb2 100644 --- a/cloud/azure/datalakestore/monitors-datalakestore.tf +++ b/cloud/azure/datalakestore/monitors-datalakestore.tf @@ -1,26 +1,25 @@ resource "datadog_monitor" "datalakestore_status" { - count = "${var.status_enabled == "true" ? 1 : 0}" - + count = var.status_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Datalake Store is down" - message = "${coalesce(var.status_message, var.message)}" + message = coalesce(var.status_message, var.message) + type = "query alert" query = < ${var.failed_messages_rate_thresold_critical} - EOQ +EOQ - type = "query alert" +thresholds = { +critical = var.failed_messages_rate_thresold_critical +warning = var.failed_messages_rate_thresold_warning +} - thresholds { - critical = "${var.failed_messages_rate_thresold_critical}" - warning = "${var.failed_messages_rate_thresold_warning}" - } +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 - 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:azure", "resource:eventgrid", "team:claranet", "created-by:terraform", "${var.failed_messages_rate_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:eventgrid", "team:claranet", "created-by:terraform", var.failed_messages_rate_extra_tags] } resource "datadog_monitor" "eventgrid_unmatched_events" { - count = "${var.unmatched_events_rate_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Event Grid too many unmatched events {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.unmatched_events_rate_message, var.message)}" +count = var.unmatched_events_rate_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Event Grid too many unmatched events {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +message = coalesce(var.unmatched_events_rate_message, var.message) + type = "query alert" - query = < ${var.unmatched_events_rate_thresold_critical} - EOQ +EOQ - type = "query alert" - - thresholds { - critical = "${var.unmatched_events_rate_thresold_critical}" - warning = "${var.unmatched_events_rate_thresold_warning}" - } - - 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:azure", "resource:eventgrid", "team:claranet", "created-by:terraform", "${var.unmatched_events_rate_extra_tags}"] +thresholds = { +critical = var.unmatched_events_rate_thresold_critical +warning = var.unmatched_events_rate_thresold_warning } + +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:azure", "resource:eventgrid", "team:claranet", "created-by:terraform", var.unmatched_events_rate_extra_tags] +} + diff --git a/cloud/azure/eventgrid/outputs.tf b/cloud/azure/eventgrid/outputs.tf index e209934..6369b0f 100644 --- a/cloud/azure/eventgrid/outputs.tf +++ b/cloud/azure/eventgrid/outputs.tf @@ -1,14 +1,15 @@ output "eventgrid_no_successful_message_id" { description = "id for monitor eventgrid_no_successful_message" - value = "${datadog_monitor.eventgrid_no_successful_message.*.id}" + value = datadog_monitor.eventgrid_no_successful_message.*.id } output "eventgrid_failed_messages_id" { description = "id for monitor eventgrid_failed_messages" - value = "${datadog_monitor.eventgrid_failed_messages.*.id}" + value = datadog_monitor.eventgrid_failed_messages.*.id } output "eventgrid_unmatched_events_id" { description = "id for monitor eventgrid_unmatched_events" - value = "${datadog_monitor.eventgrid_unmatched_events.*.id}" + value = datadog_monitor.eventgrid_unmatched_events.*.id } + diff --git a/cloud/azure/eventgrid/versions.tf b/cloud/azure/eventgrid/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/cloud/azure/eventgrid/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/cloud/azure/eventhub/inputs.tf b/cloud/azure/eventhub/inputs.tf index ca54d2e..a1bb291 100644 --- a/cloud/azure/eventhub/inputs.tf +++ b/cloud/azure/eventhub/inputs.tf @@ -1,7 +1,7 @@ # Global Terraform variable "environment" { description = "Architecture environment" - type = "string" + type = string } # Global DataDog @@ -43,61 +43,61 @@ variable "filter_tags_custom_excluded" { variable "status_enabled" { description = "Flag to enable Event Hub status monitor" - type = "string" + type = string default = "true" } variable "status_extra_tags" { description = "Extra tags for Event Hub status monitor" - type = "list" + type = list(string) default = [] } variable "status_message" { description = "Custom message for Event Hub status monitor" - type = "string" + type = string default = "" } variable "status_time_aggregator" { description = "Monitor aggregator for Event Hub status [available values: min, max or avg]" - type = "string" + type = string default = "max" } variable "status_timeframe" { description = "Monitor timeframe for Event Hub status [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } variable "failed_requests_rate_enabled" { description = "Flag to enable Event Hub failed requests monitor" - type = "string" + type = string default = "true" } variable "failed_requests_rate_extra_tags" { description = "Extra tags for Event Hub failed requests monitor" - type = "list" + type = list(string) default = [] } variable "failed_requests_rate_message" { description = "Custom message for Event Hub failed requests monitor" - type = "string" + type = string default = "" } variable "failed_requests_rate_time_aggregator" { description = "Monitor aggregator for Event Hub failed requests [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "failed_requests_rate_timeframe" { description = "Monitor timeframe for Event Hub failed requests [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -113,31 +113,31 @@ variable "failed_requests_rate_thresold_warning" { variable "errors_rate_enabled" { description = "Flag to enable Event Hub errors monitor" - type = "string" + type = string default = "true" } variable "errors_rate_extra_tags" { description = "Extra tags for Event Hub errors monitor" - type = "list" + type = list(string) default = [] } variable "errors_rate_message" { description = "Custom message for Event Hub errors monitor" - type = "string" + type = string default = "" } variable "errors_rate_time_aggregator" { description = "Monitor aggregator for Event Hub errors [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "errors_rate_timeframe" { description = "Monitor timeframe for Event Hub errors [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -150,3 +150,4 @@ variable "errors_rate_thresold_warning" { description = "Errors ratio (percentage) to trigger a warning alert" default = 50 } + diff --git a/cloud/azure/eventhub/modules.tf b/cloud/azure/eventhub/modules.tf index 5d204fa..15b8884 100644 --- a/cloud/azure/eventhub/modules.tf +++ b/cloud/azure/eventhub/modules.tf @@ -1,9 +1,10 @@ module "filter-tags" { source = "../../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "azure_eventhub" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded } + diff --git a/cloud/azure/eventhub/monitors-eventhub.tf b/cloud/azure/eventhub/monitors-eventhub.tf index f79635b..3eb9d9f 100644 --- a/cloud/azure/eventhub/monitors-eventhub.tf +++ b/cloud/azure/eventhub/monitors-eventhub.tf @@ -1,91 +1,89 @@ resource "datadog_monitor" "eventhub_status" { - count = "${var.status_enabled == "true" ? 1 : 0}" + count = var.status_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Event Hub is down" - message = "${coalesce(var.status_message, var.message)}" + message = coalesce(var.status_message, var.message) + type = "query alert" query = < ${var.failed_requests_rate_thresold_critical} - EOQ +EOQ - type = "query alert" +thresholds = { +critical = var.failed_requests_rate_thresold_critical +warning = var.failed_requests_rate_thresold_warning +} - thresholds { - critical = "${var.failed_requests_rate_thresold_critical}" - warning = "${var.failed_requests_rate_thresold_warning}" - } +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 - 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:azure", "resource:eventhub", "team:claranet", "created-by:terraform", "${var.failed_requests_rate_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:eventhub", "team:claranet", "created-by:terraform", var.failed_requests_rate_extra_tags] } resource "datadog_monitor" "eventhub_errors" { - count = "${var.errors_rate_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Event Hub too many errors {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.errors_rate_message, var.message)}" +count = var.errors_rate_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Event Hub too many errors {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +message = coalesce(var.errors_rate_message, var.message) + type = "query alert" - query = < ${var.errors_rate_thresold_critical} - EOQ +EOQ - type = "query alert" - - thresholds { - critical = "${var.errors_rate_thresold_critical}" - warning = "${var.errors_rate_thresold_warning}" - } - - 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:azure", "resource:eventhub", "team:claranet", "created-by:terraform", "${var.errors_rate_extra_tags}"] +thresholds = { +critical = var.errors_rate_thresold_critical +warning = var.errors_rate_thresold_warning } + +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:azure", "resource:eventhub", "team:claranet", "created-by:terraform", var.errors_rate_extra_tags] +} + diff --git a/cloud/azure/eventhub/outputs.tf b/cloud/azure/eventhub/outputs.tf index 33f384a..a2545ac 100644 --- a/cloud/azure/eventhub/outputs.tf +++ b/cloud/azure/eventhub/outputs.tf @@ -1,14 +1,15 @@ output "eventhub_status_id" { description = "id for monitor eventhub_status" - value = "${datadog_monitor.eventhub_status.*.id}" + value = datadog_monitor.eventhub_status.*.id } output "eventhub_failed_requests_id" { description = "id for monitor eventhub_failed_requests" - value = "${datadog_monitor.eventhub_failed_requests.*.id}" + value = datadog_monitor.eventhub_failed_requests.*.id } output "eventhub_errors_id" { description = "id for monitor eventhub_errors" - value = "${datadog_monitor.eventhub_errors.*.id}" + value = datadog_monitor.eventhub_errors.*.id } + diff --git a/cloud/azure/eventhub/versions.tf b/cloud/azure/eventhub/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/cloud/azure/eventhub/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/cloud/azure/functions/inputs.tf b/cloud/azure/functions/inputs.tf index d7497ff..b74679c 100644 --- a/cloud/azure/functions/inputs.tf +++ b/cloud/azure/functions/inputs.tf @@ -1,6 +1,6 @@ variable "environment" { description = "Architecture environment" - type = "string" + type = string } variable "filter_tags_use_defaults" { @@ -41,31 +41,31 @@ variable "prefix_slug" { variable "http_5xx_errors_rate_enabled" { description = "Flag to enable Functions Http 5xx errors rate monitor" - type = "string" + type = string default = "true" } variable "http_5xx_errors_rate_extra_tags" { description = "Extra tags for Functions Http 5xx errors rate monitor" - type = "list" + type = list(string) default = [] } variable "http_5xx_errors_rate_message" { description = "Custom message for Functions Http 5xx errors rate monitor" - type = "string" + type = string default = "" } variable "http_5xx_errors_rate_time_aggregator" { description = "Monitor aggregator for Functions Http 5xx errors rate [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "http_5xx_errors_rate_timeframe" { description = "Monitor timeframe for Functions Http 5xx errors rate [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -81,31 +81,31 @@ variable "http_5xx_errors_rate_threshold_warning" { variable "high_connections_count_enabled" { description = "Flag to enable Functions high connections count monitor" - type = "string" + type = string default = "true" } variable "high_connections_count_extra_tags" { description = "Extra tags for Functions high connections count monitor" - type = "list" + type = list(string) default = [] } variable "high_connections_count_message" { description = "Custom message for Functions high connections count monitor" - type = "string" + type = string default = "" } variable "high_connections_count_time_aggregator" { description = "Monitor aggregator for Functions high connections count [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "high_connections_count_timeframe" { description = "Monitor timeframe for Functions high connections count [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -121,31 +121,31 @@ variable "high_connections_count_threshold_warning" { variable "high_threads_count_enabled" { description = "Flag to enable Functions high threads count monitor" - type = "string" + type = string default = "true" } variable "high_threads_count_extra_tags" { description = "Extra tags for Functions high threads count monitor" - type = "list" + type = list(string) default = [] } variable "high_threads_count_message" { description = "Custom message for Functions high threads count monitor" - type = "string" + type = string default = "" } variable "high_threads_count_time_aggregator" { description = "Monitor aggregator for Functions high threads count [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "high_threads_count_timeframe" { description = "Monitor timeframe for Functions high threads count [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -158,3 +158,4 @@ variable "high_threads_count_threshold_warning" { default = 490 description = "Warning threshold for Functions high threads count" } + diff --git a/cloud/azure/functions/modules.tf b/cloud/azure/functions/modules.tf index b68c9e6..8d6e1d0 100644 --- a/cloud/azure/functions/modules.tf +++ b/cloud/azure/functions/modules.tf @@ -1,9 +1,10 @@ module "filter-tags" { source = "../../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "azure_functions" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded } + diff --git a/cloud/azure/functions/monitors-functions.tf b/cloud/azure/functions/monitors-functions.tf index 1f946ac..fb43c2f 100644 --- a/cloud/azure/functions/monitors-functions.tf +++ b/cloud/azure/functions/monitors-functions.tf @@ -1,87 +1,85 @@ resource "datadog_monitor" "function_http_5xx_errors_rate" { - count = "${var.http_5xx_errors_rate_enabled == "true" ? 1 : 0}" + count = var.http_5xx_errors_rate_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Function App HTTP 5xx errors too high {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" type = "query alert" - message = "${coalesce(var.http_5xx_errors_rate_message, var.message)}" + message = coalesce(var.http_5xx_errors_rate_message, var.message) query = < ${var.http_5xx_errors_rate_threshold_critical} - EOQ +EOQ - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" - - thresholds { - warning = "${var.http_5xx_errors_rate_threshold_warning}" - critical = "${var.http_5xx_errors_rate_threshold_critical}" + thresholds = { + warning = var.http_5xx_errors_rate_threshold_warning + critical = var.http_5xx_errors_rate_threshold_critical } - notify_no_data = false - renotify_interval = 0 + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay + notify_no_data = false + renotify_interval = 0 require_full_window = false - timeout_h = 1 - include_tags = true + timeout_h = 1 + include_tags = true - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:azure_functions", "team:claranet", "created-by:terraform", "${var.http_5xx_errors_rate_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:azure_functions", "team:claranet", "created-by:terraform", var.http_5xx_errors_rate_extra_tags] } resource "datadog_monitor" "function_high_connections_count" { - count = "${var.high_connections_count_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Function App connections count too high {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}" + count = var.high_connections_count_enabled == "true" ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Function App connections count too high {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}" type = "query alert" - message = "${coalesce(var.high_connections_count_message, var.message)}" + message = coalesce(var.high_connections_count_message, var.message) query = < ${var.high_connections_count_threshold_critical} - EOQ +EOQ - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" +thresholds = { +warning = var.high_connections_count_threshold_warning +critical = var.high_connections_count_threshold_critical +} - thresholds { - warning = "${var.high_connections_count_threshold_warning}" - critical = "${var.high_connections_count_threshold_critical}" - } +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay +notify_no_data = false +renotify_interval = 0 +require_full_window = false +timeout_h = 1 +include_tags = true - notify_no_data = false - renotify_interval = 0 - require_full_window = false - timeout_h = 1 - include_tags = true - - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:azure_functions", "team:claranet", "created-by:terraform", "${var.high_connections_count_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:azure_functions", "team:claranet", "created-by:terraform", var.high_connections_count_extra_tags] } resource "datadog_monitor" "function_high_threads_count" { - count = "${var.high_threads_count_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Function App threads count too high {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}" +count = var.high_threads_count_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Function App threads count too high {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}" type = "query alert" - message = "${coalesce(var.high_threads_count_message, var.message)}" +message = coalesce(var.high_threads_count_message, var.message) - query = < ${var.high_threads_count_threshold_critical} - EOQ +EOQ - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" - - thresholds { - warning = "${var.high_threads_count_threshold_warning}" - critical = "${var.high_threads_count_threshold_critical}" - } - - notify_no_data = false - renotify_interval = 0 - require_full_window = false - timeout_h = 1 - include_tags = true - - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:azure_functions", "team:claranet", "created-by:terraform", "${var.high_threads_count_extra_tags}"] +thresholds = { +warning = var.high_threads_count_threshold_warning +critical = var.high_threads_count_threshold_critical } + +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay +notify_no_data = false +renotify_interval = 0 +require_full_window = false +timeout_h = 1 +include_tags = true + +tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:azure_functions", "team:claranet", "created-by:terraform", var.high_threads_count_extra_tags] +} + diff --git a/cloud/azure/functions/outputs.tf b/cloud/azure/functions/outputs.tf index 6782cff..a928a6b 100644 --- a/cloud/azure/functions/outputs.tf +++ b/cloud/azure/functions/outputs.tf @@ -1,14 +1,15 @@ output "function_http_5xx_errors_rate_id" { description = "id for monitor function_http_5xx_errors_rate" - value = "${datadog_monitor.function_http_5xx_errors_rate.*.id}" + value = datadog_monitor.function_http_5xx_errors_rate.*.id } output "function_high_connections_count_id" { description = "id for monitor function_high_connections_count" - value = "${datadog_monitor.function_high_connections_count.*.id}" + value = datadog_monitor.function_high_connections_count.*.id } output "function_high_threads_count_id" { description = "id for monitor function_high_threads_count" - value = "${datadog_monitor.function_high_threads_count.*.id}" + value = datadog_monitor.function_high_threads_count.*.id } + diff --git a/cloud/azure/functions/versions.tf b/cloud/azure/functions/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/cloud/azure/functions/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/cloud/azure/iothubs/inputs.tf b/cloud/azure/iothubs/inputs.tf index 0ede25b..1fa7bf5 100644 --- a/cloud/azure/iothubs/inputs.tf +++ b/cloud/azure/iothubs/inputs.tf @@ -1,7 +1,7 @@ # Global Terraform variable "environment" { description = "Architecture Environment" - type = "string" + type = string } # Global DataDog @@ -43,115 +43,115 @@ variable "filter_tags_custom_excluded" { variable "status_enabled" { description = "Flag to enable IoT Hub status monitor" - type = "string" + type = string default = "true" } variable "status_extra_tags" { description = "Extra tags for IoT Hub status monitor" - type = "list" + type = list(string) default = [] } variable "status_message" { description = "Custom message for IoT Hub status monitor" - type = "string" + type = string default = "" } variable "status_time_aggregator" { description = "Monitor aggregator for IoT Hub status [available values: min, max, sum or avg]" - type = "string" + type = string default = "max" } variable "status_timeframe" { description = "Monitor timeframe for IoT Hub status [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } variable "total_devices_enabled" { description = "Flag to enable IoT Hub total devices monitor" - type = "string" + type = string default = "true" } variable "total_devices_extra_tags" { description = "Extra tags for IoT Hub total devices monitor" - type = "list" + type = list(string) default = [] } variable "total_devices_message" { description = "Custom message for IoT Hub total devices monitor" - type = "string" + type = string default = "" } variable "total_devices_time_aggregator" { description = "Monitor aggregator for IoT Hub total devices [available values: min, max, sum or avg]" - type = "string" + type = string default = "min" } variable "total_devices_timeframe" { description = "Monitor timeframe for IoT Hub total devices [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } variable "too_many_d2c_telemetry_ingress_nosent_enabled" { description = "Flag to enable IoT Hub unsent d2c telemetry monitor" - type = "string" + type = string default = "true" } variable "too_many_d2c_telemetry_ingress_nosent_extra_tags" { description = "Extra tags for IoT Hub unsent d2c telemetry monitor" - type = "list" + type = list(string) default = [] } variable "too_many_d2c_telemetry_ingress_nosent_message" { description = "Custom message for IoT Hub unsent d2c telemetry monitor" - type = "string" + type = string default = "" } variable "too_many_d2c_telemetry_ingress_nosent_timeframe" { description = "Monitor timeframe for IoT Hub unsent d2c telemetry [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } variable "failed_jobs_rate_enabled" { description = "Flag to enable IoT Hub failed jobs monitor" - type = "string" + type = string default = "true" } variable "failed_jobs_rate_extra_tags" { description = "Extra tags for IoT Hub failed jobs monitor" - type = "list" + type = list(string) default = [] } variable "failed_jobs_rate_message" { description = "Custom message for IoT Hub failed jobs monitor" - type = "string" + type = string default = "" } variable "failed_jobs_rate_time_aggregator" { description = "Monitor aggregator for IoT Hub failed jobs [available values: min, max, sum or avg]" - type = "string" + type = string default = "min" } variable "failed_jobs_rate_timeframe" { description = "Monitor timeframe for IoT Hub failed jobs [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -167,31 +167,31 @@ variable "failed_jobs_rate_threshold_critical" { variable "failed_listjobs_rate_enabled" { description = "Flag to enable IoT Hub failed list jobs monitor" - type = "string" + type = string default = "true" } variable "failed_listjobs_rate_extra_tags" { description = "Extra tags for IoT Hub failed list jobs monitor" - type = "list" + type = list(string) default = [] } variable "failed_listjobs_rate_message" { description = "Custom message for IoT Hub failed list jobs monitor" - type = "string" + type = string default = "" } variable "failed_listjobs_rate_time_aggregator" { description = "Monitor aggregator for IoT Hub failed list jobs [available values: min, max, sum or avg]" - type = "string" + type = string default = "min" } variable "failed_listjobs_rate_timeframe" { description = "Monitor timeframe for IoT Hub failed list jobs [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -207,31 +207,31 @@ variable "failed_listjobs_rate_threshold_critical" { variable "failed_queryjobs_rate_enabled" { description = "Flag to enable IoT Hub failed query jobs monitor" - type = "string" + type = string default = "true" } variable "failed_queryjobs_rate_extra_tags" { description = "Extra tags for IoT Hub failed query jobs monitor" - type = "list" + type = list(string) default = [] } variable "failed_queryjobs_rate_message" { description = "Custom message for IoT Hub failed query jobs monitor" - type = "string" + type = string default = "" } variable "failed_queryjobs_rate_time_aggregator" { description = "Monitor aggregator for IoT Hub failed query jobs [available values: min, max, sum or avg]" - type = "string" + type = string default = "min" } variable "failed_queryjobs_rate_timeframe" { description = "Monitor timeframe for IoT Hub failed query jobs [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -247,31 +247,31 @@ variable "failed_queryjobs_rate_threshold_critical" { variable "failed_c2d_methods_rate_enabled" { description = "Flag to enable IoT Hub failed c2d methods monitor" - type = "string" + type = string default = "true" } variable "failed_c2d_methods_rate_extra_tags" { description = "Extra tags for IoT Hub failed c2d methods monitor" - type = "list" + type = list(string) default = [] } variable "failed_c2d_methods_rate_message" { description = "Custom message for IoT Hub failed c2d method monitor" - type = "string" + type = string default = "" } variable "failed_c2d_methods_rate_time_aggregator" { description = "Monitor aggregator for IoT Hub failed c2d method [available values: min, max, sum or avg]" - type = "string" + type = string default = "min" } variable "failed_c2d_methods_rate_timeframe" { description = "Monitor timeframe for IoT Hub failed c2d method [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -287,31 +287,31 @@ variable "failed_c2d_methods_rate_threshold_critical" { variable "failed_c2d_twin_read_rate_enabled" { description = "Flag to enable IoT Hub failed c2d twin read monitor" - type = "string" + type = string default = "true" } variable "failed_c2d_twin_read_rate_extra_tags" { description = "Extra tags for IoT Hub failed c2d twin read monitor" - type = "list" + type = list(string) default = [] } variable "failed_c2d_twin_read_rate_message" { description = "Custom message for IoT Hub failed c2d twin read monitor" - type = "string" + type = string default = "" } variable "failed_c2d_twin_read_rate_time_aggregator" { description = "Monitor aggregator for IoT Hub failed c2d twin read [available values: min, max, sum or avg]" - type = "string" + type = string default = "min" } variable "failed_c2d_twin_read_rate_timeframe" { description = "Monitor timeframe for IoT Hub failed c2d twin read [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -327,31 +327,31 @@ variable "failed_c2d_twin_read_rate_threshold_critical" { variable "failed_c2d_twin_update_rate_enabled" { description = "Flag to enable IoT Hub failed c2d twin update monitor" - type = "string" + type = string default = "true" } variable "failed_c2d_twin_update_rate_extra_tags" { description = "Extra tags for IoT Hub failed c2d twin update monitor" - type = "list" + type = list(string) default = [] } variable "failed_c2d_twin_update_rate_message" { description = "Custom message for IoT Hub failed c2d twin update monitor" - type = "string" + type = string default = "" } variable "failed_c2d_twin_update_rate_time_aggregator" { description = "Monitor aggregator for IoT Hub failed c2d twin update [available values: min, max, sum or avg]" - type = "string" + type = string default = "min" } variable "failed_c2d_twin_update_rate_timeframe" { description = "Monitor timeframe for IoT Hub failed c2d twin update [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -367,31 +367,31 @@ variable "failed_c2d_twin_update_rate_threshold_critical" { variable "failed_d2c_twin_read_rate_enabled" { description = "Flag to enable IoT Hub failed d2c twin read monitor" - type = "string" + type = string default = "true" } variable "failed_d2c_twin_read_rate_extra_tags" { description = "Extra tags for IoT Hub failed d2c twin read monitor" - type = "list" + type = list(string) default = [] } variable "failed_d2c_twin_read_rate_message" { description = "Custom message for IoT Hub failed d2c twin read monitor" - type = "string" + type = string default = "" } variable "failed_d2c_twin_read_rate_time_aggregator" { description = "Monitor aggregator for IoT Hub failed d2c twin read [available values: min, max, sum or avg]" - type = "string" + type = string default = "min" } variable "failed_d2c_twin_read_rate_timeframe" { description = "Monitor timeframe for IoT Hub failed d2c twin read [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -407,31 +407,31 @@ variable "failed_d2c_twin_read_rate_threshold_critical" { variable "failed_d2c_twin_update_rate_enabled" { description = "Flag to enable IoT Hub failed d2c twin update monitor" - type = "string" + type = string default = "true" } variable "failed_d2c_twin_update_rate_extra_tags" { description = "Extra tags for IoT Hub failed d2c twin update monitor" - type = "list" + type = list(string) default = [] } variable "failed_d2c_twin_update_rate_message" { description = "Custom message for IoT Hub failed d2c twin update monitor" - type = "string" + type = string default = "" } variable "failed_d2c_twin_update_rate_time_aggregator" { description = "Monitor aggregator for IoT Hub failed d2c twin update [available values: min, max, sum or avg]" - type = "string" + type = string default = "min" } variable "failed_d2c_twin_update_rate_timeframe" { description = "Monitor timeframe for IoT Hub failed d2c twin update [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -447,31 +447,31 @@ variable "failed_d2c_twin_update_rate_threshold_critical" { variable "dropped_d2c_telemetry_egress_enabled" { description = "Flag to enable IoT Hub dropped d2c telemetry monitor" - type = "string" + type = string default = "true" } variable "dropped_d2c_telemetry_egress_extra_tags" { description = "Extra tags for IoT Hub dropped d2c telemetry monitor" - type = "list" + type = list(string) default = [] } variable "dropped_d2c_telemetry_egress_message" { description = "Custom message for IoT Hub dropped d2c telemetry monitor" - type = "string" + type = string default = "" } variable "dropped_d2c_telemetry_egress_time_aggregator" { description = "Monitor aggregator for IoT Hub dropped d2c telemetry [available values: min, max, sum or avg]" - type = "string" + type = string default = "min" } variable "dropped_d2c_telemetry_egress_timeframe" { description = "Monitor timeframe for IoT Hub dropped d2c telemetry [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -487,31 +487,31 @@ variable "dropped_d2c_telemetry_egress_rate_threshold_critical" { variable "orphaned_d2c_telemetry_egress_enabled" { description = "Flag to enable IoT Hub orphaned d2c telemetry monitor" - type = "string" + type = string default = "true" } variable "orphaned_d2c_telemetry_egress_extra_tags" { description = "Extra tags for IoT Hub orphaned d2c telemetry monitor" - type = "list" + type = list(string) default = [] } variable "orphaned_d2c_telemetry_egress_message" { description = "Custom message for IoT Hub orphaned d2c telemetry monitor" - type = "string" + type = string default = "" } variable "orphaned_d2c_telemetry_egress_time_aggregator" { description = "Monitor aggregator for IoT Hub orphaned d2c telemetry [available values: min, max, sum or avg]" - type = "string" + type = string default = "min" } variable "orphaned_d2c_telemetry_egress_timeframe" { description = "Monitor timeframe for IoT Hub orphaned d2c telemetry [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -527,31 +527,31 @@ variable "orphaned_d2c_telemetry_egress_rate_threshold_critical" { variable "invalid_d2c_telemetry_egress_enabled" { description = "Flag to enable IoT Hub invalid d2c telemetry monitor" - type = "string" + type = string default = "true" } variable "invalid_d2c_telemetry_egress_extra_tags" { description = "Extra tags for IoT Hub invalid d2c telemetry monitor" - type = "list" + type = list(string) default = [] } variable "invalid_d2c_telemetry_egress_message" { description = "Custom message for IoT Hub invalid d2c telemetry monitor" - type = "string" + type = string default = "" } variable "invalid_d2c_telemetry_egress_time_aggregator" { description = "Monitor aggregator for IoT Hub invalid d2c telemetry [available values: min, max, sum or avg]" - type = "string" + type = string default = "min" } variable "invalid_d2c_telemetry_egress_timeframe" { description = "Monitor timeframe for IoT Hub invalid d2c telemetry [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -564,3 +564,4 @@ variable "invalid_d2c_telemetry_egress_rate_threshold_critical" { description = "D2C Telemetry Invalid limit (critical threshold)" default = 90 } + diff --git a/cloud/azure/iothubs/modules.tf b/cloud/azure/iothubs/modules.tf index cb481a0..887245d 100644 --- a/cloud/azure/iothubs/modules.tf +++ b/cloud/azure/iothubs/modules.tf @@ -1,8 +1,9 @@ module "filter-tags" { source = "../../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "azure_iothubs" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom } + diff --git a/cloud/azure/iothubs/monitors-iothubs.tf b/cloud/azure/iothubs/monitors-iothubs.tf index 7681534..2df299a 100644 --- a/cloud/azure/iothubs/monitors-iothubs.tf +++ b/cloud/azure/iothubs/monitors-iothubs.tf @@ -1,7 +1,8 @@ resource "datadog_monitor" "too_many_jobs_failed" { - count = "${var.failed_jobs_rate_enabled == "true" ? 1 : 0}" + count = var.failed_jobs_rate_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] IOT Hub Too many jobs failed {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.failed_jobs_rate_message, var.message)}" + message = coalesce(var.failed_jobs_rate_message, var.message) + type = "query alert" query = < ${var.failed_jobs_rate_threshold_critical} - EOQ +EOQ - type = "query alert" - - thresholds { - warning = "${var.failed_jobs_rate_threshold_warning}" - critical = "${var.failed_jobs_rate_threshold_critical}" + thresholds = { + warning = var.failed_jobs_rate_threshold_warning + critical = var.failed_jobs_rate_threshold_critical } - notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - renotify_interval = 0 - notify_audit = false - timeout_h = 1 - include_tags = true - locked = false + notify_no_data = false + evaluation_delay = var.evaluation_delay + renotify_interval = 0 + notify_audit = false + timeout_h = 1 + include_tags = true + locked = false require_full_window = false - new_host_delay = "${var.new_host_delay}" + new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:iothubs", "team:claranet", "created-by:terraform", "${var.failed_jobs_rate_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:iothubs", "team:claranet", "created-by:terraform", var.failed_jobs_rate_extra_tags] } resource "datadog_monitor" "too_many_list_jobs_failed" { - count = "${var.failed_listjobs_rate_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] IOT Hub Too many list_jobs failure {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.failed_listjobs_rate_message, var.message)}" + count = var.failed_listjobs_rate_enabled == "true" ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] IOT Hub Too many list_jobs failure {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" + message = coalesce(var.failed_listjobs_rate_message, var.message) + type = "query alert" query = < ${var.failed_listjobs_rate_threshold_critical} - EOQ +EOQ - type = "query alert" +thresholds = { +warning = var.failed_listjobs_rate_threshold_warning +critical = var.failed_listjobs_rate_threshold_critical +} - thresholds { - warning = "${var.failed_listjobs_rate_threshold_warning}" - critical = "${var.failed_listjobs_rate_threshold_critical}" - } +notify_no_data = false +evaluation_delay = var.evaluation_delay +renotify_interval = 0 +notify_audit = false +timeout_h = 1 +include_tags = true +locked = false +require_full_window = false +new_host_delay = var.new_host_delay - notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - renotify_interval = 0 - notify_audit = false - timeout_h = 1 - include_tags = true - locked = false - require_full_window = false - new_host_delay = "${var.new_host_delay}" - - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:iothubs", "team:claranet", "created-by:terraform", "${var.failed_listjobs_rate_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:iothubs", "team:claranet", "created-by:terraform", var.failed_listjobs_rate_extra_tags] } resource "datadog_monitor" "too_many_query_jobs_failed" { - count = "${var.failed_queryjobs_rate_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] IOT Hub Too many query_jobs failed {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.failed_queryjobs_rate_message, var.message)}" +count = var.failed_queryjobs_rate_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] IOT Hub Too many query_jobs failed {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +message = coalesce(var.failed_queryjobs_rate_message, var.message) + type = "query alert" - query = < ${var.failed_queryjobs_rate_threshold_critical} - EOQ +EOQ - type = "query alert" +thresholds = { +warning = var.failed_queryjobs_rate_threshold_warning +critical = var.failed_queryjobs_rate_threshold_critical +} - thresholds { - warning = "${var.failed_queryjobs_rate_threshold_warning}" - critical = "${var.failed_queryjobs_rate_threshold_critical}" - } +notify_no_data = false +evaluation_delay = var.evaluation_delay +renotify_interval = 0 +notify_audit = false +timeout_h = 1 +include_tags = true +locked = false +require_full_window = false +new_host_delay = var.new_host_delay - notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - renotify_interval = 0 - notify_audit = false - timeout_h = 1 - include_tags = true - locked = false - require_full_window = false - new_host_delay = "${var.new_host_delay}" - - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:iothubs", "team:claranet", "created-by:terraform", "${var.failed_queryjobs_rate_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:iothubs", "team:claranet", "created-by:terraform", var.failed_queryjobs_rate_extra_tags] } resource "datadog_monitor" "status" { - count = "${var.status_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] IOT Hub is down" - message = "${coalesce(var.status_message, var.message)}" +count = var.status_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] IOT Hub is down" +message = coalesce(var.status_message, var.message) + type = "query alert" - query = < ${var.failed_c2d_methods_rate_threshold_critical} - EOQ +EOQ - type = "query alert" +thresholds = { +warning = var.failed_c2d_methods_rate_threshold_warning +critical = var.failed_c2d_methods_rate_threshold_critical +} - thresholds { - warning = "${var.failed_c2d_methods_rate_threshold_warning}" - critical = "${var.failed_c2d_methods_rate_threshold_critical}" - } +notify_no_data = false +evaluation_delay = var.evaluation_delay +renotify_interval = 0 +notify_audit = false +timeout_h = 1 +include_tags = true +locked = false +require_full_window = false +new_host_delay = var.new_host_delay - notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - renotify_interval = 0 - notify_audit = false - timeout_h = 1 - include_tags = true - locked = false - require_full_window = false - new_host_delay = "${var.new_host_delay}" - - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:iothubs", "team:claranet", "created-by:terraform", "${var.failed_c2d_methods_rate_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:iothubs", "team:claranet", "created-by:terraform", var.failed_c2d_methods_rate_extra_tags] } resource "datadog_monitor" "too_many_c2d_twin_read_failed" { - count = "${var.failed_c2d_twin_read_rate_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] IOT Hub Too many c2d twin read failure {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.failed_c2d_twin_read_rate_message, var.message)}" +count = var.failed_c2d_twin_read_rate_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] IOT Hub Too many c2d twin read failure {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +message = coalesce(var.failed_c2d_twin_read_rate_message, var.message) + type = "query alert" - query = < ${var.failed_c2d_twin_read_rate_threshold_critical} - EOQ +EOQ - type = "query alert" +thresholds = { +warning = var.failed_c2d_twin_read_rate_threshold_warning +critical = var.failed_c2d_twin_read_rate_threshold_critical +} - thresholds { - warning = "${var.failed_c2d_twin_read_rate_threshold_warning}" - critical = "${var.failed_c2d_twin_read_rate_threshold_critical}" - } +notify_no_data = false +evaluation_delay = var.evaluation_delay +renotify_interval = 0 +notify_audit = false +timeout_h = 1 +include_tags = true +locked = false +require_full_window = false +new_host_delay = var.new_host_delay - notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - renotify_interval = 0 - notify_audit = false - timeout_h = 1 - include_tags = true - locked = false - require_full_window = false - new_host_delay = "${var.new_host_delay}" - - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:iothubs", "team:claranet", "created-by:terraform", "${var.failed_c2d_twin_read_rate_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:iothubs", "team:claranet", "created-by:terraform", var.failed_c2d_twin_read_rate_extra_tags] } resource "datadog_monitor" "too_many_c2d_twin_update_failed" { - count = "${var.failed_c2d_twin_update_rate_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] IOT Hub Too many c2d twin update failure {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.failed_c2d_twin_update_rate_message, var.message)}" +count = var.failed_c2d_twin_update_rate_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] IOT Hub Too many c2d twin update failure {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +message = coalesce(var.failed_c2d_twin_update_rate_message, var.message) + type = "query alert" - query = < ${var.failed_c2d_twin_update_rate_threshold_critical} - EOQ +EOQ - type = "query alert" - - thresholds { - warning = "${var.failed_c2d_twin_update_rate_threshold_warning}" - critical = "${var.failed_c2d_twin_update_rate_threshold_critical}" + thresholds = { + warning = var.failed_c2d_twin_update_rate_threshold_warning + critical = var.failed_c2d_twin_update_rate_threshold_critical } notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" + evaluation_delay = var.evaluation_delay renotify_interval = 0 notify_audit = false timeout_h = 1 include_tags = true locked = false require_full_window = false - new_host_delay = "${var.new_host_delay}" + new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:iothubs", "team:claranet", "created-by:terraform", "${var.failed_c2d_twin_update_rate_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:iothubs", "team:claranet", "created-by:terraform", var.failed_c2d_twin_update_rate_extra_tags] } resource "datadog_monitor" "too_many_d2c_twin_read_failed" { - count = "${var.failed_d2c_twin_read_rate_enabled == "true" ? 1 : 0}" + count = var.failed_d2c_twin_read_rate_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] IOT Hub Too many d2c twin read failure {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.failed_d2c_twin_read_rate_message, var.message)}" + message = coalesce(var.failed_d2c_twin_read_rate_message, var.message) + type = "query alert" query = < ${var.failed_d2c_twin_read_rate_threshold_critical} - EOQ +EOQ - type = "query alert" - - thresholds { - warning = "${var.failed_d2c_twin_read_rate_threshold_warning}" - critical = "${var.failed_d2c_twin_read_rate_threshold_critical}" + thresholds = { + warning = var.failed_d2c_twin_read_rate_threshold_warning + critical = var.failed_d2c_twin_read_rate_threshold_critical } - notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - renotify_interval = 0 - notify_audit = false - timeout_h = 1 - include_tags = true - locked = false + notify_no_data = false + evaluation_delay = var.evaluation_delay + renotify_interval = 0 + notify_audit = false + timeout_h = 1 + include_tags = true + locked = false require_full_window = false - new_host_delay = "${var.new_host_delay}" + new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:iothubs", "team:claranet", "created-by:terraform", "${var.failed_d2c_twin_read_rate_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:iothubs", "team:claranet", "created-by:terraform", var.failed_d2c_twin_read_rate_extra_tags] } resource "datadog_monitor" "too_many_d2c_twin_update_failed" { - count = "${var.failed_d2c_twin_update_rate_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] IOT Hub Too many d2c twin update failure {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.failed_d2c_twin_update_rate_message, var.message)}" + count = var.failed_d2c_twin_update_rate_enabled == "true" ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] IOT Hub Too many d2c twin update failure {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" + message = coalesce(var.failed_d2c_twin_update_rate_message, var.message) + type = "query alert" query = < ${var.failed_d2c_twin_update_rate_threshold_critical} - EOQ +EOQ - type = "query alert" +thresholds = { +warning = var.failed_d2c_twin_update_rate_threshold_warning +critical = var.failed_d2c_twin_update_rate_threshold_critical +} - thresholds { - warning = "${var.failed_d2c_twin_update_rate_threshold_warning}" - critical = "${var.failed_d2c_twin_update_rate_threshold_critical}" - } +notify_no_data = false +evaluation_delay = var.evaluation_delay +renotify_interval = 0 +notify_audit = false +timeout_h = 1 +include_tags = true +locked = false +require_full_window = false +new_host_delay = var.new_host_delay - notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - renotify_interval = 0 - notify_audit = false - timeout_h = 1 - include_tags = true - locked = false - require_full_window = false - new_host_delay = "${var.new_host_delay}" - - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:iothubs", "team:claranet", "created-by:terraform", "${var.failed_d2c_twin_update_rate_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:iothubs", "team:claranet", "created-by:terraform", var.failed_d2c_twin_update_rate_extra_tags] } resource "datadog_monitor" "too_many_d2c_telemetry_egress_dropped" { - count = "${var.dropped_d2c_telemetry_egress_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] IOT Hub Too many d2c telemetry egress dropped {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}" - message = "${coalesce(var.dropped_d2c_telemetry_egress_message, var.message)}" +count = var.dropped_d2c_telemetry_egress_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] IOT Hub Too many d2c telemetry egress dropped {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}" +message = coalesce(var.dropped_d2c_telemetry_egress_message, var.message) + type = "query alert" - query = < ${var.dropped_d2c_telemetry_egress_rate_threshold_critical} - EOQ +EOQ - type = "query alert" +thresholds = { +warning = var.dropped_d2c_telemetry_egress_rate_threshold_warning +critical = var.dropped_d2c_telemetry_egress_rate_threshold_critical +} - thresholds { - warning = "${var.dropped_d2c_telemetry_egress_rate_threshold_warning}" - critical = "${var.dropped_d2c_telemetry_egress_rate_threshold_critical}" - } +notify_no_data = false +evaluation_delay = var.evaluation_delay +renotify_interval = 0 +notify_audit = false +timeout_h = 1 +include_tags = true +locked = false +require_full_window = false +new_host_delay = var.new_host_delay - notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - renotify_interval = 0 - notify_audit = false - timeout_h = 1 - include_tags = true - locked = false - require_full_window = false - new_host_delay = "${var.new_host_delay}" - - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:iothubs", "team:claranet", "created-by:terraform", "${var.dropped_d2c_telemetry_egress_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:iothubs", "team:claranet", "created-by:terraform", var.dropped_d2c_telemetry_egress_extra_tags] } resource "datadog_monitor" "too_many_d2c_telemetry_egress_orphaned" { - count = "${var.orphaned_d2c_telemetry_egress_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] IOT Hub Too many d2c telemetry egress orphaned {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}" - message = "${coalesce(var.orphaned_d2c_telemetry_egress_message, var.message)}" +count = var.orphaned_d2c_telemetry_egress_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] IOT Hub Too many d2c telemetry egress orphaned {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}" +message = coalesce(var.orphaned_d2c_telemetry_egress_message, var.message) + type = "query alert" - query = < ${var.orphaned_d2c_telemetry_egress_rate_threshold_critical} - EOQ +EOQ - type = "query alert" - - thresholds { - warning = "${var.orphaned_d2c_telemetry_egress_rate_threshold_warning}" - critical = "${var.orphaned_d2c_telemetry_egress_rate_threshold_critical}" + thresholds = { + warning = var.orphaned_d2c_telemetry_egress_rate_threshold_warning + critical = var.orphaned_d2c_telemetry_egress_rate_threshold_critical } notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" + evaluation_delay = var.evaluation_delay renotify_interval = 0 notify_audit = false timeout_h = 1 include_tags = true locked = false require_full_window = false - new_host_delay = "${var.new_host_delay}" + new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:iothubs", "team:claranet", "created-by:terraform", "${var.orphaned_d2c_telemetry_egress_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:iothubs", "team:claranet", "created-by:terraform", var.orphaned_d2c_telemetry_egress_extra_tags] } resource "datadog_monitor" "too_many_d2c_telemetry_egress_invalid" { - count = "${var.invalid_d2c_telemetry_egress_enabled == "true" ? 1 : 0}" + count = var.invalid_d2c_telemetry_egress_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] IOT Hub Too many d2c telemetry egress invalid {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}" - message = "${coalesce(var.invalid_d2c_telemetry_egress_message, var.message)}" + message = coalesce(var.invalid_d2c_telemetry_egress_message, var.message) + type = "query alert" query = < ${var.invalid_d2c_telemetry_egress_rate_threshold_critical} - EOQ +EOQ - type = "query alert" - - thresholds { - warning = "${var.invalid_d2c_telemetry_egress_rate_threshold_warning}" - critical = "${var.invalid_d2c_telemetry_egress_rate_threshold_critical}" + thresholds = { + warning = var.invalid_d2c_telemetry_egress_rate_threshold_warning + critical = var.invalid_d2c_telemetry_egress_rate_threshold_critical } - notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - renotify_interval = 0 - notify_audit = false - timeout_h = 1 - include_tags = true - locked = false + notify_no_data = false + evaluation_delay = var.evaluation_delay + renotify_interval = 0 + notify_audit = false + timeout_h = 1 + include_tags = true + locked = false require_full_window = false - new_host_delay = "${var.new_host_delay}" + new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:iothubs", "team:claranet", "created-by:terraform", "${var.invalid_d2c_telemetry_egress_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:iothubs", "team:claranet", "created-by:terraform", var.invalid_d2c_telemetry_egress_extra_tags] } resource "datadog_monitor" "too_many_d2c_telemetry_ingress_nosent" { - count = "${var.too_many_d2c_telemetry_ingress_nosent_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] IOT Hub Too many d2c telemetry ingress not sent {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}" - message = "${coalesce(var.too_many_d2c_telemetry_ingress_nosent_message, var.message)}" + count = var.too_many_d2c_telemetry_ingress_nosent_enabled == "true" ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] IOT Hub Too many d2c telemetry ingress not sent {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}" + message = coalesce(var.too_many_d2c_telemetry_ingress_nosent_message,var.message) + type = "query alert" query = < 0 - EOQ +EOQ - type = "query alert" +notify_no_data = false +evaluation_delay = var.evaluation_delay +renotify_interval = 0 +notify_audit = false +timeout_h = 1 +include_tags = true +locked = false +require_full_window = false +new_host_delay = var.new_host_delay - notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - renotify_interval = 0 - notify_audit = false - timeout_h = 1 - include_tags = true - locked = false - require_full_window = false - new_host_delay = "${var.new_host_delay}" - - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:iothubs", "team:claranet", "created-by:terraform", "${var.too_many_d2c_telemetry_ingress_nosent_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:iothubs", "team:claranet", "created-by:terraform", var.too_many_d2c_telemetry_ingress_nosent_extra_tags] } + diff --git a/cloud/azure/iothubs/outputs.tf b/cloud/azure/iothubs/outputs.tf index 95c7cc0..5107ffc 100644 --- a/cloud/azure/iothubs/outputs.tf +++ b/cloud/azure/iothubs/outputs.tf @@ -1,69 +1,70 @@ output "too_many_jobs_failed_id" { description = "id for monitor too_many_jobs_failed" - value = "${datadog_monitor.too_many_jobs_failed.*.id}" + value = datadog_monitor.too_many_jobs_failed.*.id } output "too_many_list_jobs_failed_id" { description = "id for monitor too_many_list_jobs_failed" - value = "${datadog_monitor.too_many_list_jobs_failed.*.id}" + value = datadog_monitor.too_many_list_jobs_failed.*.id } output "too_many_query_jobs_failed_id" { description = "id for monitor too_many_query_jobs_failed" - value = "${datadog_monitor.too_many_query_jobs_failed.*.id}" + value = datadog_monitor.too_many_query_jobs_failed.*.id } output "status_id" { description = "id for monitor status" - value = "${datadog_monitor.status.*.id}" + value = datadog_monitor.status.*.id } output "total_devices_id" { description = "id for monitor total_devices" - value = "${datadog_monitor.total_devices.*.id}" + value = datadog_monitor.total_devices.*.id } output "too_many_c2d_methods_failed_id" { description = "id for monitor too_many_c2d_methods_failed" - value = "${datadog_monitor.too_many_c2d_methods_failed.*.id}" + value = datadog_monitor.too_many_c2d_methods_failed.*.id } output "too_many_c2d_twin_read_failed_id" { description = "id for monitor too_many_c2d_twin_read_failed" - value = "${datadog_monitor.too_many_c2d_twin_read_failed.*.id}" + value = datadog_monitor.too_many_c2d_twin_read_failed.*.id } output "too_many_c2d_twin_update_failed_id" { description = "id for monitor too_many_c2d_twin_update_failed" - value = "${datadog_monitor.too_many_c2d_twin_update_failed.*.id}" + value = datadog_monitor.too_many_c2d_twin_update_failed.*.id } output "too_many_d2c_twin_read_failed_id" { description = "id for monitor too_many_d2c_twin_read_failed" - value = "${datadog_monitor.too_many_d2c_twin_read_failed.*.id}" + value = datadog_monitor.too_many_d2c_twin_read_failed.*.id } output "too_many_d2c_twin_update_failed_id" { description = "id for monitor too_many_d2c_twin_update_failed" - value = "${datadog_monitor.too_many_d2c_twin_update_failed.*.id}" + value = datadog_monitor.too_many_d2c_twin_update_failed.*.id } output "too_many_d2c_telemetry_egress_dropped_id" { description = "id for monitor too_many_d2c_telemetry_egress_dropped" - value = "${datadog_monitor.too_many_d2c_telemetry_egress_dropped.*.id}" + value = datadog_monitor.too_many_d2c_telemetry_egress_dropped.*.id } output "too_many_d2c_telemetry_egress_orphaned_id" { description = "id for monitor too_many_d2c_telemetry_egress_orphaned" - value = "${datadog_monitor.too_many_d2c_telemetry_egress_orphaned.*.id}" + value = datadog_monitor.too_many_d2c_telemetry_egress_orphaned.*.id } output "too_many_d2c_telemetry_egress_invalid_id" { description = "id for monitor too_many_d2c_telemetry_egress_invalid" - value = "${datadog_monitor.too_many_d2c_telemetry_egress_invalid.*.id}" + value = datadog_monitor.too_many_d2c_telemetry_egress_invalid.*.id } output "too_many_d2c_telemetry_ingress_nosent_id" { description = "id for monitor too_many_d2c_telemetry_ingress_nosent" - value = "${datadog_monitor.too_many_d2c_telemetry_ingress_nosent.*.id}" + value = datadog_monitor.too_many_d2c_telemetry_ingress_nosent.*.id } + diff --git a/cloud/azure/iothubs/versions.tf b/cloud/azure/iothubs/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/cloud/azure/iothubs/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/cloud/azure/keyvault/inputs.tf b/cloud/azure/keyvault/inputs.tf index 86775cf..15a0040 100644 --- a/cloud/azure/keyvault/inputs.tf +++ b/cloud/azure/keyvault/inputs.tf @@ -1,6 +1,6 @@ variable "environment" { description = "Architecture environment" - type = "string" + type = string } variable "filter_tags_use_defaults" { @@ -40,19 +40,19 @@ variable "prefix_slug" { # Azure Key Vault specific variables variable "status_enabled" { description = "Flag to enable Key Vault status monitor" - type = "string" + type = string default = "true" } variable "status_message" { description = "Custom message for Key Vault status monitor" - type = "string" + type = string default = "" } variable "status_time_aggregator" { description = "Monitor aggregator for Key Vault status [available values: min, max or avg]" - type = "string" + type = string default = "max" } @@ -63,25 +63,25 @@ variable "status_timeframe" { variable "status_extra_tags" { description = "Extra tags for Key Vault status monitor" - type = "list" + type = list(string) default = [] } variable "api_result_enabled" { description = "Flag to enable Key Vault API result monitor" - type = "string" + type = string default = "true" } variable "api_result_message" { description = "Custom message for Key Vault API result monitor" - type = "string" + type = string default = "" } variable "api_result_time_aggregator" { description = "Monitor aggregator for Key Vault API result [available values: min, max or avg]" - type = "string" + type = string default = "max" } @@ -102,25 +102,25 @@ variable "api_result_threshold_warning" { variable "api_result_extra_tags" { description = "Extra tags for Key Vault API result monitor" - type = "list" + type = list(string) default = [] } variable "api_latency_enabled" { description = "Flag to enable Key Vault API latency monitor" - type = "string" + type = string default = "true" } variable "api_latency_message" { description = "Custom message for Key Vault API latency monitor" - type = "string" + type = string default = "" } variable "api_latency_time_aggregator" { description = "Monitor aggregator for Key Vault API latency [available values: min, max or avg]" - type = "string" + type = string default = "min" } @@ -141,6 +141,7 @@ variable "api_latency_threshold_warning" { variable "api_latency_extra_tags" { description = "Extra tags for Key Vault API latency monitor" - type = "list" + type = list(string) default = [] } + diff --git a/cloud/azure/keyvault/modules.tf b/cloud/azure/keyvault/modules.tf index 6e6f876..9fd2ab3 100644 --- a/cloud/azure/keyvault/modules.tf +++ b/cloud/azure/keyvault/modules.tf @@ -1,31 +1,32 @@ module "filter-tags" { source = "../../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "azure_keyvault" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded } module "filter-tags-statuscode" { source = "../../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "azure_keyvault" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded extra_tags = ["statuscode:%s"] } module "filter-tags-activity" { source = "../../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "azure_keyvault" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded extra_tags_excluded = ["activityname:secretlist"] } + diff --git a/cloud/azure/keyvault/monitors-keyvault.tf b/cloud/azure/keyvault/monitors-keyvault.tf index 6005b71..aabad04 100644 --- a/cloud/azure/keyvault/monitors-keyvault.tf +++ b/cloud/azure/keyvault/monitors-keyvault.tf @@ -1,35 +1,33 @@ resource "datadog_monitor" "keyvault_status" { - count = "${var.status_enabled == "true" ? 1 : 0}" - + count = var.status_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Key Vault is down" - message = "${coalesce(var.status_message, var.message)}" + message = coalesce(var.status_message, var.message) + type = "query alert" query = < ${var.api_latency_threshold_critical} - EOQ +EOQ - thresholds { - critical = "${var.api_latency_threshold_critical}" - warning = "${var.api_latency_threshold_warning}" - } - - type = "metric alert" - - 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:azure", "resource:keyvault", "team:claranet", "created-by:terraform", "${var.api_latency_extra_tags}"] +thresholds = { +critical = var.api_latency_threshold_critical +warning = var.api_latency_threshold_warning } + +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:azure", "resource:keyvault", "team:claranet", "created-by:terraform", var.api_latency_extra_tags] +} + diff --git a/cloud/azure/keyvault/outputs.tf b/cloud/azure/keyvault/outputs.tf index a6a4ca0..91b5d99 100644 --- a/cloud/azure/keyvault/outputs.tf +++ b/cloud/azure/keyvault/outputs.tf @@ -1,14 +1,15 @@ output "keyvault_status_id" { description = "id for monitor keyvault_status" - value = "${datadog_monitor.keyvault_status.*.id}" + value = datadog_monitor.keyvault_status.*.id } output "keyvault_api_result_id" { description = "id for monitor keyvault_api_result" - value = "${datadog_monitor.keyvault_api_result.*.id}" + value = datadog_monitor.keyvault_api_result.*.id } output "keyvault_api_latency_id" { description = "id for monitor keyvault_api_latency" - value = "${datadog_monitor.keyvault_api_latency.*.id}" + value = datadog_monitor.keyvault_api_latency.*.id } + diff --git a/cloud/azure/keyvault/versions.tf b/cloud/azure/keyvault/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/cloud/azure/keyvault/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/cloud/azure/load-balancer/inputs.tf b/cloud/azure/load-balancer/inputs.tf index 8e99ec8..9707a46 100644 --- a/cloud/azure/load-balancer/inputs.tf +++ b/cloud/azure/load-balancer/inputs.tf @@ -1,6 +1,6 @@ variable "environment" { description = "Architecture environment" - type = "string" + type = string } variable "filter_tags_use_defaults" { @@ -40,19 +40,19 @@ variable "prefix_slug" { # Azure Load Balancer specific variables variable "status_enabled" { description = "Flag to enable Load Balancer status monitor" - type = "string" + type = string default = "true" } variable "status_message" { description = "Custom message for Load Balancer status monitor" - type = "string" + type = string default = "" } variable "status_time_aggregator" { description = "Monitor aggregator for Load Balancer status [available values: min, max or avg]" - type = "string" + type = string default = "max" } @@ -63,6 +63,7 @@ variable "status_timeframe" { variable "status_extra_tags" { description = "Extra tags for Load Balancer status monitor" - type = "list" + type = list(string) default = [] } + diff --git a/cloud/azure/load-balancer/modules.tf b/cloud/azure/load-balancer/modules.tf index 760e10f..d68393b 100644 --- a/cloud/azure/load-balancer/modules.tf +++ b/cloud/azure/load-balancer/modules.tf @@ -1,9 +1,10 @@ module "filter-tags" { source = "../../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "azure_load-balancer" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded } + diff --git a/cloud/azure/load-balancer/monitors-load-balancer.tf b/cloud/azure/load-balancer/monitors-load-balancer.tf index 45ede58..a67ab49 100644 --- a/cloud/azure/load-balancer/monitors-load-balancer.tf +++ b/cloud/azure/load-balancer/monitors-load-balancer.tf @@ -1,26 +1,25 @@ resource "datadog_monitor" "loadbalancer_status" { - count = "${var.status_enabled == "true" ? 1 : 0}" - + count = var.status_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Load Balancer is unreachable" - message = "${coalesce(var.status_message, var.message)}" + message = coalesce(var.status_message, var.message) + type = "query alert" query = < ${var.cpu_usage_threshold_critical} - EOQ +EOQ - type = "query alert" - - thresholds { - critical = "${var.cpu_usage_threshold_critical}" - warning = "${var.cpu_usage_threshold_warning}" + thresholds = { + critical = var.cpu_usage_threshold_critical + warning = var.cpu_usage_threshold_warning } - notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - renotify_interval = 0 - notify_audit = false - timeout_h = 0 - include_tags = true - locked = false + 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}" + new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:mysql", "team:claranet", "created-by:terraform", "${var.cpu_usage_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:mysql", "team:claranet", "created-by:terraform", var.cpu_usage_extra_tags] } resource "datadog_monitor" "mysql_free_storage" { - count = "${var.free_storage_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Mysql Server storage {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.free_storage_message, var.message)}" + count = var.free_storage_enabled == "true" ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Mysql Server storage {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" + message = coalesce(var.free_storage_message, var.message) + type = "query alert" query = < ${var.io_consumption_threshold_critical} - EOQ +EOQ - type = "query alert" +thresholds = { +critical = var.io_consumption_threshold_critical +warning = var.io_consumption_threshold_warning +} - thresholds { - critical = "${var.io_consumption_threshold_critical}" - warning = "${var.io_consumption_threshold_warning}" - } +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 - 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:azure", "resource:mysql", "team:claranet", "created-by:terraform", "${var.io_consumption_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:mysql", "team:claranet", "created-by:terraform", var.io_consumption_extra_tags] } resource "datadog_monitor" "mysql_memory_usage" { - count = "${var.memory_usage_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Mysql Server memory usage {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.memory_usage_message, var.message)}" +count = var.memory_usage_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Mysql Server memory usage {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +message = coalesce(var.memory_usage_message, var.message) + type = "query alert" - query = < ${var.memory_usage_threshold_critical} - EOQ +EOQ - type = "query alert" - - thresholds { - critical = "${var.memory_usage_threshold_critical}" - warning = "${var.memory_usage_threshold_warning}" + thresholds = { + critical = var.memory_usage_threshold_critical + warning = var.memory_usage_threshold_warning } notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" + 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}" + new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:mysql", "team:claranet", "created-by:terraform", "${var.memory_usage_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:mysql", "team:claranet", "created-by:terraform", var.memory_usage_extra_tags] } + diff --git a/cloud/azure/mysql/outputs.tf b/cloud/azure/mysql/outputs.tf index 3b22ff3..ace5b8a 100644 --- a/cloud/azure/mysql/outputs.tf +++ b/cloud/azure/mysql/outputs.tf @@ -1,19 +1,20 @@ output "mysql_cpu_usage_id" { description = "id for monitor mysql_cpu_usage" - value = "${datadog_monitor.mysql_cpu_usage.*.id}" + value = datadog_monitor.mysql_cpu_usage.*.id } output "mysql_free_storage_id" { description = "id for monitor mysql_free_storage" - value = "${datadog_monitor.mysql_free_storage.*.id}" + value = datadog_monitor.mysql_free_storage.*.id } output "mysql_io_consumption_id" { description = "id for monitor mysql_io_consumption" - value = "${datadog_monitor.mysql_io_consumption.*.id}" + value = datadog_monitor.mysql_io_consumption.*.id } output "mysql_memory_usage_id" { description = "id for monitor mysql_memory_usage" - value = "${datadog_monitor.mysql_memory_usage.*.id}" + value = datadog_monitor.mysql_memory_usage.*.id } + diff --git a/cloud/azure/mysql/versions.tf b/cloud/azure/mysql/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/cloud/azure/mysql/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/cloud/azure/postgresql/inputs.tf b/cloud/azure/postgresql/inputs.tf index 137e1b2..38f779a 100644 --- a/cloud/azure/postgresql/inputs.tf +++ b/cloud/azure/postgresql/inputs.tf @@ -1,7 +1,7 @@ # Global Terraform variable "environment" { description = "Architecture environment" - type = "string" + type = string } # Global DataDog @@ -38,31 +38,31 @@ variable "filter_tags_custom" { variable "cpu_usage_enabled" { description = "Flag to enable PostgreSQL status monitor" - type = "string" + type = string default = "true" } variable "cpu_usage_extra_tags" { description = "Extra tags for PostgreSQL status monitor" - type = "list" + type = list(string) default = [] } variable "cpu_usage_message" { description = "Custom message for PostgreSQL CPU monitor" - type = "string" + type = string default = "" } variable "cpu_usage_time_aggregator" { description = "Monitor aggregator for PostgreSQL CPU [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "cpu_usage_timeframe" { description = "Monitor timeframe for PostgreSQL CPU [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_15m" } @@ -78,61 +78,61 @@ variable "cpu_usage_threshold_critical" { variable "no_connection_enabled" { description = "Flag to enable PostgreSQL status monitor" - type = "string" + type = string default = "true" } variable "no_connection_extra_tags" { description = "Extra tags for PostgreSQL status monitor" - type = "list" + type = list(string) default = [] } variable "no_connection_message" { description = "Custom message for PostgreSQL no connection monitor" - type = "string" + type = string default = "" } variable "no_connection_time_aggregator" { description = "Monitor aggregator for PostgreSQL no connection [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "no_connection_timeframe" { description = "Monitor timeframe for PostgreSQL no connection [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } variable "free_storage_enabled" { description = "Flag to enable PostgreSQL status monitor" - type = "string" + type = string default = "true" } variable "free_storage_extra_tags" { description = "Extra tags for PostgreSQL status monitor" - type = "list" + type = list(string) default = [] } variable "free_storage_message" { description = "Custom message for PostgreSQL Free Storage monitor" - type = "string" + type = string default = "" } variable "free_storage_time_aggregator" { description = "Monitor aggregator for PostgreSQL Free Storage [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "free_storage_timeframe" { description = "Monitor timeframe for PostgreSQL Free Storage [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_15m" } @@ -148,31 +148,31 @@ variable "free_storage_threshold_critical" { variable "io_consumption_enabled" { description = "Flag to enable PostgreSQL status monitor" - type = "string" + type = string default = "true" } variable "io_consumption_extra_tags" { description = "Extra tags for PostgreSQL status monitor" - type = "list" + type = list(string) default = [] } variable "io_consumption_message" { description = "Custom message for PostgreSQL IO consumption monitor" - type = "string" + type = string default = "" } variable "io_consumption_time_aggregator" { description = "Monitor aggregator for PostgreSQL IO consumption [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "io_consumption_timeframe" { description = "Monitor timeframe for PostgreSQL IO consumption [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_15m" } @@ -188,31 +188,31 @@ variable "io_consumption_threshold_critical" { variable "memory_usage_enabled" { description = "Flag to enable PostgreSQL status monitor" - type = "string" + type = string default = "true" } variable "memory_usage_extra_tags" { description = "Extra tags for PostgreSQL status monitor" - type = "list" + type = list(string) default = [] } variable "memory_usage_message" { description = "Custom message for PostgreSQL memory monitor" - type = "string" + type = string default = "" } variable "memory_usage_time_aggregator" { description = "Monitor aggregator for PostgreSQL memory [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "memory_usage_timeframe" { description = "Monitor timeframe for PostgreSQL memory [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_15m" } @@ -225,3 +225,4 @@ variable "memory_usage_threshold_critical" { description = "PostgreSQL memory usage in percent (critical threshold)" default = "90" } + diff --git a/cloud/azure/postgresql/modules.tf b/cloud/azure/postgresql/modules.tf index 8183a7b..52a7f41 100644 --- a/cloud/azure/postgresql/modules.tf +++ b/cloud/azure/postgresql/modules.tf @@ -1,8 +1,9 @@ module "filter-tags" { source = "../../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "azure_postgresql" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom } + diff --git a/cloud/azure/postgresql/monitors-postegresql.tf b/cloud/azure/postgresql/monitors-postegresql.tf index 679278f..4c11d57 100644 --- a/cloud/azure/postgresql/monitors-postegresql.tf +++ b/cloud/azure/postgresql/monitors-postegresql.tf @@ -1,149 +1,146 @@ resource "datadog_monitor" "postgresql_cpu_usage" { - count = "${var.cpu_usage_enabled == "true" ? 1 : 0}" + count = var.cpu_usage_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Postgresql Server CPU usage {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.cpu_usage_message, var.message)}" + message = coalesce(var.cpu_usage_message, var.message) + type = "query alert" query = < ${var.cpu_usage_threshold_critical} - EOQ +EOQ - type = "query alert" - - thresholds { - critical = "${var.cpu_usage_threshold_critical}" - warning = "${var.cpu_usage_threshold_warning}" + thresholds = { + critical = var.cpu_usage_threshold_critical + warning = var.cpu_usage_threshold_warning } - notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - renotify_interval = 0 - notify_audit = false - timeout_h = 0 - include_tags = true - locked = false + 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}" + new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:postgresql", "team:claranet", "created-by:terraform", "${var.cpu_usage_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:postgresql", "team:claranet", "created-by:terraform", var.cpu_usage_extra_tags] } resource "datadog_monitor" "postgresql_no_connection" { - count = "${var.no_connection_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Postgresql Server has no connection" - message = "${coalesce(var.no_connection_message, var.message)}" + count = var.no_connection_enabled == "true" ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Postgresql Server has no connection" + message = coalesce(var.no_connection_message, var.message) + type = "query alert" query = < ${var.io_consumption_threshold_critical} - EOQ +EOQ - type = "query alert" - - thresholds { - critical = "${var.io_consumption_threshold_critical}" - warning = "${var.io_consumption_threshold_warning}" + thresholds = { + critical = var.io_consumption_threshold_critical + warning = var.io_consumption_threshold_warning } notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" + 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}" + new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:postgresql", "team:claranet", "created-by:terraform", "${var.io_consumption_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:postgresql", "team:claranet", "created-by:terraform", var.io_consumption_extra_tags] } resource "datadog_monitor" "postgresql_memory_usage" { - count = "${var.memory_usage_enabled == "true" ? 1 : 0}" + count = var.memory_usage_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Postgresql Server memory usage {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.memory_usage_message, var.message)}" + message = coalesce(var.memory_usage_message, var.message) + type = "query alert" query = < ${var.memory_usage_threshold_critical} - EOQ +EOQ - type = "query alert" - - thresholds { - critical = "${var.memory_usage_threshold_critical}" - warning = "${var.memory_usage_threshold_warning}" + thresholds = { + critical = var.memory_usage_threshold_critical + warning = var.memory_usage_threshold_warning } - notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - renotify_interval = 0 - notify_audit = false - timeout_h = 0 - include_tags = true - locked = false + 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}" + new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:postgresql", "team:claranet", "created-by:terraform", "${var.memory_usage_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:postgresql", "team:claranet", "created-by:terraform", var.memory_usage_extra_tags] } + diff --git a/cloud/azure/postgresql/outputs.tf b/cloud/azure/postgresql/outputs.tf index 52b8398..86e9d8b 100644 --- a/cloud/azure/postgresql/outputs.tf +++ b/cloud/azure/postgresql/outputs.tf @@ -1,24 +1,25 @@ output "postgresql_cpu_usage_id" { description = "id for monitor postgresql_cpu_usage" - value = "${datadog_monitor.postgresql_cpu_usage.*.id}" + value = datadog_monitor.postgresql_cpu_usage.*.id } output "postgresql_no_connection_id" { description = "id for monitor postgresql_no_connection" - value = "${datadog_monitor.postgresql_no_connection.*.id}" + value = datadog_monitor.postgresql_no_connection.*.id } output "postgresql_free_storage_id" { description = "id for monitor postgresql_free_storage" - value = "${datadog_monitor.postgresql_free_storage.*.id}" + value = datadog_monitor.postgresql_free_storage.*.id } output "postgresql_io_consumption_id" { description = "id for monitor postgresql_io_consumption" - value = "${datadog_monitor.postgresql_io_consumption.*.id}" + value = datadog_monitor.postgresql_io_consumption.*.id } output "postgresql_memory_usage_id" { description = "id for monitor postgresql_memory_usage" - value = "${datadog_monitor.postgresql_memory_usage.*.id}" + value = datadog_monitor.postgresql_memory_usage.*.id } + diff --git a/cloud/azure/postgresql/versions.tf b/cloud/azure/postgresql/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/cloud/azure/postgresql/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/cloud/azure/redis/inputs.tf b/cloud/azure/redis/inputs.tf index 7737430..0bb5758 100644 --- a/cloud/azure/redis/inputs.tf +++ b/cloud/azure/redis/inputs.tf @@ -1,7 +1,7 @@ # Global Terraform variable "environment" { description = "Architecture environment" - type = "string" + type = string } # Global DataDog @@ -43,61 +43,61 @@ variable "filter_tags_custom_excluded" { variable "status_enabled" { description = "Flag to enable Redis status monitor" - type = "string" + type = string default = "true" } variable "status_extra_tags" { description = "Extra tags for Redis status monitor" - type = "list" + type = list(string) default = [] } variable "status_message" { description = "Custom message for Redis status monitor" - type = "string" + type = string default = "" } variable "status_time_aggregator" { description = "Monitor aggregator for Redis status [available values: min, max or avg]" - type = "string" + type = string default = "max" } variable "status_timeframe" { description = "Monitor timeframe for Redis status [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } variable "evictedkeys_limit_enabled" { description = "Flag to enable Redis evicted keys monitor" - type = "string" + type = string default = "true" } variable "evictedkeys_limit_extra_tags" { description = "Extra tags for Redis evicted keys monitor" - type = "list" + type = list(string) default = [] } variable "evictedkeys_limit_message" { description = "Custom message for Redis evicted keys monitor" - type = "string" + type = string default = "" } variable "evictedkeys_limit_time_aggregator" { description = "Monitor aggregator for Redis evicted keys [available values: min, max or avg]" - type = "string" + type = string default = "avg" } variable "evictedkeys_limit_timeframe" { description = "Monitor timeframe for Redis evicted keys [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -113,31 +113,31 @@ variable "evictedkeys_limit_threshold_critical" { variable "percent_processor_time_enabled" { description = "Flag to enable Redis processor monitor" - type = "string" + type = string default = "true" } variable "percent_processor_time_extra_tags" { description = "Extra tags for Redis processor monitor" - type = "list" + type = list(string) default = [] } variable "percent_processor_time_message" { description = "Custom message for Redis processor monitor" - type = "string" + type = string default = "" } variable "percent_processor_time_time_aggregator" { description = "Monitor aggregator for Redis processor [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "percent_processor_time_timeframe" { description = "Monitor timeframe for Redis processor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -153,31 +153,31 @@ variable "percent_processor_time_threshold_warning" { variable "server_load_rate_enabled" { description = "Flag to enable Redis server load monitor" - type = "string" + type = string default = "true" } variable "server_load_rate_extra_tags" { description = "Extra tags for Redis server load monitor" - type = "list" + type = list(string) default = [] } variable "server_load_rate_message" { description = "Custom message for Redis server load monitor" - type = "string" + type = string default = "" } variable "server_load_rate_time_aggregator" { description = "Monitor aggregator for Redis server load [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "server_load_rate_timeframe" { description = "Monitor timeframe for Redis server load [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -190,3 +190,4 @@ variable "server_load_rate_threshold_warning" { description = "Server CPU load rate (warning threshold)" default = 70 } + diff --git a/cloud/azure/redis/modules.tf b/cloud/azure/redis/modules.tf index 8ffca7d..1c038f7 100644 --- a/cloud/azure/redis/modules.tf +++ b/cloud/azure/redis/modules.tf @@ -1,9 +1,10 @@ module "filter-tags" { source = "../../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "azure_redis" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded } + diff --git a/cloud/azure/redis/monitors-azure-redis.tf b/cloud/azure/redis/monitors-azure-redis.tf index fd38fc2..5e90fbe 100644 --- a/cloud/azure/redis/monitors-azure-redis.tf +++ b/cloud/azure/redis/monitors-azure-redis.tf @@ -1,118 +1,115 @@ resource "datadog_monitor" "status" { - count = "${var.status_enabled == "true" ? 1 : 0}" + count = var.status_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Redis {{name}} is down" - message = "${coalesce(var.status_message, var.message)}" + message = coalesce(var.status_message, var.message) + type = "query alert" query = < ${var.evictedkeys_limit_threshold_critical} - EOQ +EOQ - type = "query alert" +thresholds = { +warning = var.evictedkeys_limit_threshold_warning +critical = var.evictedkeys_limit_threshold_critical +} - thresholds { - warning = "${var.evictedkeys_limit_threshold_warning}" - critical = "${var.evictedkeys_limit_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 - 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:azure", "resource:redis", "team:claranet", "created-by:terraform", "${var.evictedkeys_limit_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:redis", "team:claranet", "created-by:terraform", var.evictedkeys_limit_extra_tags] } resource "datadog_monitor" "percent_processor_time" { - count = "${var.percent_processor_time_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Redis processor time too high {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.percent_processor_time_message, var.message)}" +count = var.percent_processor_time_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Redis processor time too high {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +message = coalesce(var.percent_processor_time_message, var.message) + type = "query alert" - query = < ${var.percent_processor_time_threshold_critical} - EOQ +EOQ - type = "query alert" +thresholds = { +warning = var.percent_processor_time_threshold_warning +critical = var.percent_processor_time_threshold_critical +} - thresholds { - warning = "${var.percent_processor_time_threshold_warning}" - critical = "${var.percent_processor_time_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 - 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:azure", "resource:redis", "team:claranet", "created-by:terraform", "${var.percent_processor_time_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:redis", "team:claranet", "created-by:terraform", var.percent_processor_time_extra_tags] } resource "datadog_monitor" "server_load" { - count = "${var.server_load_rate_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Redis server load too high {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.server_load_rate_message, var.message)}" +count = var.server_load_rate_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Redis server load too high {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +message = coalesce(var.server_load_rate_message, var.message) + type = "query alert" - query = < ${var.server_load_rate_threshold_critical} - EOQ +EOQ - type = "query alert" - - thresholds { - warning = "${var.server_load_rate_threshold_warning}" - critical = "${var.server_load_rate_threshold_critical}" + thresholds = { + warning = var.server_load_rate_threshold_warning + critical = var.server_load_rate_threshold_critical } notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" + 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}" + new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:redis", "team:claranet", "created-by:terraform", "${var.server_load_rate_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:redis", "team:claranet", "created-by:terraform", var.server_load_rate_extra_tags] } + diff --git a/cloud/azure/redis/outputs.tf b/cloud/azure/redis/outputs.tf index f3c64a1..b4c71da 100644 --- a/cloud/azure/redis/outputs.tf +++ b/cloud/azure/redis/outputs.tf @@ -1,19 +1,20 @@ output "status_id" { description = "id for monitor status" - value = "${datadog_monitor.status.*.id}" + value = datadog_monitor.status.*.id } output "evictedkeys_id" { description = "id for monitor evictedkeys" - value = "${datadog_monitor.evictedkeys.*.id}" + value = datadog_monitor.evictedkeys.*.id } output "percent_processor_time_id" { description = "id for monitor percent_processor_time" - value = "${datadog_monitor.percent_processor_time.*.id}" + value = datadog_monitor.percent_processor_time.*.id } output "server_load_id" { description = "id for monitor server_load" - value = "${datadog_monitor.server_load.*.id}" + value = datadog_monitor.server_load.*.id } + diff --git a/cloud/azure/redis/versions.tf b/cloud/azure/redis/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/cloud/azure/redis/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/cloud/azure/serverfarms/inputs.tf b/cloud/azure/serverfarms/inputs.tf index a3f5962..dfb2743 100644 --- a/cloud/azure/serverfarms/inputs.tf +++ b/cloud/azure/serverfarms/inputs.tf @@ -1,7 +1,7 @@ # Global Terraform variable "environment" { description = "Architecture environment" - type = "string" + type = string } # Global DataDog @@ -39,62 +39,62 @@ variable "filter_tags_custom" { # Status variable "status_enabled" { description = "Flag to enable the serverfarms status monitor" - type = "string" + type = string default = "true" } variable "status_message" { description = "Custom message for serverfarm status monitor" - type = "string" + type = string default = "" } variable "status_extra_tags" { description = "Extra tags for serverfarms status monitor" - type = "list" + type = list(string) default = [] } variable "status_time_aggregator" { description = "Monitor aggregator for serverfarms status [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "status_timeframe" { description = "Monitor timeframe for serverfarms status [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } # CPU percentage variable "cpu_percentage_enabled" { description = "Flag to enable the serverfarms cpu_percentage monitor" - type = "string" + type = string default = "true" } variable "cpu_percentage_message" { description = "Custom message for serverfarm cpu_percentage monitor" - type = "string" + type = string default = "" } variable "cpu_percentage_extra_tags" { description = "Extra tags for serverfarms cpu_percentage monitor" - type = "list" + type = list(string) default = [] } variable "cpu_percentage_time_aggregator" { description = "Monitor aggregator for serverfarms cpu_percentage [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "cpu_percentage_timeframe" { description = "Monitor timeframe for serverfarms cpu_percentage [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_10m" } @@ -111,31 +111,31 @@ variable "cpu_percentage_threshold_warning" { # Memory percentage variable "memory_percentage_enabled" { description = "Flag to enable the serverfarms memory_percentage monitor" - type = "string" + type = string default = "true" } variable "memory_percentage_message" { description = "Custom message for serverfarm memory_percentage monitor" - type = "string" + type = string default = "" } variable "memory_percentage_extra_tags" { description = "Extra tags for serverfarms memory_percentage monitor" - type = "list" + type = list(string) default = [] } variable "memory_percentage_time_aggregator" { description = "Monitor aggregator for serverfarms memory_percentage [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "memory_percentage_timeframe" { description = "Monitor timeframe for serverfarms memory_percentage [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -148,3 +148,4 @@ variable "memory_percentage_threshold_warning" { description = "Memory percentage (warning threshold)" default = 90 } + diff --git a/cloud/azure/serverfarms/modules.tf b/cloud/azure/serverfarms/modules.tf index 96acfda..ed11dfa 100644 --- a/cloud/azure/serverfarms/modules.tf +++ b/cloud/azure/serverfarms/modules.tf @@ -1,8 +1,9 @@ module "filter-tags" { source = "../../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "azure_serverfarms" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom } + diff --git a/cloud/azure/serverfarms/monitors-azure-serverfarms.tf b/cloud/azure/serverfarms/monitors-azure-serverfarms.tf index 1dccf59..bd492f6 100644 --- a/cloud/azure/serverfarms/monitors-azure-serverfarms.tf +++ b/cloud/azure/serverfarms/monitors-azure-serverfarms.tf @@ -1,87 +1,85 @@ resource "datadog_monitor" "status" { - count = "${var.status_enabled == "true" ? 1 : 0}" + count = var.status_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Serverfarm is down" - message = "${coalesce(var.status_message, var.message)}" + message = coalesce(var.status_message, var.message) + type = "query alert" query = < ${var.cpu_percentage_threshold_critical} - EOQ +EOQ - type = "query alert" +thresholds = { +warning = var.cpu_percentage_threshold_warning +critical = var.cpu_percentage_threshold_critical +} - thresholds { - warning = "${var.cpu_percentage_threshold_warning}" - critical = "${var.cpu_percentage_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 - 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:azure", "resource:serverfarms", "team:claranet", "created-by:terraform", "${var.cpu_percentage_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:serverfarms", "team:claranet", "created-by:terraform", var.cpu_percentage_extra_tags] } resource "datadog_monitor" "memory_percentage" { - count = "${var.memory_percentage_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Serverfarm memory percentage is too high {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.memory_percentage_message, var.message)}" +count = var.memory_percentage_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Serverfarm memory percentage is too high {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +message = coalesce(var.memory_percentage_message, var.message) + type = "query alert" - query = < ${var.memory_percentage_threshold_critical} - EOQ +EOQ - type = "query alert" - - thresholds { - warning = "${var.memory_percentage_threshold_warning}" - critical = "${var.memory_percentage_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:azure", "resource:serverfarms", "team:claranet", "created-by:terraform", "${var.memory_percentage_extra_tags}"] +thresholds = { +warning = var.memory_percentage_threshold_warning +critical = var.memory_percentage_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:azure", "resource:serverfarms", "team:claranet", "created-by:terraform", var.memory_percentage_extra_tags] +} + diff --git a/cloud/azure/serverfarms/outputs.tf b/cloud/azure/serverfarms/outputs.tf index c021806..2780151 100644 --- a/cloud/azure/serverfarms/outputs.tf +++ b/cloud/azure/serverfarms/outputs.tf @@ -1,14 +1,15 @@ output "status_id" { description = "id for monitor status" - value = "${datadog_monitor.status.*.id}" + value = datadog_monitor.status.*.id } output "cpu_percentage_id" { description = "id for monitor cpu_percentage" - value = "${datadog_monitor.cpu_percentage.*.id}" + value = datadog_monitor.cpu_percentage.*.id } output "memory_percentage_id" { description = "id for monitor memory_percentage" - value = "${datadog_monitor.memory_percentage.*.id}" + value = datadog_monitor.memory_percentage.*.id } + diff --git a/cloud/azure/serverfarms/versions.tf b/cloud/azure/serverfarms/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/cloud/azure/serverfarms/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/cloud/azure/servicebus/inputs.tf b/cloud/azure/servicebus/inputs.tf index 6b69823..d70daee 100644 --- a/cloud/azure/servicebus/inputs.tf +++ b/cloud/azure/servicebus/inputs.tf @@ -1,7 +1,7 @@ # Global Terraform variable "environment" { description = "Architecture Environment" - type = "string" + type = string } # Global DataDog @@ -42,25 +42,25 @@ variable "filter_tags_custom_excluded" { # Azure Service Bus specific variables variable "status_enabled" { description = "Flag to enable Service Bus status monitor" - type = "string" + type = string default = "true" } variable "status_extra_tags" { description = "Extra tags for Service Bus status monitor" - type = "list" + type = list(string) default = [] } variable "status_message" { description = "Custom message for Service Bus status monitor" - type = "string" + type = string default = "" } variable "status_time_aggregator" { description = "Monitor aggregator for Service Bus status [available values: min, max or avg]" - type = "string" + type = string default = "max" } @@ -71,49 +71,49 @@ variable "status_timeframe" { variable "no_active_connections_enabled" { description = "Flag to enable Service Bus status monitor" - type = "string" + type = string default = "true" } variable "no_active_connections_message" { description = "Custom message for Service Bus status monitor" - type = "string" + type = string default = "" } variable "no_active_connections_time_aggregator" { description = "Monitor aggregator for Service Bus status [available values: min, max or avg]" - type = "string" + type = string default = "max" } variable "no_active_connections_timeframe" { description = "Monitor timeframe for Service Bus status [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } variable "server_errors_message" { description = "Custom message for Service Bus server errors monitor" - type = "string" + type = string default = "" } variable "server_errors_enabled" { description = "Flag to enable Service Bus server errors monitor" - type = "string" + type = string default = "true" } variable "server_errors_time_aggregator" { description = "Monitor aggregator for Service Bus server errors [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "server_errors_timeframe" { description = "Monitor timeframe for Service Bus server errors [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -129,25 +129,25 @@ variable "server_errors_threshold_warning" { variable "user_errors_message" { description = "Custom message for Service Bus user errors monitor" - type = "string" + type = string default = "" } variable "user_errors_enabled" { description = "Flag to enable Service Bus user errors monitor" - type = "string" + type = string default = "true" } variable "user_errors_time_aggregator" { description = "Monitor aggregator for Service Bus user errors [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "user_errors_timeframe" { description = "Monitor timeframe for Service Bus user errors [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -160,3 +160,4 @@ variable "user_errors_threshold_warning" { description = "Warning threshold for Service Bus user errors monitor" default = 50 } + diff --git a/cloud/azure/servicebus/modules.tf b/cloud/azure/servicebus/modules.tf index 78ee1ae..4abc459 100644 --- a/cloud/azure/servicebus/modules.tf +++ b/cloud/azure/servicebus/modules.tf @@ -1,9 +1,10 @@ module "filter-tags" { source = "../../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "azure_servicebus" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded } + diff --git a/cloud/azure/servicebus/monitors-service-bus.tf b/cloud/azure/servicebus/monitors-service-bus.tf index ccad349..22da17e 100644 --- a/cloud/azure/servicebus/monitors-service-bus.tf +++ b/cloud/azure/servicebus/monitors-service-bus.tf @@ -1,119 +1,112 @@ resource "datadog_monitor" "servicebus_status" { - count = "${var.status_enabled == "true" ? 1 : 0}" - + count = var.status_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Service Bus is down" - message = "${coalesce(var.status_message, var.message)}" + message = coalesce(var.status_message, var.message) + type = "query alert" query = < ${var.user_errors_threshold_critical} - EOQ +EOQ - type = "query alert" +thresholds = { +critical = var.user_errors_threshold_critical +warning = var.user_errors_threshold_warning +} - thresholds { - critical = "${var.user_errors_threshold_critical}" - warning = "${var.user_errors_threshold_warning}" - } +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 - 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}", "resource:servicebus", "team:azure", "provider:azure"] +tags = ["env:${var.environment}", "resource:servicebus", "team:azure", "provider:azure"] } resource "datadog_monitor" "service_bus_server_errors" { - count = "${var.server_errors_enabled == "true" ? 1 : 0}" +count = var.server_errors_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Service Bus server errors rate is high {{#is_alert}}{{comparator}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{comparator}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +message = coalesce(var.server_errors_message, var.message) + type = "query alert" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Service Bus server errors rate is high {{#is_alert}}{{comparator}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{comparator}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.server_errors_message, var.message)}" - - query = < ${var.server_errors_threshold_critical} - EOQ +EOQ - type = "query alert" - - thresholds { - critical = "${var.server_errors_threshold_critical}" - warning = "${var.server_errors_threshold_warning}" + thresholds = { + critical = var.server_errors_threshold_critical + warning = var.server_errors_threshold_warning } notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" + 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}" + new_host_delay = var.new_host_delay tags = ["env:${var.environment}", "resource:servicebus", "team:azure", "provider:azure"] } + diff --git a/cloud/azure/servicebus/outputs.tf b/cloud/azure/servicebus/outputs.tf index ad117a1..0f0aaff 100644 --- a/cloud/azure/servicebus/outputs.tf +++ b/cloud/azure/servicebus/outputs.tf @@ -1,19 +1,20 @@ output "servicebus_status_id" { description = "id for monitor servicebus_status" - value = "${datadog_monitor.servicebus_status.*.id}" + value = datadog_monitor.servicebus_status.*.id } output "service_bus_no_active_connections_id" { description = "id for monitor service_bus_no_active_connections" - value = "${datadog_monitor.service_bus_no_active_connections.*.id}" + value = datadog_monitor.service_bus_no_active_connections.*.id } output "service_bus_user_errors_id" { description = "id for monitor service_bus_user_errors" - value = "${datadog_monitor.service_bus_user_errors.*.id}" + value = datadog_monitor.service_bus_user_errors.*.id } output "service_bus_server_errors_id" { description = "id for monitor service_bus_server_errors" - value = "${datadog_monitor.service_bus_server_errors.*.id}" + value = datadog_monitor.service_bus_server_errors.*.id } + diff --git a/cloud/azure/servicebus/versions.tf b/cloud/azure/servicebus/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/cloud/azure/servicebus/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/cloud/azure/sql-database/inputs.tf b/cloud/azure/sql-database/inputs.tf index 10190b5..9a65ed0 100644 --- a/cloud/azure/sql-database/inputs.tf +++ b/cloud/azure/sql-database/inputs.tf @@ -1,7 +1,7 @@ # Global Terraform variable "environment" { description = "Architecture Environment" - type = "string" + type = string } # Global DataDog @@ -43,61 +43,61 @@ variable "filter_tags_custom_excluded" { variable "status_enabled" { description = "Flag to enable Redis status monitor" - type = "string" + type = string default = "true" } variable "status_extra_tags" { description = "Extra tags for Redis status monitor" - type = "list" + type = list(string) default = [] } variable "status_message" { description = "Custom message for Redis status monitor" - type = "string" + type = string default = "" } variable "status_time_aggregator" { description = "Monitor aggregator for Redis status [available values: min, max or avg]" - type = "string" + type = string default = "max" } variable "status_timeframe" { description = "Monitor timeframe for Redis status [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } variable "cpu_enabled" { description = "Flag to enable SQL CPU monitor" - type = "string" + type = string default = "true" } variable "cpu_extra_tags" { description = "Extra tags for SQL CPU monitor" - type = "list" + type = list(string) default = [] } variable "cpu_message" { description = "Custom message for SQL CPU monitor" - type = "string" + type = string default = "" } variable "cpu_time_aggregator" { description = "Monitor aggregator for SQL CPU [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "cpu_timeframe" { description = "Monitor timeframe for SQL CPU [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_15m" } @@ -113,31 +113,31 @@ variable "cpu_threshold_critical" { variable "diskspace_enabled" { description = "Flag to enable SQL disk space monitor" - type = "string" + type = string default = "true" } variable "diskspace_extra_tags" { description = "Extra tags for SQL disk space monitor" - type = "list" + type = list(string) default = [] } variable "diskspace_message" { description = "Custom message for SQL disk space monitor" - type = "string" + type = string default = "" } variable "diskspace_time_aggregator" { description = "Monitor aggregator for SQL disk space [available values: min, max or avg]" - type = "string" + type = string default = "max" } variable "diskspace_timeframe" { description = "Monitor timeframe for SQL disk space [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_15m" } @@ -153,31 +153,31 @@ variable "diskspace_threshold_critical" { variable "dtu_enabled" { description = "Flag to enable SQL DTU monitor" - type = "string" + type = string default = "true" } variable "dtu_extra_tags" { description = "Extra tags for SQL DTU monitor" - type = "list" + type = list(string) default = [] } variable "dtu_message" { description = "Custom message for SQL DTU monitor" - type = "string" + type = string default = "" } variable "dtu_time_aggregator" { description = "Monitor aggregator for SQL DTU [available values: min, max or avg]" - type = "string" + type = string default = "avg" } variable "dtu_timeframe" { description = "Monitor timeframe for SQL DTU [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_15m" } @@ -193,25 +193,25 @@ variable "dtu_threshold_critical" { variable "deadlock_enabled" { description = "Flag to enable SQL Deadlock monitor" - type = "string" + type = string default = "true" } variable "deadlock_extra_tags" { description = "Extra tags for SQL Deadlock monitor" - type = "list" + type = list(string) default = [] } variable "deadlock_message" { description = "Custom message for SQL Deadlock monitor" - type = "string" + type = string default = "" } variable "deadlock_timeframe" { description = "Monitor timeframe for SQL Deadlock [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -219,3 +219,4 @@ variable "deadlock_threshold_critical" { description = "Amount of Deadlocks (critical threshold)" default = "1" } + diff --git a/cloud/azure/sql-database/modules.tf b/cloud/azure/sql-database/modules.tf index 3f6833a..6f0c6de 100644 --- a/cloud/azure/sql-database/modules.tf +++ b/cloud/azure/sql-database/modules.tf @@ -1,9 +1,10 @@ module "filter-tags" { source = "../../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "azure_sql-database" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded } + diff --git a/cloud/azure/sql-database/monitors-sql-database.tf b/cloud/azure/sql-database/monitors-sql-database.tf index 6d8908c..2eb2635 100644 --- a/cloud/azure/sql-database/monitors-sql-database.tf +++ b/cloud/azure/sql-database/monitors-sql-database.tf @@ -1,148 +1,144 @@ resource "datadog_monitor" "status" { - count = "${var.status_enabled == "true" ? 1 : 0}" + count = var.status_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] SQL Database is down" - message = "${coalesce(var.status_message, var.message)}" + message = coalesce(var.status_message, var.message) + type = "query alert" query = < ${var.cpu_threshold_critical} - EOQ +EOQ - type = "query alert" +thresholds = { +critical = var.cpu_threshold_critical +warning = var.cpu_threshold_warning +} - thresholds { - critical = "${var.cpu_threshold_critical}" - warning = "${var.cpu_threshold_warning}" - } +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 - 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:azure", "resource:sql-database", "team:claranet", "created-by:terraform", "${var.cpu_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:sql-database", "team:claranet", "created-by:terraform", var.cpu_extra_tags] } resource "datadog_monitor" "sql-database_free_space_low" { - count = "${var.diskspace_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] SQL Database high disk usage {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.diskspace_message, var.message)}" - +count = var.diskspace_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] SQL Database high disk usage {{#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.diskspace_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.diskspace_threshold_warning}" - critical = "${var.diskspace_threshold_critical}" - } +thresholds = { +warning = var.diskspace_threshold_warning +critical = var.diskspace_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}" +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:azure", "resource:sql-database", "team:claranet", "created-by:terraform", "${var.diskspace_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:sql-database", "team:claranet", "created-by:terraform", var.diskspace_extra_tags] } resource "datadog_monitor" "sql-database_dtu_consumption_high" { - count = "${var.dtu_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] SQL Database DTU Consumption too high {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.dtu_message, var.message)}" - +count = var.dtu_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] SQL Database DTU Consumption too high {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +message = coalesce(var.dtu_message, var.message) type = "query alert" - query = < ${var.dtu_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.dtu_threshold_warning}" - critical = "${var.dtu_threshold_critical}" + thresholds = { + warning = var.dtu_threshold_warning + critical = var.dtu_threshold_critical } notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" + 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}" + new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:sql-database", "team:claranet", "created-by:terraform", "${var.dtu_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:sql-database", "team:claranet", "created-by:terraform", var.dtu_extra_tags] } resource "datadog_monitor" "sql-database_deadlocks_count" { - count = "${var.deadlock_enabled == "true" ? 1 : 0}" + count = var.deadlock_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] SQL Database Deadlocks too high {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}" - message = "${coalesce(var.deadlock_message, var.message)}" - + message = coalesce(var.deadlock_message, var.message) type = "query alert" query = < ${var.deadlock_threshold_critical} - EOQ +EOQ - thresholds { - critical = "${var.deadlock_threshold_critical}" + thresholds = { + critical = var.deadlock_threshold_critical } - notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - renotify_interval = 0 - notify_audit = false - timeout_h = 1 - include_tags = true - locked = false + notify_no_data = false + evaluation_delay = var.evaluation_delay + renotify_interval = 0 + notify_audit = false + timeout_h = 1 + include_tags = true + locked = false require_full_window = false - new_host_delay = "${var.new_host_delay}" + new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:sql-database", "team:claranet", "created-by:terraform", "${var.deadlock_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:sql-database", "team:claranet", "created-by:terraform", var.deadlock_extra_tags] } + diff --git a/cloud/azure/sql-database/outputs.tf b/cloud/azure/sql-database/outputs.tf index d31edbf..964b748 100644 --- a/cloud/azure/sql-database/outputs.tf +++ b/cloud/azure/sql-database/outputs.tf @@ -1,24 +1,25 @@ output "status_id" { description = "id for monitor status" - value = "${datadog_monitor.status.*.id}" + value = datadog_monitor.status.*.id } output "sql-database_cpu_id" { description = "id for monitor sql-database_cpu" - value = "${datadog_monitor.sql-database_cpu.*.id}" + value = datadog_monitor.sql-database_cpu.*.id } output "sql-database_free_space_low_id" { description = "id for monitor sql-database_free_space_low" - value = "${datadog_monitor.sql-database_free_space_low.*.id}" + value = datadog_monitor.sql-database_free_space_low.*.id } output "sql-database_dtu_consumption_high_id" { description = "id for monitor sql-database_dtu_consumption_high" - value = "${datadog_monitor.sql-database_dtu_consumption_high.*.id}" + value = datadog_monitor.sql-database_dtu_consumption_high.*.id } output "sql-database_deadlocks_count_id" { description = "id for monitor sql-database_deadlocks_count" - value = "${datadog_monitor.sql-database_deadlocks_count.*.id}" + value = datadog_monitor.sql-database_deadlocks_count.*.id } + diff --git a/cloud/azure/sql-database/versions.tf b/cloud/azure/sql-database/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/cloud/azure/sql-database/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/cloud/azure/sql-elasticpool/inputs.tf b/cloud/azure/sql-elasticpool/inputs.tf index 89f63ec..b6fee13 100644 --- a/cloud/azure/sql-elasticpool/inputs.tf +++ b/cloud/azure/sql-elasticpool/inputs.tf @@ -1,7 +1,7 @@ # Global Terraform variable "environment" { description = "Architecture Environment" - type = "string" + type = string } # Global DataDog @@ -43,31 +43,31 @@ variable "filter_tags_custom_excluded" { variable "cpu_enabled" { description = "Flag to enable SQL Elastic Pool CPU monitor" - type = "string" + type = string default = "true" } variable "cpu_extra_tags" { description = "Extra tags for SQL Elastic Pool CPU monitor" - type = "list" + type = list(string) default = [] } variable "cpu_message" { description = "Custom message for SQL Elastic Pool CPU monitor" - type = "string" + type = string default = "" } variable "cpu_time_aggregator" { description = "Monitor aggregator for SQL Elastic Pool CPU [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "cpu_timeframe" { description = "Monitor timeframe for SQL Elastic Pool CPU [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_15m" } @@ -83,31 +83,31 @@ variable "cpu_threshold_critical" { variable "diskspace_enabled" { description = "Flag to enable SQL Elastic Pool disk space monitor" - type = "string" + type = string default = "true" } variable "diskspace_extra_tags" { description = "Extra tags for SQL Elastic Pool disk space monitor" - type = "list" + type = list(string) default = [] } variable "diskspace_message" { description = "Custom message for SQL Elastic Pool disk space monitor" - type = "string" + type = string default = "" } variable "diskspace_time_aggregator" { description = "Monitor aggregator for SQL Elastic Pool disk space [available values: min, max or avg]" - type = "string" + type = string default = "max" } variable "diskspace_timeframe" { description = "Monitor timeframe for SQL Elastic Pool disk space [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_15m" } @@ -123,31 +123,31 @@ variable "diskspace_threshold_critical" { variable "dtu_enabled" { description = "Flag to enable SQL Elastic Pool DTU monitor" - type = "string" + type = string default = "true" } variable "dtu_extra_tags" { description = "Extra tags for SQL Elastic Pool DTU monitor" - type = "list" + type = list(string) default = [] } variable "dtu_message" { description = "Custom message for SQL Elastic Pool DTU monitor" - type = "string" + type = string default = "" } variable "dtu_time_aggregator" { description = "Monitor aggregator for SQL Elastic Pool DTU [available values: min, max or avg]" - type = "string" + type = string default = "avg" } variable "dtu_timeframe" { description = "Monitor timeframe for SQL Elastic Pool DTU [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_15m" } @@ -160,3 +160,4 @@ variable "dtu_threshold_critical" { description = "Amount of DTU used (critical threshold)" default = "90" } + diff --git a/cloud/azure/sql-elasticpool/modules.tf b/cloud/azure/sql-elasticpool/modules.tf index 7e0411e..6c5206d 100644 --- a/cloud/azure/sql-elasticpool/modules.tf +++ b/cloud/azure/sql-elasticpool/modules.tf @@ -1,9 +1,10 @@ module "filter-tags" { source = "../../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "azure_sql-elasticpool" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded } + diff --git a/cloud/azure/sql-elasticpool/monitors-sql-elasticpool.tf b/cloud/azure/sql-elasticpool/monitors-sql-elasticpool.tf index 3cea3cc..5b038d4 100644 --- a/cloud/azure/sql-elasticpool/monitors-sql-elasticpool.tf +++ b/cloud/azure/sql-elasticpool/monitors-sql-elasticpool.tf @@ -1,92 +1,90 @@ resource "datadog_monitor" "sql_elasticpool_cpu" { - count = "${var.cpu_enabled == "true" ? 1 : 0}" + count = var.cpu_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] SQL Elastic Pool CPU too high {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.cpu_message, var.message)}" + message = coalesce(var.cpu_message, var.message) + type = "query alert" query = < ${var.cpu_threshold_critical} - EOQ +EOQ - type = "query alert" - - thresholds { - critical = "${var.cpu_threshold_critical}" - warning = "${var.cpu_threshold_warning}" + thresholds = { + critical = var.cpu_threshold_critical + warning = var.cpu_threshold_warning } - notify_no_data = true - evaluation_delay = "${var.evaluation_delay}" - renotify_interval = 0 - notify_audit = false - timeout_h = 0 - include_tags = true - locked = false + 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}" + new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:sql-elasticpool", "team:claranet", "created-by:terraform", "${var.cpu_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:sql-elasticpool", "team:claranet", "created-by:terraform", var.cpu_extra_tags] } resource "datadog_monitor" "sql_elasticpool_free_space_low" { - count = "${var.diskspace_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] SQL Elastic Pool high disk usage {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.diskspace_message, var.message)}" - + count = var.diskspace_enabled == "true" ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] SQL Elastic Pool high disk usage {{#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.diskspace_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.diskspace_threshold_warning}" - critical = "${var.diskspace_threshold_critical}" - } +thresholds = { +warning = var.diskspace_threshold_warning +critical = var.diskspace_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}" +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:azure", "resource:sql-elasticpool", "team:claranet", "created-by:terraform", "${var.diskspace_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:sql-elasticpool", "team:claranet", "created-by:terraform", var.diskspace_extra_tags] } resource "datadog_monitor" "sql_elasticpool_dtu_consumption_high" { - count = "${var.dtu_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] SQL Elastic Pool DTU Consumption too high {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.dtu_message, var.message)}" - +count = var.dtu_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] SQL Elastic Pool DTU Consumption too high {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +message = coalesce(var.dtu_message, var.message) type = "query alert" - query = < ${var.dtu_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.dtu_threshold_warning}" - critical = "${var.dtu_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:azure", "resource:sql-elasticpool", "team:claranet", "created-by:terraform", "${var.dtu_extra_tags}"] +thresholds = { +warning = var.dtu_threshold_warning +critical = var.dtu_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:azure", "resource:sql-elasticpool", "team:claranet", "created-by:terraform", var.dtu_extra_tags] +} + diff --git a/cloud/azure/sql-elasticpool/outputs.tf b/cloud/azure/sql-elasticpool/outputs.tf index f3c189d..fb40d2e 100644 --- a/cloud/azure/sql-elasticpool/outputs.tf +++ b/cloud/azure/sql-elasticpool/outputs.tf @@ -1,14 +1,15 @@ output "sql_elasticpool_cpu_id" { description = "id for monitor sql_elasticpool_cpu" - value = "${datadog_monitor.sql_elasticpool_cpu.*.id}" + value = datadog_monitor.sql_elasticpool_cpu.*.id } output "sql_elasticpool_free_space_low_id" { description = "id for monitor sql_elasticpool_free_space_low" - value = "${datadog_monitor.sql_elasticpool_free_space_low.*.id}" + value = datadog_monitor.sql_elasticpool_free_space_low.*.id } output "sql_elasticpool_dtu_consumption_high_id" { description = "id for monitor sql_elasticpool_dtu_consumption_high" - value = "${datadog_monitor.sql_elasticpool_dtu_consumption_high.*.id}" + value = datadog_monitor.sql_elasticpool_dtu_consumption_high.*.id } + diff --git a/cloud/azure/sql-elasticpool/versions.tf b/cloud/azure/sql-elasticpool/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/cloud/azure/sql-elasticpool/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/cloud/azure/storage/inputs.tf b/cloud/azure/storage/inputs.tf index 2214a8f..9f9d73a 100644 --- a/cloud/azure/storage/inputs.tf +++ b/cloud/azure/storage/inputs.tf @@ -1,7 +1,7 @@ # Global Terraform variable "environment" { description = "Architecture environment" - type = "string" + type = string } # Global DataDog @@ -43,31 +43,31 @@ variable "filter_tags_custom_excluded" { variable "availability_enabled" { description = "Flag to enable Storage availability monitor" - type = "string" + type = string default = "true" } variable "availability_extra_tags" { description = "Extra tags for Storage availability monitor" - type = "list" + type = list(string) default = [] } variable "availability_message" { description = "Custom message for Storage availability monitor" - type = "string" + type = string default = "" } variable "availability_time_aggregator" { description = "Monitor aggregator for Storage availability [available values: min, max or avg]" - type = "string" + type = string default = "max" } variable "availability_timeframe" { description = "Monitor timeframe for Storage availability [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -83,31 +83,31 @@ variable "availability_threshold_warning" { variable "successful_requests_enabled" { description = "Flag to enable Storage sucessful requests monitor" - type = "string" + type = string default = "true" } variable "successful_requests_extra_tags" { description = "Extra tags for Storage sucessful requests monitor" - type = "list" + type = list(string) default = [] } variable "successful_requests_message" { description = "Custom message for Storage sucessful requests monitor" - type = "string" + type = string default = "" } variable "successful_requests_time_aggregator" { description = "Monitor aggregator for Storage sucessful requests [available values: min, max or avg]" - type = "string" + type = string default = "max" } variable "successful_requests_timeframe" { description = "Monitor timeframe for Storage sucessful requests [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -123,31 +123,31 @@ variable "successful_requests_threshold_warning" { variable "latency_enabled" { description = "Flag to enable Storage latency monitor" - type = "string" + type = string default = "true" } variable "latency_extra_tags" { description = "Extra tags for Storage latency monitor" - type = "list" + type = list(string) default = [] } variable "latency_message" { description = "Custom message for Storage latency monitor" - type = "string" + type = string default = "" } variable "latency_time_aggregator" { description = "Monitor aggregator for Storage latency [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "latency_timeframe" { description = "Monitor timeframe for Storage latency [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -163,31 +163,31 @@ variable "latency_threshold_warning" { variable "timeout_error_requests_enabled" { description = "Flag to enable Storage timeout monitor" - type = "string" + type = string default = "true" } variable "timeout_error_requests_extra_tags" { description = "Extra tags for Storage timeout monitor" - type = "list" + type = list(string) default = [] } variable "timeout_error_requests_message" { description = "Custom message for Storage timeout monitor" - type = "string" + type = string default = "" } variable "timeout_error_requests_time_aggregator" { description = "Monitor aggregator for Storage timeout [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "timeout_error_requests_timeframe" { description = "Monitor timeframe for Storage timeout [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -203,31 +203,31 @@ variable "timeout_error_requests_threshold_warning" { variable "network_error_requests_enabled" { description = "Flag to enable Storage network errors monitor" - type = "string" + type = string default = "true" } variable "network_error_requests_extra_tags" { description = "Extra tags for Storage network errors monitor" - type = "list" + type = list(string) default = [] } variable "network_error_requests_message" { description = "Custom message for Storage network errors monitor" - type = "string" + type = string default = "" } variable "network_error_requests_time_aggregator" { description = "Monitor aggregator for Storage network errors [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "network_error_requests_timeframe" { description = "Monitor timeframe for Storage network errors [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -243,31 +243,31 @@ variable "network_error_requests_threshold_warning" { variable "throttling_error_requests_enabled" { description = "Flag to enable Storage throttling error monitor" - type = "string" + type = string default = "true" } variable "throttling_error_requests_extra_tags" { description = "Extra tags for Storage throttling error monitor" - type = "list" + type = list(string) default = [] } variable "throttling_error_requests_message" { description = "Custom message for Storage throttling error monitor" - type = "string" + type = string default = "" } variable "throttling_error_requests_time_aggregator" { description = "Monitor aggregator for Storage throttling errors [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "throttling_error_requests_timeframe" { description = "Monitor timeframe for Storage throttling errors [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -283,31 +283,31 @@ variable "throttling_error_requests_threshold_warning" { variable "server_other_error_requests_enabled" { description = "Flag to enable Storage server other errors monitor" - type = "string" + type = string default = "true" } variable "server_other_error_requests_extra_tags" { description = "Extra tags for Storage server other errors monitor" - type = "list" + type = list(string) default = [] } variable "server_other_error_requests_message" { description = "Custom message for Storage server other errors monitor" - type = "string" + type = string default = "" } variable "server_other_error_requests_time_aggregator" { description = "Monitor aggregator for Storage other errors [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "server_other_error_requests_timeframe" { description = "Monitor timeframe for Storage server other errors [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -323,31 +323,31 @@ variable "server_other_error_requests_threshold_warning" { variable "client_other_error_requests_enabled" { description = "Flag to enable Storage other errors monitor" - type = "string" + type = string default = "true" } variable "client_other_error_requests_extra_tags" { description = "Extra tags for Storage other errors monitor" - type = "list" + type = list(string) default = [] } variable "client_other_error_requests_message" { description = "Custom message for Storage other errors monitor" - type = "string" + type = string default = "" } variable "client_other_error_requests_time_aggregator" { description = "Monitor aggregator for Storage other errors [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "client_other_error_requests_timeframe" { description = "Monitor timeframe for Storage other errors [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -363,31 +363,31 @@ variable "client_other_error_requests_threshold_warning" { variable "authorization_error_requests_enabled" { description = "Flag to enable Storage authorization errors monitor" - type = "string" + type = string default = "true" } variable "authorization_error_requests_extra_tags" { description = "Extra tags for Storage authorization errors monitor" - type = "list" + type = list(string) default = [] } variable "authorization_error_requests_message" { description = "Custom message for Storage authorization errors monitor" - type = "string" + type = string default = "" } variable "authorization_error_requests_time_aggregator" { description = "Monitor aggregator for Storage authorization errors [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "authorization_error_requests_timeframe" { description = "Monitor timeframe for Storage authorization errors [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -400,3 +400,4 @@ variable "authorization_error_requests_threshold_warning" { description = "Warning regarding acceptable percent of authorization error requests for a storage" default = 50 } + diff --git a/cloud/azure/storage/modules.tf b/cloud/azure/storage/modules.tf index 3a51cad..d60f90d 100644 --- a/cloud/azure/storage/modules.tf +++ b/cloud/azure/storage/modules.tf @@ -1,10 +1,11 @@ module "filter-tags" { source = "../../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "azure_storage" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded extra_tags = ["transaction_type:all"] } + diff --git a/cloud/azure/storage/monitors-azure-storage.tf b/cloud/azure/storage/monitors-azure-storage.tf index f5b6d92..c87b4da 100644 --- a/cloud/azure/storage/monitors-azure-storage.tf +++ b/cloud/azure/storage/monitors-azure-storage.tf @@ -1,269 +1,271 @@ resource "datadog_monitor" "availability" { - count = "${var.availability_enabled == "true" ? 1 : 0}" + count = var.availability_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Azure Storage is down" - message = "${coalesce(var.availability_message, var.message)}" + message = coalesce(var.availability_message, var.message) + type = "query alert" query = < ${var.latency_threshold_critical} - EOQ +EOQ - thresholds { - critical = "${var.latency_threshold_critical}" - warning = "${var.latency_threshold_warning}" - } +thresholds = { +critical = var.latency_threshold_critical +warning = var.latency_threshold_warning +} - type = "query alert" - notify_no_data = false - notify_audit = false - timeout_h = 0 - include_tags = true - locked = false - require_full_window = false - new_host_delay = "${var.new_host_delay}" - evaluation_delay = "${var.evaluation_delay}" - renotify_interval = 0 +notify_no_data = false +notify_audit = false +timeout_h = 0 +include_tags = true +locked = false +require_full_window = false +new_host_delay = var.new_host_delay +evaluation_delay = var.evaluation_delay +renotify_interval = 0 - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:storage", "team:claranet", "created-by:terraform", "${var.latency_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:storage", "team:claranet", "created-by:terraform", var.latency_extra_tags] } resource "datadog_monitor" "timeout_error_requests" { - count = "${var.timeout_error_requests_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Azure Storage too many timeout errors {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.timeout_error_requests_message, var.message)}" +count = var.timeout_error_requests_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Azure Storage too many timeout errors {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +message = coalesce(var.timeout_error_requests_message, var.message) + type = "query alert" - query = < ${var.timeout_error_requests_threshold_critical} - EOQ +EOQ - thresholds { - critical = "${var.timeout_error_requests_threshold_critical}" - warning = "${var.timeout_error_requests_threshold_warning}" + thresholds = { + critical = var.timeout_error_requests_threshold_critical + warning = var.timeout_error_requests_threshold_warning } - type = "query alert" notify_no_data = false notify_audit = false timeout_h = 0 include_tags = true locked = false require_full_window = false - new_host_delay = "${var.new_host_delay}" - evaluation_delay = "${var.evaluation_delay}" + new_host_delay = var.new_host_delay + evaluation_delay = var.evaluation_delay renotify_interval = 0 - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:storage", "team:claranet", "created-by:terraform", "${var.timeout_error_requests_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:storage", "team:claranet", "created-by:terraform", var.timeout_error_requests_extra_tags] } resource "datadog_monitor" "network_error_requests" { - count = "${var.network_error_requests_enabled == "true" ? 1 : 0}" + count = var.network_error_requests_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Azure Storage too many network errors {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.network_error_requests_message, var.message)}" + message = coalesce(var.network_error_requests_message, var.message) + type = "query alert" query = < ${var.network_error_requests_threshold_critical} - EOQ +EOQ - thresholds { - critical = "${var.network_error_requests_threshold_critical}" - warning = "${var.network_error_requests_threshold_warning}" + thresholds = { + critical = var.network_error_requests_threshold_critical + warning = var.network_error_requests_threshold_warning } - type = "query alert" - notify_no_data = false - notify_audit = false - timeout_h = 0 - include_tags = true - locked = false + notify_no_data = false + notify_audit = false + timeout_h = 0 + include_tags = true + locked = false require_full_window = false - new_host_delay = "${var.new_host_delay}" - evaluation_delay = "${var.evaluation_delay}" - renotify_interval = 0 + new_host_delay = var.new_host_delay + evaluation_delay = var.evaluation_delay + renotify_interval = 0 - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:storage", "team:claranet", "created-by:terraform", "${var.network_error_requests_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:storage", "team:claranet", "created-by:terraform", var.network_error_requests_extra_tags] } resource "datadog_monitor" "throttling_error_requests" { - count = "${var.throttling_error_requests_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Azure Storage too many throttling errors {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.throttling_error_requests_message, var.message)}" + count = var.throttling_error_requests_enabled == "true" ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Azure Storage too many throttling errors {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" + message = coalesce(var.throttling_error_requests_message, var.message) + type = "query alert" query = < ${var.throttling_error_requests_threshold_critical} - EOQ +EOQ - thresholds { - critical = "${var.throttling_error_requests_threshold_critical}" - warning = "${var.throttling_error_requests_threshold_warning}" - } +thresholds = { +critical = var.throttling_error_requests_threshold_critical +warning = var.throttling_error_requests_threshold_warning +} - type = "query alert" - notify_no_data = false - notify_audit = false - timeout_h = 0 - include_tags = true - locked = false - require_full_window = false - new_host_delay = "${var.new_host_delay}" - evaluation_delay = "${var.evaluation_delay}" - renotify_interval = 0 +notify_no_data = false +notify_audit = false +timeout_h = 0 +include_tags = true +locked = false +require_full_window = false +new_host_delay = var.new_host_delay +evaluation_delay = var.evaluation_delay +renotify_interval = 0 - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:storage", "team:claranet", "created-by:terraform", "${var.throttling_error_requests_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:storage", "team:claranet", "created-by:terraform", var.throttling_error_requests_extra_tags] } resource "datadog_monitor" "server_other_error_requests" { - count = "${var.server_other_error_requests_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Azure Storage too many server_other errors {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.server_other_error_requests_message, var.message)}" +count = var.server_other_error_requests_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Azure Storage too many server_other errors {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +message = coalesce(var.server_other_error_requests_message, var.message) + type = "query alert" - query = < ${var.server_other_error_requests_threshold_critical} - EOQ +EOQ - thresholds { - critical = "${var.server_other_error_requests_threshold_critical}" - warning = "${var.server_other_error_requests_threshold_warning}" - } +thresholds = { +critical = var.server_other_error_requests_threshold_critical +warning = var.server_other_error_requests_threshold_warning +} - type = "query alert" - notify_no_data = false - notify_audit = false - timeout_h = 0 - include_tags = true - locked = false - require_full_window = false - new_host_delay = "${var.new_host_delay}" - evaluation_delay = "${var.evaluation_delay}" - renotify_interval = 0 +notify_no_data = false +notify_audit = false +timeout_h = 0 +include_tags = true +locked = false +require_full_window = false +new_host_delay = var.new_host_delay +evaluation_delay = var.evaluation_delay +renotify_interval = 0 - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:storage", "team:claranet", "created-by:terraform", "${var.server_other_error_requests_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:storage", "team:claranet", "created-by:terraform", var.server_other_error_requests_extra_tags] } resource "datadog_monitor" "client_other_error_requests" { - count = "${var.client_other_error_requests_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Azure Storage too many client_other errors {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.client_other_error_requests_message, var.message)}" +count = var.client_other_error_requests_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Azure Storage too many client_other errors {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +message = coalesce(var.client_other_error_requests_message, var.message) + type = "query alert" - query = < ${var.client_other_error_requests_threshold_critical} - EOQ +EOQ - thresholds { - critical = "${var.client_other_error_requests_threshold_critical}" - warning = "${var.client_other_error_requests_threshold_warning}" + thresholds = { + critical = var.client_other_error_requests_threshold_critical + warning = var.client_other_error_requests_threshold_warning } - type = "query alert" notify_no_data = false notify_audit = false timeout_h = 0 include_tags = true locked = false require_full_window = false - new_host_delay = "${var.new_host_delay}" - evaluation_delay = "${var.evaluation_delay}" + new_host_delay = var.new_host_delay + evaluation_delay = var.evaluation_delay renotify_interval = 0 - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:storage", "team:claranet", "created-by:terraform", "${var.client_other_error_requests_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:storage", "team:claranet", "created-by:terraform", var.client_other_error_requests_extra_tags] } resource "datadog_monitor" "authorization_error_requests" { - count = "${var.authorization_error_requests_enabled == "true" ? 1 : 0}" + count = var.authorization_error_requests_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Azure Storage too many authorization errors {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.authorization_error_requests_message, var.message)}" + message = coalesce(var.authorization_error_requests_message, var.message) + type = "query alert" query = < ${var.authorization_error_requests_threshold_critical} - EOQ +EOQ - thresholds { - critical = "${var.authorization_error_requests_threshold_critical}" - warning = "${var.authorization_error_requests_threshold_warning}" + thresholds = { + critical = var.authorization_error_requests_threshold_critical + warning = var.authorization_error_requests_threshold_warning } - type = "query alert" - notify_no_data = false - notify_audit = false - timeout_h = 0 - include_tags = true - locked = false + notify_no_data = false + notify_audit = false + timeout_h = 0 + include_tags = true + locked = false require_full_window = false - new_host_delay = "${var.new_host_delay}" - evaluation_delay = "${var.evaluation_delay}" - renotify_interval = 0 + new_host_delay = var.new_host_delay + evaluation_delay = var.evaluation_delay + renotify_interval = 0 - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:storage", "team:claranet", "created-by:terraform", "${var.authorization_error_requests_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:storage", "team:claranet", "created-by:terraform", var.authorization_error_requests_extra_tags] } + diff --git a/cloud/azure/storage/outputs.tf b/cloud/azure/storage/outputs.tf index 261c8f1..bc3bb1a 100644 --- a/cloud/azure/storage/outputs.tf +++ b/cloud/azure/storage/outputs.tf @@ -1,44 +1,45 @@ output "availability_id" { description = "id for monitor availability" - value = "${datadog_monitor.availability.*.id}" + value = datadog_monitor.availability.*.id } output "successful_requests_id" { description = "id for monitor successful_requests" - value = "${datadog_monitor.successful_requests.*.id}" + value = datadog_monitor.successful_requests.*.id } output "latency_id" { description = "id for monitor latency" - value = "${datadog_monitor.latency.*.id}" + value = datadog_monitor.latency.*.id } output "timeout_error_requests_id" { description = "id for monitor timeout_error_requests" - value = "${datadog_monitor.timeout_error_requests.*.id}" + value = datadog_monitor.timeout_error_requests.*.id } output "network_error_requests_id" { description = "id for monitor network_error_requests" - value = "${datadog_monitor.network_error_requests.*.id}" + value = datadog_monitor.network_error_requests.*.id } output "throttling_error_requests_id" { description = "id for monitor throttling_error_requests" - value = "${datadog_monitor.throttling_error_requests.*.id}" + value = datadog_monitor.throttling_error_requests.*.id } output "server_other_error_requests_id" { description = "id for monitor server_other_error_requests" - value = "${datadog_monitor.server_other_error_requests.*.id}" + value = datadog_monitor.server_other_error_requests.*.id } output "client_other_error_requests_id" { description = "id for monitor client_other_error_requests" - value = "${datadog_monitor.client_other_error_requests.*.id}" + value = datadog_monitor.client_other_error_requests.*.id } output "authorization_error_requests_id" { description = "id for monitor authorization_error_requests" - value = "${datadog_monitor.authorization_error_requests.*.id}" + value = datadog_monitor.authorization_error_requests.*.id } + diff --git a/cloud/azure/storage/versions.tf b/cloud/azure/storage/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/cloud/azure/storage/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/cloud/azure/stream-analytics/inputs.tf b/cloud/azure/stream-analytics/inputs.tf index 314bb1f..14b2687 100644 --- a/cloud/azure/stream-analytics/inputs.tf +++ b/cloud/azure/stream-analytics/inputs.tf @@ -1,7 +1,7 @@ # Global Terraform variable "environment" { description = "Architecture environment" - type = "string" + type = string } # Global DataDog @@ -43,61 +43,61 @@ variable "filter_tags_custom_excluded" { variable "status_enabled" { description = "Flag to enable Stream Analytics status monitor" - type = "string" + type = string default = "true" } variable "status_extra_tags" { description = "Extra tags for Stream Analytics status monitor" - type = "list" + type = list(string) default = [] } variable "status_message" { description = "Custom message for Stream Analytics status monitor" - type = "string" + type = string default = "" } variable "status_time_aggregator" { description = "Monitor aggregator for Stream Analytics status [available values: min, max or avg]" - type = "string" + type = string default = "max" } variable "status_timeframe" { description = "Monitor timeframe for Stream Analytics status [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } variable "su_utilization_enabled" { description = "Flag to enable Stream Analytics utilization monitor" - type = "string" + type = string default = "true" } variable "su_utilization_extra_tags" { description = "Extra tags for Stream Analytics utilization monitor" - type = "list" + type = list(string) default = [] } variable "su_utilization_message" { description = "Custom message for Stream Analytics utilization monitor" - type = "string" + type = string default = "" } variable "su_utilization_time_aggregator" { description = "Monitor aggregator for Stream Analytics utilization [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "su_utilization_timeframe" { description = "Monitor timeframe for Stream Analytics utilization [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -113,31 +113,31 @@ variable "su_utilization_threshold_critical" { variable "failed_function_requests_enabled" { description = "Flag to enable Stream Analytics failed requests monitor" - type = "string" + type = string default = "true" } variable "failed_function_requests_extra_tags" { description = "Extra tags for Stream Analytics failed requests monitor" - type = "list" + type = list(string) default = [] } variable "failed_function_requests_message" { description = "Custom message for Stream Analytics failed requests monitor" - type = "string" + type = string default = "" } variable "failed_function_requests_time_aggregator" { description = "Monitor aggregator for Stream Analytics failed requests [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "failed_function_requests_timeframe" { description = "Monitor timeframe for Stream Analytics failed requests [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -153,31 +153,31 @@ variable "failed_function_requests_threshold_critical" { variable "conversion_errors_enabled" { description = "Flag to enable Stream Analytics conversion errors monitor" - type = "string" + type = string default = "true" } variable "conversion_errors_extra_tags" { description = "Extra tags for Stream Analytics conversion errors monitor" - type = "list" + type = list(string) default = [] } variable "conversion_errors_message" { description = "Custom message for Stream Analytics conversion errors monitor" - type = "string" + type = string default = "" } variable "conversion_errors_time_aggregator" { description = "Monitor aggregator for Stream Analytics conversion errors [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "conversion_errors_timeframe" { description = "Monitor timeframe for Stream Analytics conversion errors [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -193,31 +193,31 @@ variable "conversion_errors_threshold_critical" { variable "runtime_errors_enabled" { description = "Flag to enable Stream Analytics runtime errors monitor" - type = "string" + type = string default = "true" } variable "runtime_errors_extra_tags" { description = "Extra tags for Stream Analytics runtime errors monitor" - type = "list" + type = list(string) default = [] } variable "runtime_errors_message" { description = "Custom message for Stream Analytics runtime errors monitor" - type = "string" + type = string default = "" } variable "runtime_errors_time_aggregator" { description = "Monitor aggregator for Stream Analytics runtime errors [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "runtime_errors_timeframe" { description = "Monitor timeframe for Stream Analytics runtime errors [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -230,3 +230,4 @@ variable "runtime_errors_threshold_critical" { description = "Runtime errors limit (critical threshold)" default = 10 } + diff --git a/cloud/azure/stream-analytics/modules.tf b/cloud/azure/stream-analytics/modules.tf index 2738684..868c6a9 100644 --- a/cloud/azure/stream-analytics/modules.tf +++ b/cloud/azure/stream-analytics/modules.tf @@ -1,9 +1,10 @@ module "filter-tags" { source = "../../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "azure_stream-analytics" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded } + diff --git a/cloud/azure/stream-analytics/monitors-stream-analytics.tf b/cloud/azure/stream-analytics/monitors-stream-analytics.tf index f9ab56a..7c9e80d 100644 --- a/cloud/azure/stream-analytics/monitors-stream-analytics.tf +++ b/cloud/azure/stream-analytics/monitors-stream-analytics.tf @@ -1,150 +1,146 @@ resource "datadog_monitor" "status" { - count = "${var.status_enabled == "true" ? 1 : 0}" + count = var.status_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Stream Analytics is down" - message = "${coalesce(var.status_message, var.message)}" + message = coalesce(var.status_message, var.message) + type = "query alert" query = < ${var.su_utilization_threshold_critical} - EOQ +EOQ - type = "query alert" +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 - 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}" +thresholds = { +warning = var.su_utilization_threshold_warning +critical = var.su_utilization_threshold_critical +} - thresholds { - warning = "${var.su_utilization_threshold_warning}" - critical = "${var.su_utilization_threshold_critical}" - } - - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:stream-analytics", "team:claranet", "created-by:terraform", "${var.su_utilization_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:stream-analytics", "team:claranet", "created-by:terraform", var.su_utilization_extra_tags] } resource "datadog_monitor" "failed_function_requests" { - count = "${var.failed_function_requests_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Stream Analytics too many failed requests {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.failed_function_requests_message, var.message)}" +count = var.failed_function_requests_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Stream Analytics too many failed requests {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +message = coalesce(var.failed_function_requests_message, var.message) + type = "query alert" - query = < ${var.failed_function_requests_threshold_critical} - EOQ +EOQ - type = "query alert" +thresholds = { +warning = var.failed_function_requests_threshold_warning +critical = var.failed_function_requests_threshold_critical +} - notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - renotify_interval = 60 - notify_audit = false - timeout_h = 1 - include_tags = true - locked = false - require_full_window = false - new_host_delay = "${var.new_host_delay}" +notify_no_data = false +evaluation_delay = var.evaluation_delay +renotify_interval = 60 +notify_audit = false +timeout_h = 1 +include_tags = true +locked = false +require_full_window = false +new_host_delay = var.new_host_delay - thresholds { - warning = "${var.failed_function_requests_threshold_warning}" - critical = "${var.failed_function_requests_threshold_critical}" - } - - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:stream-analytics", "team:claranet", "created-by:terraform", "${var.failed_function_requests_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:stream-analytics", "team:claranet", "created-by:terraform", var.failed_function_requests_extra_tags] } resource "datadog_monitor" "conversion_errors" { - count = "${var.conversion_errors_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Stream Analytics too many conversion errors {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.conversion_errors_message, var.message)}" +count = var.conversion_errors_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Stream Analytics too many conversion errors {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +message = coalesce(var.conversion_errors_message, var.message) + type = "query alert" - query = < ${var.conversion_errors_threshold_critical} - EOQ +EOQ - type = "query alert" + thresholds = { + warning = var.conversion_errors_threshold_warning + critical = var.conversion_errors_threshold_critical + } notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" + evaluation_delay = var.evaluation_delay renotify_interval = 0 notify_audit = false timeout_h = 1 include_tags = true locked = false require_full_window = false - new_host_delay = "${var.new_host_delay}" + new_host_delay = var.new_host_delay - thresholds { - warning = "${var.conversion_errors_threshold_warning}" - critical = "${var.conversion_errors_threshold_critical}" - } - - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:stream-analytics", "team:claranet", "created-by:terraform", "${var.conversion_errors_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:stream-analytics", "team:claranet", "created-by:terraform", var.conversion_errors_extra_tags] } resource "datadog_monitor" "runtime_errors" { - count = "${var.runtime_errors_enabled == "true" ? 1 : 0}" + count = var.runtime_errors_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Stream Analytics too many runtime errors {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}" - message = "${coalesce(var.runtime_errors_message, var.message)}" + message = coalesce(var.runtime_errors_message, var.message) + type = "query alert" query = < ${var.runtime_errors_threshold_critical} - EOQ +EOQ - type = "query alert" - - notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - renotify_interval = 0 - notify_audit = false - timeout_h = 1 - include_tags = true - locked = false - require_full_window = false - new_host_delay = "${var.new_host_delay}" - - thresholds { - warning = "${var.runtime_errors_threshold_warning}" - critical = "${var.runtime_errors_threshold_critical}" + thresholds = { + warning = var.runtime_errors_threshold_warning + critical = var.runtime_errors_threshold_critical } - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:stream-analytics", "team:claranet", "created-by:terraform", "${var.runtime_errors_extra_tags}"] + notify_no_data = false + evaluation_delay = var.evaluation_delay + renotify_interval = 0 + notify_audit = false + timeout_h = 1 + include_tags = true + locked = false + require_full_window = false + new_host_delay = var.new_host_delay + + tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:stream-analytics", "team:claranet", "created-by:terraform", var.runtime_errors_extra_tags] } + diff --git a/cloud/azure/stream-analytics/outputs.tf b/cloud/azure/stream-analytics/outputs.tf index e0367f7..94129c7 100644 --- a/cloud/azure/stream-analytics/outputs.tf +++ b/cloud/azure/stream-analytics/outputs.tf @@ -1,24 +1,25 @@ output "status_id" { description = "id for monitor status" - value = "${datadog_monitor.status.*.id}" + value = datadog_monitor.status.*.id } output "su_utilization_id" { description = "id for monitor su_utilization" - value = "${datadog_monitor.su_utilization.*.id}" + value = datadog_monitor.su_utilization.*.id } output "failed_function_requests_id" { description = "id for monitor failed_function_requests" - value = "${datadog_monitor.failed_function_requests.*.id}" + value = datadog_monitor.failed_function_requests.*.id } output "conversion_errors_id" { description = "id for monitor conversion_errors" - value = "${datadog_monitor.conversion_errors.*.id}" + value = datadog_monitor.conversion_errors.*.id } output "runtime_errors_id" { description = "id for monitor runtime_errors" - value = "${datadog_monitor.runtime_errors.*.id}" + value = datadog_monitor.runtime_errors.*.id } + diff --git a/cloud/azure/stream-analytics/versions.tf b/cloud/azure/stream-analytics/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/cloud/azure/stream-analytics/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/cloud/azure/virtual-machine/inputs.tf b/cloud/azure/virtual-machine/inputs.tf index 485a86d..087c19f 100644 --- a/cloud/azure/virtual-machine/inputs.tf +++ b/cloud/azure/virtual-machine/inputs.tf @@ -1,7 +1,7 @@ # Global Terraform variable "environment" { description = "Architecture environment" - type = "string" + type = string } # Global DataDog @@ -43,61 +43,61 @@ variable "filter_tags_custom_excluded" { variable "status_enabled" { description = "Flag to enable Virtual Machine status monitor" - type = "string" + type = string default = "true" } variable "status_extra_tags" { description = "Extra tags for Virtual Machine status monitor" - type = "list" + type = list(string) default = [] } variable "status_message" { description = "Custom message for Virtual Machine status monitor" - type = "string" + type = string default = "" } variable "status_time_aggregator" { description = "Monitor aggregator for Virtual Machine status [available values: min, max or avg]" - type = "string" + type = string default = "max" } variable "status_timeframe" { description = "Monitor timeframe for Virtual Machine status [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } variable "cpu_usage_enabled" { description = "Flag to enable Virtual Machine status monitor" - type = "string" + type = string default = "true" } variable "cpu_usage_extra_tags" { description = "Extra tags for Virtual Machine status monitor" - type = "list" + type = list(string) default = [] } variable "cpu_usage_message" { description = "Custom message for Virtual Machine CPU monitor" - type = "string" + type = string default = "" } variable "cpu_usage_time_aggregator" { description = "Monitor aggregator for Virtual Machine CPU [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "cpu_usage_timeframe" { description = "Monitor timeframe for Virtual Machine CPU [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_15m" } @@ -113,31 +113,31 @@ variable "cpu_usage_threshold_critical" { variable "cpu_remaining_rate_enabled" { description = "Flag to enable Virtual Machine CPU remaining monitor" - type = "string" + type = string default = "true" } variable "cpu_remaining_rate_extra_tags" { description = "Extra tags for Virtual Machine CPU remaining monitor" - type = "list" + type = list(string) default = [] } variable "cpu_remaining_rate_message" { description = "Custom message for Virtual Machine CPU remaining monitor" - type = "string" + type = string default = "" } variable "cpu_remaining_rate_time_aggregator" { description = "Monitor aggregator for Virtual Machine CPU remaining [available values: min, max, sum or avg]" - type = "string" + type = string default = "min" } variable "cpu_remaining_rate_timeframe" { description = "Monitor timeframe for Virtual Machine CPU remaining [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -150,3 +150,4 @@ variable "cpu_remaining_rate_threshold_critical" { description = "Virtual Machine CPU rate limit (critical threshold)" default = 15 } + diff --git a/cloud/azure/virtual-machine/modules.tf b/cloud/azure/virtual-machine/modules.tf index 9967458..8be2bf9 100644 --- a/cloud/azure/virtual-machine/modules.tf +++ b/cloud/azure/virtual-machine/modules.tf @@ -1,9 +1,10 @@ module "filter-tags" { source = "../../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "azure_virtual-machine" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded } + diff --git a/cloud/azure/virtual-machine/monitors-virtual-machine.tf b/cloud/azure/virtual-machine/monitors-virtual-machine.tf index aaeddc7..3ed46e6 100644 --- a/cloud/azure/virtual-machine/monitors-virtual-machine.tf +++ b/cloud/azure/virtual-machine/monitors-virtual-machine.tf @@ -1,91 +1,88 @@ resource "datadog_monitor" "virtualmachine_status" { - count = "${var.status_enabled == "true" ? 1 : 0}" - + count = var.status_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Virtual Machine is unreachable" - message = "${coalesce(var.status_message, var.message)}" + message = coalesce(var.status_message, var.message) + type = "query alert" query = < ${var.cpu_usage_threshold_critical} - EOQ +EOQ - type = "query alert" +thresholds = { +critical = var.cpu_usage_threshold_critical +warning = var.cpu_usage_threshold_warning +} - thresholds { - critical = "${var.cpu_usage_threshold_critical}" - warning = "${var.cpu_usage_threshold_warning}" - } +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 - 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:azure", "resource:virtualmachine", "team:claranet", "created-by:terraform", "${var.cpu_usage_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:virtualmachine", "team:claranet", "created-by:terraform", var.cpu_usage_extra_tags] } resource "datadog_monitor" "virtualmachine_credit_cpu_remaining_too_low" { - count = "${var.cpu_remaining_rate_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Virtual Machine credit CPU {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.cpu_remaining_rate_message, var.message)}" +count = var.cpu_remaining_rate_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Virtual Machine credit CPU {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +message = coalesce(var.cpu_remaining_rate_message, var.message) + type = "query alert" - query = < ${var.concurrent_queries_threshold_critical} - EOQ + avg(${var.concurrent_queries_timeframe}): + default(avg:gcp.bigquery.query.count{${var.filter_tags}}, 0) + > ${var.concurrent_queries_threshold_critical} +EOQ - thresholds { - warning = "${var.concurrent_queries_threshold_warning}" - critical = "${var.concurrent_queries_threshold_critical}" + thresholds = { + warning = var.concurrent_queries_threshold_warning + critical = var.concurrent_queries_threshold_critical } - include_tags = true - notify_no_data = false + include_tags = true + notify_no_data = false require_full_window = false - renotify_interval = 0 - notify_audit = false - timeout_h = 0 - locked = false + renotify_interval = 0 + notify_audit = false + timeout_h = 0 + locked = false - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:big-query", "team:claranet", "created-by:terraform", "${var.concurrent_queries_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:big-query", "team:claranet", "created-by:terraform", var.concurrent_queries_extra_tags] } # # Execution Time # resource "datadog_monitor" "execution_time" { - count = "${var.execution_time_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] GCP Big Query Execution Time {{#is_alert}}{{{comparator}}} {{threshold}}s ({{value}}s){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}s ({{value}}s){{/is_warning}}" - message = "${coalesce(var.execution_time_message, var.message)}" - + count = var.execution_time_enabled == "true" ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] GCP Big Query Execution Time {{#is_alert}}{{{comparator}}} {{threshold}}s ({{value}}s){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}s ({{value}}s){{/is_warning}}" + message = coalesce(var.execution_time_message, var.message) type = "query alert" query = < ${var.execution_time_threshold_critical} - EOQ + avg(${var.execution_time_timeframe}): + default(avg:gcp.bigquery.query.execution_times.avg{${var.filter_tags}}, 0) + > ${var.execution_time_threshold_critical} +EOQ - thresholds { - warning = "${var.execution_time_threshold_warning}" - critical = "${var.execution_time_threshold_critical}" - } +thresholds = { +warning = var.execution_time_threshold_warning +critical = var.execution_time_threshold_critical +} - include_tags = true - notify_no_data = false - require_full_window = false - renotify_interval = 0 - notify_audit = false - timeout_h = 0 - locked = false +include_tags = true +notify_no_data = false +require_full_window = false +renotify_interval = 0 +notify_audit = false +timeout_h = 0 +locked = false - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:big-query", "team:claranet", "created-by:terraform", "${var.execution_time_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:big-query", "team:claranet", "created-by:terraform", var.execution_time_extra_tags] } # # Scanned Bytes # resource "datadog_monitor" "scanned_bytes" { - count = "${var.scanned_bytes_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] GCP Big Query Scanned Bytes {{#is_alert}}{{{comparator}}} {{threshold}}B/mn ({{value}}B/mn){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}B/mn ({{value}}B/mn){{/is_warning}}" - message = "${coalesce(var.scanned_bytes_message, var.message)}" - +count = var.scanned_bytes_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] GCP Big Query Scanned Bytes {{#is_alert}}{{{comparator}}} {{threshold}}B/mn ({{value}}B/mn){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}B/mn ({{value}}B/mn){{/is_warning}}" +message = coalesce(var.scanned_bytes_message, var.message) type = "query alert" - query = < ${var.scanned_bytes_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.scanned_bytes_threshold_warning}" - critical = "${var.scanned_bytes_threshold_critical}" - } +thresholds = { +warning = var.scanned_bytes_threshold_warning +critical = var.scanned_bytes_threshold_critical +} - include_tags = true - notify_no_data = false - require_full_window = false - renotify_interval = 0 - notify_audit = false - timeout_h = 0 - locked = false +include_tags = true +notify_no_data = false +require_full_window = false +renotify_interval = 0 +notify_audit = false +timeout_h = 0 +locked = false - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:big-query", "team:claranet", "created-by:terraform", "${var.scanned_bytes_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:big-query", "team:claranet", "created-by:terraform", var.scanned_bytes_extra_tags] } # # Scanned Bytes Billed # resource "datadog_monitor" "scanned_bytes_billed" { - count = "${var.scanned_bytes_billed_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] GCP Big Query Scanned Bytes Billed {{#is_alert}}{{{comparator}}} {{threshold}}B/mn ({{value}}B/mn){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}B/mn ({{value}}B/mn){{/is_warning}}" - message = "${coalesce(var.scanned_bytes_billed_message, var.message)}" - +count = var.scanned_bytes_billed_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] GCP Big Query Scanned Bytes Billed {{#is_alert}}{{{comparator}}} {{threshold}}B/mn ({{value}}B/mn){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}B/mn ({{value}}B/mn){{/is_warning}}" +message = coalesce(var.scanned_bytes_billed_message, var.message) type = "query alert" - query = < ${var.scanned_bytes_billed_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.scanned_bytes_billed_threshold_warning}" - critical = "${var.scanned_bytes_billed_threshold_critical}" + thresholds = { + warning = var.scanned_bytes_billed_threshold_warning + critical = var.scanned_bytes_billed_threshold_critical } include_tags = true @@ -128,132 +128,133 @@ resource "datadog_monitor" "scanned_bytes_billed" { timeout_h = 0 locked = false - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:big-query", "team:claranet", "created-by:terraform", "${var.scanned_bytes_billed_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:big-query", "team:claranet", "created-by:terraform", var.scanned_bytes_billed_extra_tags] } # # Available Slots # resource "datadog_monitor" "available_slots" { - count = "${var.available_slots_enabled == "true" ? 1 : 0}" + count = var.available_slots_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] GCP Big Query Available Slots {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}" - message = "${coalesce(var.available_slots_message, var.message)}" - + message = coalesce(var.available_slots_message, var.message) type = "metric alert" query = < ${var.stored_bytes_threshold_critical} - EOQ + avg(${var.stored_bytes_timeframe}): + default(avg:gcp.bigquery.storage.stored_bytes{${var.filter_tags}} by {dataset_id,table}, 0) + > ${var.stored_bytes_threshold_critical} +EOQ - thresholds { - warning = "${var.stored_bytes_threshold_warning}" - critical = "${var.stored_bytes_threshold_critical}" - } - include_tags = true - notify_no_data = false - require_full_window = false - renotify_interval = 0 - notify_audit = false - timeout_h = 0 - locked = false +thresholds = { +warning = var.stored_bytes_threshold_warning +critical = var.stored_bytes_threshold_critical +} - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" +include_tags = true +notify_no_data = false +require_full_window = false +renotify_interval = 0 +notify_audit = false +timeout_h = 0 +locked = false - tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:big-query", "team:claranet", "created-by:terraform", "${var.stored_bytes_extra_tags}"] +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay + +tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:big-query", "team:claranet", "created-by:terraform", var.stored_bytes_extra_tags] } # # Table Count # resource "datadog_monitor" "table_count" { - count = "${var.table_count_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] GCP Big Query Table Count {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}" - message = "${coalesce(var.table_count_message, var.message)}" +count = var.table_count_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] GCP Big Query Table Count {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}" +message = coalesce(var.table_count_message, var.message) +type = "metric alert" - type = "metric alert" - - query = < ${var.table_count_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.table_count_threshold_warning}" - critical = "${var.table_count_threshold_critical}" - } +thresholds = { +warning = var.table_count_threshold_warning +critical = var.table_count_threshold_critical +} - include_tags = true - notify_no_data = false - require_full_window = false - renotify_interval = 0 - notify_audit = false - timeout_h = 0 - locked = false +include_tags = true +notify_no_data = false +require_full_window = false +renotify_interval = 0 +notify_audit = false +timeout_h = 0 +locked = false - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:big-query", "team:claranet", "created-by:terraform", "${var.table_count_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:big-query", "team:claranet", "created-by:terraform", var.table_count_extra_tags] } # # Uploaded Bytes # resource "datadog_monitor" "uploaded_bytes" { - count = "${var.uploaded_bytes_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] GCP Big Query Uploaded Bytes {{#is_alert}}{{{comparator}}} {{threshold}}B/mn ({{value}}B/mn){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}B/mn ({{value}}B/mn){{/is_warning}}" - message = "${coalesce(var.uploaded_bytes_message, var.message)}" - +count = var.uploaded_bytes_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] GCP Big Query Uploaded Bytes {{#is_alert}}{{{comparator}}} {{threshold}}B/mn ({{value}}B/mn){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}B/mn ({{value}}B/mn){{/is_warning}}" +message = coalesce(var.uploaded_bytes_message, var.message) type = "query alert" - query = < ${var.uploaded_bytes_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.uploaded_bytes_threshold_warning}" - critical = "${var.uploaded_bytes_threshold_critical}" + thresholds = { + warning = var.uploaded_bytes_threshold_warning + critical = var.uploaded_bytes_threshold_critical } include_tags = true @@ -264,42 +265,43 @@ resource "datadog_monitor" "uploaded_bytes" { timeout_h = 0 locked = false - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:big-query", "team:claranet", "created-by:terraform", "${var.uploaded_bytes_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:big-query", "team:claranet", "created-by:terraform", var.uploaded_bytes_extra_tags] } # # Uploaded Bytes Billed # resource "datadog_monitor" "uploaded_bytes_billed" { - count = "${var.uploaded_bytes_billed_enabled == "true" ? 1 : 0}" + count = var.uploaded_bytes_billed_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] GCP Big Query Uploaded Bytes Billed {{#is_alert}}{{{comparator}}} {{threshold}}B/mn ({{value}}B/mn){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}B/mn ({{value}}B/mn){{/is_warning}}" - message = "${coalesce(var.uploaded_bytes_billed_message, var.message)}" - + message = coalesce(var.uploaded_bytes_billed_message, var.message) type = "query alert" query = < ${var.uploaded_bytes_billed_threshold_critical} - EOQ + avg(${var.uploaded_bytes_billed_timeframe}): + default(avg:gcp.bigquery.storage.uploaded_bytes_billed{${var.filter_tags}} by {dataset_id,table}, 0) + > ${var.uploaded_bytes_billed_threshold_critical} +EOQ - thresholds { - warning = "${var.uploaded_bytes_billed_threshold_warning}" - critical = "${var.uploaded_bytes_billed_threshold_critical}" + thresholds = { + warning = var.uploaded_bytes_billed_threshold_warning + critical = var.uploaded_bytes_billed_threshold_critical } - include_tags = true - notify_no_data = false + include_tags = true + notify_no_data = false require_full_window = false - renotify_interval = 0 - notify_audit = false - timeout_h = 0 - locked = false + renotify_interval = 0 + notify_audit = false + timeout_h = 0 + locked = false - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:big-query", "team:claranet", "created-by:terraform", "${var.uploaded_bytes_billed_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:big-query", "team:claranet", "created-by:terraform", var.uploaded_bytes_billed_extra_tags] } + diff --git a/cloud/gcp/big-query/outputs.tf b/cloud/gcp/big-query/outputs.tf index be9de5f..e38f8d1 100644 --- a/cloud/gcp/big-query/outputs.tf +++ b/cloud/gcp/big-query/outputs.tf @@ -1,44 +1,45 @@ output "concurrent_queries_id" { description = "id for monitor concurrent_queries" - value = "${datadog_monitor.concurrent_queries.*.id}" + value = datadog_monitor.concurrent_queries.*.id } output "execution_time_id" { description = "id for monitor execution_time" - value = "${datadog_monitor.execution_time.*.id}" + value = datadog_monitor.execution_time.*.id } output "scanned_bytes_id" { description = "id for monitor scanned_bytes" - value = "${datadog_monitor.scanned_bytes.*.id}" + value = datadog_monitor.scanned_bytes.*.id } output "scanned_bytes_billed_id" { description = "id for monitor scanned_bytes_billed" - value = "${datadog_monitor.scanned_bytes_billed.*.id}" + value = datadog_monitor.scanned_bytes_billed.*.id } output "available_slots_id" { description = "id for monitor available_slots" - value = "${datadog_monitor.available_slots.*.id}" + value = datadog_monitor.available_slots.*.id } output "stored_bytes_id" { description = "id for monitor stored_bytes" - value = "${datadog_monitor.stored_bytes.*.id}" + value = datadog_monitor.stored_bytes.*.id } output "table_count_id" { description = "id for monitor table_count" - value = "${datadog_monitor.table_count.*.id}" + value = datadog_monitor.table_count.*.id } output "uploaded_bytes_id" { description = "id for monitor uploaded_bytes" - value = "${datadog_monitor.uploaded_bytes.*.id}" + value = datadog_monitor.uploaded_bytes.*.id } output "uploaded_bytes_billed_id" { description = "id for monitor uploaded_bytes_billed" - value = "${datadog_monitor.uploaded_bytes_billed.*.id}" + value = datadog_monitor.uploaded_bytes_billed.*.id } + diff --git a/cloud/gcp/big-query/versions.tf b/cloud/gcp/big-query/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/cloud/gcp/big-query/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/cloud/gcp/cloud-sql/common/inputs.tf b/cloud/gcp/cloud-sql/common/inputs.tf index 74743f8..9ee91df 100644 --- a/cloud/gcp/cloud-sql/common/inputs.tf +++ b/cloud/gcp/cloud-sql/common/inputs.tf @@ -3,7 +3,7 @@ # variable "environment" { description = "Architecture environment" - type = "string" + type = string } variable "filter_tags" { @@ -36,43 +36,43 @@ variable "prefix_slug" { variable "cpu_utilization_message" { description = "Custom message for the CPU Utilization monitor" - type = "string" + type = string default = "" } variable "cpu_utilization_time_aggregator" { description = "Time aggregator for the CPU Utilization monitor" - type = "string" + type = string default = "avg" } variable "cpu_utilization_timeframe" { description = "Timeframe for the CPU Utilization monitor" - type = "string" + type = string default = "last_15m" } variable "cpu_utilization_threshold_warning" { description = "CPU Utilization in percentage (warning threshold)" - type = "string" + type = string default = 80 } variable "cpu_utilization_threshold_critical" { description = "CPU Utilization in percentage (critical threshold)" - type = "string" + type = string default = 90 } variable "cpu_utilization_enabled" { description = "Flag to enable GCP Cloud SQL CPU Utilization monitor" - type = "string" + type = string default = "true" } variable "cpu_utilization_extra_tags" { description = "Extra tags for GCP Cloud SQL CPU Utilization monitor" - type = "list" + type = list(string) default = [] } @@ -82,43 +82,43 @@ variable "cpu_utilization_extra_tags" { variable "disk_utilization_message" { description = "Custom message for the Disk Utilization monitor" - type = "string" + type = string default = "" } variable "disk_utilization_time_aggregator" { description = "Time aggregator for the Disk Utilization monitor" - type = "string" + type = string default = "avg" } variable "disk_utilization_timeframe" { description = "Timeframe for the Disk Utilization monitor" - type = "string" + type = string default = "last_5m" } variable "disk_utilization_threshold_warning" { description = "Disk Utilization in percentage (warning threshold)" - type = "string" + type = string default = 80 } variable "disk_utilization_threshold_critical" { description = "Disk Utilization in percentage (critical threshold)" - type = "string" + type = string default = 90 } variable "disk_utilization_enabled" { description = "Flag to enable GCP Cloud SQL Disk Utilization monitor" - type = "string" + type = string default = "true" } variable "disk_utilization_extra_tags" { description = "Extra tags for GCP Cloud SQL CPU Utilization monitor" - type = "list" + type = list(string) default = [] } @@ -128,79 +128,79 @@ variable "disk_utilization_extra_tags" { variable "disk_utilization_forecast_message" { description = "Custom message for the Disk Utilization Forecast monitor" - type = "string" + type = string default = "" } variable "disk_utilization_forecast_time_aggregator" { description = "Time aggregator for the Disk Utilization Forecast monitor" - type = "string" + type = string default = "max" } variable "disk_utilization_forecast_timeframe" { description = "Timeframe for the Disk Utilization Forecast monitor" - type = "string" + type = string default = "next_1w" } variable "disk_utilization_forecast_algorithm" { description = "Algorithm for the Disk Utilization Forecast monitor" - type = "string" + type = string default = "linear" } variable "disk_utilization_forecast_deviations" { description = "Deviations for the Disk Utilization Forecast monitor" - type = "string" + type = string default = 1 } variable "disk_utilization_forecast_interval" { description = "Interval for the Disk Utilization Forecast monitor" - type = "string" + type = string default = "60m" } variable "disk_utilization_forecast_linear_history" { description = "History for the Disk Utilization Forecast monitor" - type = "string" + type = string default = "3d" } variable "disk_utilization_forecast_linear_model" { description = "Model for the Disk Utilization Forecast monitor" - type = "string" + type = string default = "default" } variable "disk_utilization_forecast_seasonal_seasonality" { description = "Seasonality for the Disk Utilization Forecast monitor" - type = "string" + type = string default = "weekly" } variable "disk_utilization_forecast_threshold_critical" { description = "Disk Utilization Forecast in percentage (critical threshold)" - type = "string" + type = string default = 80 } variable "disk_utilization_forecast_threshold_critical_recovery" { description = "Disk Utilization Forecast in percentage (recovery threshold)" - type = "string" + type = string default = 72 } variable "disk_utilization_forecast_enabled" { description = "Flag to enable GCP Cloud SQL Disk Utilization Forecast monitor" - type = "string" + type = string default = "true" } variable "disk_utilization_forecast_extra_tags" { description = "Extra tags for GCP Cloud SQL Disk Utilization Forecast monitor" - type = "list" + type = list(string) default = [] } @@ -235,13 +235,13 @@ variable "memory_utilization_threshold_critical" { variable "memory_utilization_enabled" { description = "Flag to enable GCP Cloud SQL Memory Utilization monitor" - type = "string" + type = string default = "true" } variable "memory_utilization_extra_tags" { description = "Extra tags for GCP Cloud SQL Memory Utilization monitor" - type = "list" + type = list(string) default = [] } @@ -266,37 +266,37 @@ variable "memory_utilization_forecast_timeframe" { variable "memory_utilization_forecast_algorithm" { description = "Algorithm for the Memory Utilization Forecast monitor" - type = "string" + type = string default = "linear" } variable "memory_utilization_forecast_deviations" { description = "Deviations for the Memory Utilization Forecast monitor" - type = "string" + type = string default = 1 } variable "memory_utilization_forecast_interval" { description = "Interval for the Memory Utilization Forecast monitor" - type = "string" + type = string default = "30m" } variable "memory_utilization_forecast_linear_history" { description = "History for the Memory Utilization Forecast monitor" - type = "string" + type = string default = "12h" } variable "memory_utilization_forecast_linear_model" { description = "Model for the Memory Utilization Forecast monitor" - type = "string" + type = string default = "default" } variable "memory_utilization_forecast_seasonal_seasonality" { description = "Seasonality for the Memory Utilization Forecast monitor" - type = "string" + type = string default = "weekly" } @@ -312,13 +312,13 @@ variable "memory_utilization_forecast_threshold_critical_recovery" { variable "memory_utilization_forecast_enabled" { description = "Flag to enable GCP Cloud SQL Memory Utilization Forecast monitor" - type = "string" + type = string default = "true" } variable "memory_utilization_forecast_extra_tags" { description = "Extra tags for GCP Cloud SQL Memory Utilization Forecast monitor" - type = "list" + type = list(string) default = [] } @@ -328,36 +328,37 @@ variable "memory_utilization_forecast_extra_tags" { variable "failover_unavailable_message" { description = "Custom message for the Failover Unavailable monitor" - type = "string" + type = string default = "" } variable "failover_unavailable_time_aggregator" { description = "Time aggreggator for the Failover Unavailable monitor" - type = "string" + type = string default = "max" } variable "failover_unavailable_timeframe" { description = "Timeframe for the Failover Unavailable monitor" - type = "string" + type = string default = "last_10m" } variable "failover_unavailable_threshold_critical" { description = "Failover Unavailable critical threshold" - type = "string" + type = string default = 0 } variable "failover_unavailable_enabled" { description = "Flag to enable GCP Cloud SQL Failover Unavailable monitor" - type = "string" + type = string default = "true" } variable "failover_unavailable_extra_tags" { description = "Extra tags for GCP Cloud SQL Failover Unavailable monitor" - type = "list" + type = list(string) default = [] } + diff --git a/cloud/gcp/cloud-sql/common/monitors-cloud-sql-common.tf b/cloud/gcp/cloud-sql/common/monitors-cloud-sql-common.tf index c422129..c712095 100644 --- a/cloud/gcp/cloud-sql/common/monitors-cloud-sql-common.tf +++ b/cloud/gcp/cloud-sql/common/monitors-cloud-sql-common.tf @@ -2,100 +2,102 @@ # CPU Utilization # resource "datadog_monitor" "cpu_utilization" { - count = "${var.cpu_utilization_enabled == "true" ? 1 : 0}" + count = var.cpu_utilization_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Cloud SQL CPU Utilization {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.cpu_utilization_message, var.message)}" - + message = coalesce(var.cpu_utilization_message, var.message) type = "query alert" query = < ${var.cpu_utilization_threshold_critical} - EOQ + ${var.cpu_utilization_time_aggregator}(${var.cpu_utilization_timeframe}): + avg:gcp.cloudsql.database.cpu.utilization{${var.filter_tags}} by {database_id} * 100 + > ${var.cpu_utilization_threshold_critical} +EOQ - thresholds { - warning = "${var.cpu_utilization_threshold_warning}" - critical = "${var.cpu_utilization_threshold_critical}" + thresholds = { + warning = var.cpu_utilization_threshold_warning + critical = var.cpu_utilization_threshold_critical } - notify_audit = false - locked = false - timeout_h = 0 - include_tags = true + notify_audit = false + locked = false + timeout_h = 0 + include_tags = true require_full_window = false notify_no_data = false renotify_interval = 0 - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:cloud-sql", "team:claranet", "created-by:terraform", "${var.cpu_utilization_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:cloud-sql", "team:claranet", "created-by:terraform", var.cpu_utilization_extra_tags] } # # Disk Utilization # resource "datadog_monitor" "disk_utilization" { - count = "${var.disk_utilization_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Cloud SQL Disk Utilization {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.disk_utilization_message, var.message)}" - + count = var.disk_utilization_enabled == "true" ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Cloud SQL Disk Utilization {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" + message = coalesce(var.disk_utilization_message, var.message) type = "query alert" query = < ${var.disk_utilization_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.disk_utilization_threshold_warning}" - critical = "${var.disk_utilization_threshold_critical}" - } +thresholds = { +warning = var.disk_utilization_threshold_warning +critical = var.disk_utilization_threshold_critical +} - notify_audit = false - locked = false - timeout_h = 0 - include_tags = true - require_full_window = false - notify_no_data = true - renotify_interval = 0 +notify_audit = false +locked = false +timeout_h = 0 +include_tags = true +require_full_window = false +notify_no_data = true +renotify_interval = 0 - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:cloud-sql", "team:claranet", "created-by:terraform", "${var.disk_utilization_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:cloud-sql", "team:claranet", "created-by:terraform", var.disk_utilization_extra_tags] } # # Disk Utilization Forecast # resource "datadog_monitor" "disk_utilization_forecast" { - count = "${var.disk_utilization_forecast_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Cloud SQL Disk Utilization could reach {{#is_alert}}{{threshold}}%{{/is_alert}} in a near future" - message = "${coalesce(var.disk_utilization_forecast_message, var.message)}" - +count = var.disk_utilization_forecast_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Cloud SQL Disk Utilization could reach {{#is_alert}}{{threshold}}%%{{/is_alert}} in a near future" +message = coalesce(var.disk_utilization_forecast_message, var.message) type = "query alert" - query = <= ${var.disk_utilization_forecast_threshold_critical} - EOQ +EOQ - thresholds { - critical = "${var.disk_utilization_forecast_threshold_critical}" - critical_recovery = "${var.disk_utilization_forecast_threshold_critical_recovery}" + thresholds = { + critical = var.disk_utilization_forecast_threshold_critical + critical_recovery = var.disk_utilization_forecast_threshold_critical_recovery } notify_audit = false @@ -106,121 +108,126 @@ resource "datadog_monitor" "disk_utilization_forecast" { notify_no_data = false renotify_interval = 0 - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:cloud-sql", "team:claranet", "created-by:terraform", "${var.disk_utilization_forecast_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:cloud-sql", "team:claranet", "created-by:terraform", var.disk_utilization_forecast_extra_tags] } # # Memory Utilization # resource "datadog_monitor" "memory_utilization" { - count = "${var.memory_utilization_enabled == "true" ? 1 : 0}" + count = var.memory_utilization_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Cloud SQL Memory Utilization {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.memory_utilization_message, var.message)}" - + message = coalesce(var.memory_utilization_message, var.message) type = "query alert" query = < ${var.memory_utilization_threshold_critical} - EOQ + ${var.memory_utilization_time_aggregator}(${var.memory_utilization_timeframe}): + avg:gcp.cloudsql.database.memory.utilization{${var.filter_tags}} by {database_id} * 100 + > ${var.memory_utilization_threshold_critical} +EOQ - thresholds { - warning = "${var.memory_utilization_threshold_warning}" - critical = "${var.memory_utilization_threshold_critical}" + thresholds = { + warning = var.memory_utilization_threshold_warning + critical = var.memory_utilization_threshold_critical } - notify_audit = false - locked = false - timeout_h = 0 - include_tags = true + notify_audit = false + locked = false + timeout_h = 0 + include_tags = true require_full_window = false notify_no_data = false renotify_interval = 0 - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:cloud-sql", "team:claranet", "created-by:terraform", "${var.memory_utilization_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:cloud-sql", "team:claranet", "created-by:terraform", var.memory_utilization_extra_tags] } # # Memory Utilization Forecast # resource "datadog_monitor" "memory_utilization_forecast" { - count = "${var.memory_utilization_forecast_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Cloud SQL Memory Utilization could reach {{#is_alert}}{{threshold}}%{{/is_alert}} in a near future" - message = "${coalesce(var.memory_utilization_forecast_message, var.message)}" - + count = var.memory_utilization_forecast_enabled == "true" ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Cloud SQL Memory Utilization could reach {{#is_alert}}{{threshold}}%%{{/is_alert}} in a near future" + message = coalesce(var.memory_utilization_forecast_message, var.message) type = "query alert" query = <= ${var.memory_utilization_forecast_threshold_critical} - EOQ +EOQ - thresholds { - critical = "${var.memory_utilization_forecast_threshold_critical}" - critical_recovery = "${var.memory_utilization_forecast_threshold_critical_recovery}" - } + thresholds = { + critical = var.memory_utilization_forecast_threshold_critical + critical_recovery = var.memory_utilization_forecast_threshold_critical_recovery + } - notify_audit = false - locked = false - timeout_h = 0 - include_tags = true - require_full_window = false - notify_no_data = false - renotify_interval = 0 + notify_audit = false + locked = false + timeout_h = 0 + include_tags = true + require_full_window = false + notify_no_data = false + renotify_interval = 0 - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:cloud-sql", "team:claranet", "created-by:terraform", "${var.memory_utilization_forecast_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:cloud-sql", "team:claranet", "created-by:terraform", var.memory_utilization_forecast_extra_tags] } # # Failover Unavailable # resource "datadog_monitor" "failover_unavailable" { - count = "${var.failover_unavailable_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Cloud SQL Failover Unavailable" - message = "${coalesce(var.failover_unavailable_message, var.message)}" +count = var.failover_unavailable_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Cloud SQL Failover Unavailable" +message = coalesce(var.failover_unavailable_message, var.message) - type = "metric alert" +type = "metric alert" - query = < ${var.replication_lag_threshold_critical} - EOQ + ${var.replication_lag_time_aggregator}(${var.replication_lag_timeframe}): + avg:gcp.cloudsql.database.mysql.replication.seconds_behind_master{${var.filter_tags}} by {database_id} + > ${var.replication_lag_threshold_critical} +EOQ - thresholds { - critical = "${var.replication_lag_threshold_critical}" - warning = "${var.replication_lag_threshold_warning}" + thresholds = { + critical = var.replication_lag_threshold_critical + warning = var.replication_lag_threshold_warning } - notify_audit = false - locked = false - timeout_h = 0 - include_tags = true + notify_audit = false + locked = false + timeout_h = 0 + include_tags = true require_full_window = false - notify_no_data = true - renotify_interval = 0 + notify_no_data = true + renotify_interval = 0 - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:cloud-sql", "team:claranet", "created-by:terraform", "engine:mysql", "${var.replication_lag_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:cloud-sql", "team:claranet", "created-by:terraform", "engine:mysql", var.replication_lag_extra_tags] } + diff --git a/cloud/gcp/cloud-sql/mysql/outputs.tf b/cloud/gcp/cloud-sql/mysql/outputs.tf index e8e24fd..3134033 100644 --- a/cloud/gcp/cloud-sql/mysql/outputs.tf +++ b/cloud/gcp/cloud-sql/mysql/outputs.tf @@ -1,4 +1,5 @@ output "replication_lag_id" { description = "id for monitor replication_lag" - value = "${datadog_monitor.replication_lag.*.id}" + value = datadog_monitor.replication_lag.*.id } + diff --git a/cloud/gcp/cloud-sql/mysql/versions.tf b/cloud/gcp/cloud-sql/mysql/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/cloud/gcp/cloud-sql/mysql/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/cloud/gcp/gce/instance/inputs.tf b/cloud/gcp/gce/instance/inputs.tf index 0277a47..119a755 100644 --- a/cloud/gcp/gce/instance/inputs.tf +++ b/cloud/gcp/gce/instance/inputs.tf @@ -3,7 +3,7 @@ # variable "environment" { description = "Architecture environment" - type = "string" + type = string } variable "filter_tags" { @@ -36,43 +36,43 @@ variable "prefix_slug" { variable "cpu_utilization_message" { description = "Custom message for the CPU Utilization monitor" - type = "string" + type = string default = "" } variable "cpu_utilization_time_aggregator" { description = "Time aggregator for the CPU Utilization monitor" - type = "string" + type = string default = "avg" } variable "cpu_utilization_timeframe" { description = "Timeframe for the CPU Utilization monitor" - type = "string" + type = string default = "last_15m" } variable "cpu_utilization_threshold_warning" { description = "CPU Utilization in percentage (warning threshold)" - type = "string" + type = string default = 80 } variable "cpu_utilization_threshold_critical" { description = "CPU Utilization in percentage (critical threshold)" - type = "string" + type = string default = 90 } variable "cpu_utilization_enabled" { description = "Flag to enable CPU Utilization monitor" - type = "string" + type = string default = "true" } variable "cpu_utilization_extra_tags" { description = "Extra tags for CPU Utilization monitor" - type = "list" + type = list(string) default = [] } @@ -82,49 +82,49 @@ variable "cpu_utilization_extra_tags" { variable "disk_throttled_bps_message" { description = "Custom message for the Disk Throttled Bps monitor" - type = "string" + type = string default = "" } variable "disk_throttled_bps_time_aggregator" { description = "Time aggregator for the Disk Throttled Bps monitor" - type = "string" + type = string default = "min" } variable "disk_throttled_bps_timeframe" { description = "Timeframe for the Disk Throttled Bps monitor" - type = "string" + type = string default = "last_15m" } variable "disk_throttled_bps_threshold_warning" { description = "Disk Throttled Bps in percentage (warning threshold)" - type = "string" + type = string default = 30 } variable "disk_throttled_bps_threshold_critical" { description = "Disk Throttled Bps in percentage (critical threshold)" - type = "string" + type = string default = 50 } variable "disk_throttled_bps_enabled" { description = "Flag to enable Disk Throttled Bps monitor" - type = "string" + type = string default = "true" } variable "disk_throttled_bps_extra_tags" { description = "Extra tags for Disk Throttled Bps monitor" - type = "list" + type = list(string) default = [] } variable "disk_throttled_bps_notify_no_data" { description = "Flag to enable notification for no data on Disk Throttled Bps monitor" - type = "string" + type = string default = "false" } @@ -134,48 +134,49 @@ variable "disk_throttled_bps_notify_no_data" { variable "disk_throttled_ops_message" { description = "Custom message for the Disk Throttled OPS monitor" - type = "string" + type = string default = "" } variable "disk_throttled_ops_time_aggregator" { description = "Time aggregator for the Disk Throttled OPS monitor" - type = "string" + type = string default = "min" } variable "disk_throttled_ops_timeframe" { description = "Timeframe for the Disk Throttled OPS monitor" - type = "string" + type = string default = "last_15m" } variable "disk_throttled_ops_threshold_warning" { description = "Disk Throttled OPS in percentage (warning threshold)" - type = "string" + type = string default = 30 } variable "disk_throttled_ops_threshold_critical" { description = "Disk Throttled OPS in percentage (critical threshold)" - type = "string" + type = string default = 50 } variable "disk_throttled_ops_enabled" { description = "Flag to enable Disk Throttled OPS monitor" - type = "string" + type = string default = "true" } variable "disk_throttled_ops_extra_tags" { description = "Extra tags for Disk Throttled OPS monitor" - type = "list" + type = list(string) default = [] } variable "disk_throttled_ops_notify_no_data" { description = "Flag to enable notification for no data on Disk Throttled OPS monitor" - type = "string" + type = string default = "false" } + diff --git a/cloud/gcp/gce/instance/monitors-gce-instance.tf b/cloud/gcp/gce/instance/monitors-gce-instance.tf index b23d8c3..808bc4a 100644 --- a/cloud/gcp/gce/instance/monitors-gce-instance.tf +++ b/cloud/gcp/gce/instance/monitors-gce-instance.tf @@ -2,45 +2,43 @@ # CPU Utilization # resource "datadog_monitor" "cpu_utilization" { - count = "${var.cpu_utilization_enabled == "true" ? 1 : 0}" + count = var.cpu_utilization_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Compute Engine instance CPU Utilization {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.cpu_utilization_message, var.message)}" - + message = coalesce(var.cpu_utilization_message, var.message) type = "query alert" query = < ${var.cpu_utilization_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.cpu_utilization_threshold_warning}" - critical = "${var.cpu_utilization_threshold_critical}" + thresholds = { + warning = var.cpu_utilization_threshold_warning + critical = var.cpu_utilization_threshold_critical } - notify_audit = false - locked = false - timeout_h = 0 - include_tags = true + notify_audit = false + locked = false + timeout_h = 0 + include_tags = true require_full_window = false - notify_no_data = true - renotify_interval = 0 + notify_no_data = true + renotify_interval = 0 - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:gce-instance", "team:claranet", "created-by:terraform", "${var.cpu_utilization_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:gce-instance", "team:claranet", "created-by:terraform", var.cpu_utilization_extra_tags] } # # Disk Throttled Bps # resource "datadog_monitor" "disk_throttled_bps" { - count = "${var.disk_throttled_bps_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Compute Engine instance Disk Throttled Bps {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.disk_throttled_bps_message, var.message)}" - + count = var.disk_throttled_bps_enabled == "true" ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Compute Engine instance Disk Throttled Bps {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" + message = coalesce(var.disk_throttled_bps_message, var.message) type = "query alert" query = < ${var.disk_throttled_bps_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.disk_throttled_bps_threshold_warning}" - critical = "${var.disk_throttled_bps_threshold_critical}" - } +thresholds = { +warning = var.disk_throttled_bps_threshold_warning +critical = var.disk_throttled_bps_threshold_critical +} - notify_audit = false - locked = false - timeout_h = 0 - include_tags = true - require_full_window = false - notify_no_data = "${var.disk_throttled_bps_notify_no_data}" - renotify_interval = 0 +notify_audit = false +locked = false +timeout_h = 0 +include_tags = true +require_full_window = false +notify_no_data = var.disk_throttled_bps_notify_no_data +renotify_interval = 0 - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:gce-instance", "team:claranet", "created-by:terraform", "${var.disk_throttled_bps_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:gce-instance", "team:claranet", "created-by:terraform", var.disk_throttled_bps_extra_tags] } # # Disk Throttled OPS # resource "datadog_monitor" "disk_throttled_ops" { - count = "${var.disk_throttled_ops_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Compute Engine instance Disk Throttled OPS {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.disk_throttled_ops_message, var.message)}" - +count = var.disk_throttled_ops_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Compute Engine instance Disk Throttled OPS {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +message = coalesce(var.disk_throttled_ops_message, var.message) type = "query alert" - query = < ${var.disk_throttled_ops_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.disk_throttled_ops_threshold_warning}" - critical = "${var.disk_throttled_ops_threshold_critical}" - } - - notify_audit = false - locked = false - timeout_h = 0 - include_tags = true - require_full_window = false - notify_no_data = "${var.disk_throttled_ops_notify_no_data}" - renotify_interval = 0 - - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" - - tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:gce-instance", "team:claranet", "created-by:terraform", "${var.disk_throttled_ops_extra_tags}"] +thresholds = { +warning = var.disk_throttled_ops_threshold_warning +critical = var.disk_throttled_ops_threshold_critical } + +notify_audit = false +locked = false +timeout_h = 0 +include_tags = true +require_full_window = false +notify_no_data = var.disk_throttled_ops_notify_no_data +renotify_interval = 0 + +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay + +tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:gce-instance", "team:claranet", "created-by:terraform", var.disk_throttled_ops_extra_tags] +} + diff --git a/cloud/gcp/gce/instance/outputs.tf b/cloud/gcp/gce/instance/outputs.tf index 04a5c63..002b395 100644 --- a/cloud/gcp/gce/instance/outputs.tf +++ b/cloud/gcp/gce/instance/outputs.tf @@ -1,14 +1,15 @@ output "cpu_utilization_id" { description = "id for monitor cpu_utilization" - value = "${datadog_monitor.cpu_utilization.*.id}" + value = datadog_monitor.cpu_utilization.*.id } output "disk_throttled_bps_id" { description = "id for monitor disk_throttled_bps" - value = "${datadog_monitor.disk_throttled_bps.*.id}" + value = datadog_monitor.disk_throttled_bps.*.id } output "disk_throttled_ops_id" { description = "id for monitor disk_throttled_ops" - value = "${datadog_monitor.disk_throttled_ops.*.id}" + value = datadog_monitor.disk_throttled_ops.*.id } + diff --git a/cloud/gcp/gce/instance/versions.tf b/cloud/gcp/gce/instance/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/cloud/gcp/gce/instance/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/cloud/gcp/lb/inputs.tf b/cloud/gcp/lb/inputs.tf index 1bf467a..072d32f 100644 --- a/cloud/gcp/lb/inputs.tf +++ b/cloud/gcp/lb/inputs.tf @@ -3,7 +3,7 @@ # variable "environment" { description = "Architecture environment" - type = "string" + type = string } variable "filter_tags" { @@ -35,49 +35,49 @@ variable "prefix_slug" { # variable "error_rate_4xx_message" { description = "Custom message for the GCP LB 4XX Errors monitor" - type = "string" + type = string default = "" } variable "error_rate_4xx_time_aggregator" { description = "Timeframe for the GCP LB 4XX Errors monitor" - type = "string" + type = string default = "min" } variable "error_rate_4xx_timeframe" { description = "Timeframe for the GCP LB 4XX Errors monitor" - type = "string" + type = string default = "last_5m" } variable "error_rate_4xx_artificial_request" { description = "Divisor Delta for the GCP LB 4XX Errors monitor" - type = "string" + type = string default = 5 } variable "error_rate_4xx_threshold_warning" { description = "Rate error in percentage (warning threshold)" - type = "string" + type = string default = 50 } variable "error_rate_4xx_threshold_critical" { description = "Rate error in percentage (critical threshold)" - type = "string" + type = string default = 60 } variable "error_rate_4xx_enabled" { description = "Flag to enable GCP LB 4XX Errors monitor" - type = "string" + type = string default = "true" } variable "error_rate_4xx_extra_tags" { description = "Extra tags for GCP LB 4XX Errors monitor" - type = "list" + type = list(string) default = [] } @@ -86,49 +86,49 @@ variable "error_rate_4xx_extra_tags" { # variable "error_rate_5xx_message" { description = "Custom message for the GCP LB 5XX Errors monitor" - type = "string" + type = string default = "" } variable "error_rate_5xx_time_aggregator" { description = "Timeframe for the GCP LB 5XX Errors monitor" - type = "string" + type = string default = "min" } variable "error_rate_5xx_timeframe" { description = "Timeframe for the GCP LB 5XX Errors monitor" - type = "string" + type = string default = "last_5m" } variable "error_rate_5xx_artificial_request" { description = "Divisor Delta for the GCP LB 5XX Errors monitor" - type = "string" + type = string default = 5 } variable "error_rate_5xx_threshold_warning" { description = "Rate error in percentage (warning threshold)" - type = "string" + type = string default = 30 } variable "error_rate_5xx_threshold_critical" { description = "Rate error in percentage (critical threshold)" - type = "string" + type = string default = 40 } variable "error_rate_5xx_enabled" { description = "Flag to enable GCP LB 5XX Errors monitor" - type = "string" + type = string default = "true" } variable "error_rate_5xx_extra_tags" { description = "Extra tags for GCP LB 5XX Errors monitor" - type = "list" + type = list(string) default = [] } @@ -137,43 +137,43 @@ variable "error_rate_5xx_extra_tags" { # variable "backend_latency_service_message" { description = "Custom message for the GCP LB Backend Latency monitor" - type = "string" + type = string default = "" } variable "backend_latency_service_time_aggregator" { description = "Timeframe for the GCP LB Backend Latency monitor" - type = "string" + type = string default = "min" } variable "backend_latency_service_timeframe" { description = "Timeframe for the GCP LB Backend Latency monitor" - type = "string" + type = string default = "last_10m" } variable "backend_latency_service_threshold_warning" { description = "Latency in milliseconds (warning threshold)" - type = "string" + type = string default = 1000 } variable "backend_latency_service_threshold_critical" { description = "Latency in milliseconds (critical threshold)" - type = "string" + type = string default = 1500 } variable "backend_latency_service_enabled" { description = "Flag to enable GCP LB Backend Latency monitor" - type = "string" + type = string default = "true" } variable "backend_latency_service_extra_tags" { description = "Extra tags for GCP LB Backend Latency monitor" - type = "list" + type = list(string) default = [] } @@ -182,43 +182,43 @@ variable "backend_latency_service_extra_tags" { # variable "backend_latency_bucket_message" { description = "Custom message for the GCP LB Backend Latency monitor" - type = "string" + type = string default = "" } variable "backend_latency_bucket_time_aggregator" { description = "Timeframe for the GCP LB Backend Latency monitor" - type = "string" + type = string default = "min" } variable "backend_latency_bucket_timeframe" { description = "Timeframe for the GCP LB Backend Latency monitor" - type = "string" + type = string default = "last_10m" } variable "backend_latency_bucket_threshold_warning" { description = "Latency in milliseconds (warning threshold)" - type = "string" + type = string default = 4000 } variable "backend_latency_bucket_threshold_critical" { description = "Latency in milliseconds (critical threshold)" - type = "string" + type = string default = 8000 } variable "backend_latency_bucket_enabled" { description = "Flag to enable GCP LB Backend Latency monitor" - type = "string" + type = string default = "true" } variable "backend_latency_bucket_extra_tags" { description = "Extra tags for GCP LB Backend Latency monitor" - type = "list" + type = list(string) default = [] } @@ -227,48 +227,49 @@ variable "backend_latency_bucket_extra_tags" { # variable "request_count_message" { description = "Custom message for the GCP LB Request Count monitor" - type = "string" + type = string default = "" } variable "request_count_time_aggregator" { description = "Timeframe for the GCP LB Request Count monitor" - type = "string" + type = string default = "sum" } variable "request_count_timeframe" { description = "Timeframe for the GCP LB Request Count monitor" - type = "string" + type = string default = "last_5m" } variable "request_count_timeshift" { description = "Timeshift for the GCP LB Request Count monitor" - type = "string" + type = string default = "last_5m" } variable "request_count_threshold_warning" { description = "Desviation in percentage (warning threshold)" - type = "string" + type = string default = 250 } variable "request_count_threshold_critical" { description = "Desviation in percentage (critical threshold)" - type = "string" + type = string default = 500 } variable "request_count_enabled" { description = "Flag to enable GCP LB Request Count monitor" - type = "string" + type = string default = "true" } variable "request_count_extra_tags" { description = "Extra tags for GCP LB Request Count monitor" - type = "list" + type = list(string) default = [] } + diff --git a/cloud/gcp/lb/monitors-lb.tf b/cloud/gcp/lb/monitors-lb.tf index f623464..e39757f 100644 --- a/cloud/gcp/lb/monitors-lb.tf +++ b/cloud/gcp/lb/monitors-lb.tf @@ -2,10 +2,9 @@ # 4XX Errors # resource "datadog_monitor" "error_rate_4xx" { - count = "${var.error_rate_4xx_enabled == "true" ? 1 : 0}" + count = var.error_rate_4xx_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] GCP LB 4xx errors {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.error_rate_4xx_message, var.message)}" - + message = coalesce(var.error_rate_4xx_message, var.message) type = "query alert" query = < ${var.error_rate_4xx_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.error_rate_4xx_threshold_warning}" - critical = "${var.error_rate_4xx_threshold_critical}" + thresholds = { + warning = var.error_rate_4xx_threshold_warning + critical = var.error_rate_4xx_threshold_critical } - notify_audit = false - locked = false - timeout_h = 0 - include_tags = true + notify_audit = false + locked = false + timeout_h = 0 + include_tags = true require_full_window = false - notify_no_data = false - renotify_interval = 0 + notify_no_data = false + renotify_interval = 0 - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:lb", "team:claranet", "created-by:terraform", "${var.error_rate_4xx_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:lb", "team:claranet", "created-by:terraform", var.error_rate_4xx_extra_tags] } # # 5XX Errors # resource "datadog_monitor" "error_rate_5xx" { - count = "${var.error_rate_5xx_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] GCP LB 5xx errors {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.error_rate_5xx_message, var.message)}" - + count = var.error_rate_5xx_enabled == "true" ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] GCP LB 5xx errors {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" + message = coalesce(var.error_rate_5xx_message, var.message) type = "query alert" query = < ${var.error_rate_5xx_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.error_rate_5xx_threshold_warning}" - critical = "${var.error_rate_5xx_threshold_critical}" - } +thresholds = { +warning = var.error_rate_5xx_threshold_warning +critical = var.error_rate_5xx_threshold_critical +} - notify_audit = false - locked = false - timeout_h = 0 - include_tags = true - require_full_window = false - notify_no_data = false - renotify_interval = 0 +notify_audit = false +locked = false +timeout_h = 0 +include_tags = true +require_full_window = false +notify_no_data = false +renotify_interval = 0 - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:lb", "team:claranet", "created-by:terraform", "${var.error_rate_5xx_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:lb", "team:claranet", "created-by:terraform", var.error_rate_5xx_extra_tags] } # # Backend Latency for service # resource "datadog_monitor" "backend_latency_service" { - count = "${var.backend_latency_service_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] GCP LB service backend latency {{#is_alert}}{{{comparator}}} {{threshold}}ms ({{value}}ms){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}ms ({{value}}ms){{/is_warning}}" - message = "${coalesce(var.backend_latency_service_message, var.message)}" - +count = var.backend_latency_service_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] GCP LB service backend latency {{#is_alert}}{{{comparator}}} {{threshold}}ms ({{value}}ms){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}ms ({{value}}ms){{/is_warning}}" +message = coalesce(var.backend_latency_service_message, var.message) type = "query alert" - query = < ${var.backend_latency_service_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.backend_latency_service_threshold_warning}" - critical = "${var.backend_latency_service_threshold_critical}" - } +thresholds = { +warning = var.backend_latency_service_threshold_warning +critical = var.backend_latency_service_threshold_critical +} - notify_audit = false - locked = false - timeout_h = 0 - include_tags = true - require_full_window = false - notify_no_data = false - renotify_interval = 0 +notify_audit = false +locked = false +timeout_h = 0 +include_tags = true +require_full_window = false +notify_no_data = false +renotify_interval = 0 - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:lb", "team:claranet", "created-by:terraform", "${var.backend_latency_service_extra_tags}"] +tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:lb", "team:claranet", "created-by:terraform", var.backend_latency_service_extra_tags] } # # Backend Latency for bucket # resource "datadog_monitor" "backend_latency_bucket" { - count = "${var.backend_latency_bucket_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] GCP LB bucket backend latency {{#is_alert}}{{{comparator}}} {{threshold}}ms ({{value}}ms){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}ms ({{value}}ms){{/is_warning}}" - message = "${coalesce(var.backend_latency_bucket_message, var.message)}" - +count = var.backend_latency_bucket_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] GCP LB bucket backend latency {{#is_alert}}{{{comparator}}} {{threshold}}ms ({{value}}ms){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}ms ({{value}}ms){{/is_warning}}" +message = coalesce(var.backend_latency_bucket_message, var.message) type = "query alert" - query = < ${var.backend_latency_bucket_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.backend_latency_bucket_threshold_warning}" - critical = "${var.backend_latency_bucket_threshold_critical}" + thresholds = { + warning = var.backend_latency_bucket_threshold_warning + critical = var.backend_latency_bucket_threshold_critical } notify_audit = false @@ -134,43 +130,43 @@ resource "datadog_monitor" "backend_latency_bucket" { notify_no_data = false renotify_interval = 0 - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:lb", "team:claranet", "created-by:terraform", "${var.backend_latency_bucket_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:lb", "team:claranet", "created-by:terraform", var.backend_latency_bucket_extra_tags] } # # Request Count # resource "datadog_monitor" "request_count" { - count = "${var.request_count_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] GCP LB Requests count increased abruptly {{#is_alert}}{{value}}%{{/is_alert}}{{#is_warning}}{{value}}%{{/is_warning}}" - message = "${coalesce(var.request_count_message, var.message)}" - + count = var.request_count_enabled == "true" ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] GCP LB Requests count increased abruptly {{#is_alert}}{{value}}%%{{/is_alert}}{{#is_warning}}{{value}}%%{{/is_warning}}" + message = coalesce(var.request_count_message, var.message) type = "query alert" query = < ${var.request_count_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.request_count_threshold_warning}" - critical = "${var.request_count_threshold_critical}" + thresholds = { + warning = var.request_count_threshold_warning + critical = var.request_count_threshold_critical } - notify_audit = false - locked = false - timeout_h = 0 - include_tags = true + notify_audit = false + locked = false + timeout_h = 0 + include_tags = true require_full_window = false - notify_no_data = false - renotify_interval = 0 + notify_no_data = false + renotify_interval = 0 - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay - tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:lb", "team:claranet", "created-by:terraform", "${var.request_count_extra_tags}"] + tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:lb", "team:claranet", "created-by:terraform", var.request_count_extra_tags] } + diff --git a/cloud/gcp/lb/outputs.tf b/cloud/gcp/lb/outputs.tf index 4718769..7e1eb55 100644 --- a/cloud/gcp/lb/outputs.tf +++ b/cloud/gcp/lb/outputs.tf @@ -1,24 +1,25 @@ output "error_rate_4xx_id" { description = "id for monitor error_rate_4xx" - value = "${datadog_monitor.error_rate_4xx.*.id}" + value = datadog_monitor.error_rate_4xx.*.id } output "error_rate_5xx_id" { description = "id for monitor error_rate_5xx" - value = "${datadog_monitor.error_rate_5xx.*.id}" + value = datadog_monitor.error_rate_5xx.*.id } output "backend_latency_service_id" { description = "id for monitor backend_latency_service" - value = "${datadog_monitor.backend_latency_service.*.id}" + value = datadog_monitor.backend_latency_service.*.id } output "backend_latency_bucket_id" { description = "id for monitor backend_latency_bucket" - value = "${datadog_monitor.backend_latency_bucket.*.id}" + value = datadog_monitor.backend_latency_bucket.*.id } output "request_count_id" { description = "id for monitor request_count" - value = "${datadog_monitor.request_count.*.id}" + value = datadog_monitor.request_count.*.id } + diff --git a/cloud/gcp/lb/versions.tf b/cloud/gcp/lb/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/cloud/gcp/lb/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/cloud/gcp/pubsub/inputs.tf b/cloud/gcp/pubsub/inputs.tf index 36325a1..8c55a19 100644 --- a/cloud/gcp/pubsub/inputs.tf +++ b/cloud/gcp/pubsub/inputs.tf @@ -3,7 +3,7 @@ # variable "environment" { description = "Architecture environment" - type = "string" + type = string } variable "filter_tags" { @@ -35,37 +35,37 @@ variable "prefix_slug" { # variable "sending_operations_count_message" { description = "Custom message for the GCP Pub/Sub Sending Operations Count monitor" - type = "string" + type = string default = "" } variable "sending_operations_count_time_aggregator" { description = "Timeframe for the GCP Pub/Sub Sending Operations Count monitor" - type = "string" + type = string default = "sum" } variable "sending_operations_count_timeframe" { description = "Timeframe for the GCP Pub/Sub Sending Operations Count monitor" - type = "string" + type = string default = "last_30m" } variable "sending_operations_count_threshold_critical" { description = "Critical threshold for the number of sending operations." - type = "string" + type = string default = 0 } variable "sending_operations_count_enabled" { description = "Flag to enable GCP Pub/Sub Unavailable Sending Operations Count monitor" - type = "string" + type = string default = "true" } variable "sending_operations_count_extra_tags" { description = "Extra tags for GCP Pub/Sub Sending Operations Count monitor" - type = "list" + type = list(string) default = [] } @@ -74,42 +74,43 @@ variable "sending_operations_count_extra_tags" { # variable "unavailable_sending_operations_count_message" { description = "Custom message for the GCP Pub/Sub Unavailable Sending Operations Count monitor" - type = "string" + type = string default = "" } variable "unavailable_sending_operations_count_time_aggregator" { description = "Timeframe for the GCP Pub/Sub Unavailable Sending Operations Count monitor" - type = "string" + type = string default = "sum" } variable "unavailable_sending_operations_count_timeframe" { description = "Timeframe for the GCP Pub/Sub Unavailable Sending Operations Count monitor" - type = "string" + type = string default = "last_10m" } variable "unavailable_sending_operations_count_threshold_warning" { description = "Warning threshold for the number of unavailable sending operations" - type = "string" + type = string default = 2 } variable "unavailable_sending_operations_count_threshold_critical" { description = "Critical threshold for the number of unavailable sending operations" - type = "string" + type = string default = 4 } variable "unavailable_sending_operations_count_enabled" { description = "Flag to enable GCP Pub/Sub Unavailable Sending Operations Count monitor" - type = "string" + type = string default = "true" } variable "unavailable_sending_operations_count_extra_tags" { description = "Extra tags for GCP Pub/Sub Unavailable Sending Operations Count monitor" - type = "list" + type = list(string) default = [] } + diff --git a/cloud/gcp/pubsub/monitors-pubsub.tf b/cloud/gcp/pubsub/monitors-pubsub.tf index 2826eae..f40f79e 100644 --- a/cloud/gcp/pubsub/monitors-pubsub.tf +++ b/cloud/gcp/pubsub/monitors-pubsub.tf @@ -2,67 +2,66 @@ # Sending Operations Count # resource "datadog_monitor" "sending_operations_count" { - count = "${var.sending_operations_count_enabled == "true" ? 1 : 0}" + count = var.sending_operations_count_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] GCP pubsub sending messages operations {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}" - message = "${coalesce(var.sending_operations_count_message, var.message)}" - + message = coalesce(var.sending_operations_count_message, var.message) type = "query alert" query = <= ${var.unavailable_sending_operations_count_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.unavailable_sending_operations_count_threshold_warning}" - critical = "${var.unavailable_sending_operations_count_threshold_critical}" - } - - notify_audit = false - locked = false - timeout_h = 0 - include_tags = true - require_full_window = false - notify_no_data = false - renotify_interval = 0 - - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" - - tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:pubsub", "team:claranet", "created-by:terraform", "${var.unavailable_sending_operations_count_extra_tags}"] +thresholds = { +warning = var.unavailable_sending_operations_count_threshold_warning +critical = var.unavailable_sending_operations_count_threshold_critical } + +notify_audit = false +locked = false +timeout_h = 0 +include_tags = true +require_full_window = false +notify_no_data = false +renotify_interval = 0 + +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay + +tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:pubsub", "team:claranet", "created-by:terraform", var.unavailable_sending_operations_count_extra_tags] +} + diff --git a/cloud/gcp/pubsub/outputs.tf b/cloud/gcp/pubsub/outputs.tf index 869f4b8..a08edb8 100644 --- a/cloud/gcp/pubsub/outputs.tf +++ b/cloud/gcp/pubsub/outputs.tf @@ -1,9 +1,10 @@ output "sending_operations_count_id" { description = "id for monitor sending_operations_count" - value = "${datadog_monitor.sending_operations_count.*.id}" + value = datadog_monitor.sending_operations_count.*.id } output "unavailable_sending_operations_count_id" { description = "id for monitor unavailable_sending_operations_count" - value = "${datadog_monitor.unavailable_sending_operations_count.*.id}" + value = datadog_monitor.unavailable_sending_operations_count.*.id } + diff --git a/cloud/gcp/pubsub/versions.tf b/cloud/gcp/pubsub/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/cloud/gcp/pubsub/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/common/alerting-message/inputs.tf b/common/alerting-message/inputs.tf index 7a0e3ec..3ebe0cf 100644 --- a/common/alerting-message/inputs.tf +++ b/common/alerting-message/inputs.tf @@ -1,27 +1,28 @@ variable "message_alert" { description = "Define a broadcast channel for critical alerts" - type = "string" + type = string } variable "message_warning" { description = "Define a broadcast channel for warning alerts" - type = "string" + type = string } variable "message_nodata" { description = "Define a broadcast channel for nodata alerts" - type = "string" + type = string default = "" } variable "prepend_text" { description = "Optional free text string to prepend to alert" - type = "string" + type = string default = "" } variable "append_text" { description = "Optional free text string to append to alert" - type = "string" + type = string default = "" } + diff --git a/common/alerting-message/main.tf b/common/alerting-message/main.tf index 81b3369..1f81058 100644 --- a/common/alerting-message/main.tf +++ b/common/alerting-message/main.tf @@ -10,11 +10,13 @@ $${prepend_text} $${append_text} EOF - vars { - message_alert = "${var.message_alert}" - message_warning = "${var.message_warning}" - message_nodata = "${coalesce(var.message_nodata,var.message_alert)}" - prepend_text = "${var.prepend_text}" - append_text = "${var.append_text}" + + vars = { + message_alert = var.message_alert + message_warning = var.message_warning + message_nodata = coalesce(var.message_nodata, var.message_alert) + prepend_text = var.prepend_text + append_text = var.append_text } } + diff --git a/common/alerting-message/outputs.tf b/common/alerting-message/outputs.tf index 8a9d93e..56bdca8 100644 --- a/common/alerting-message/outputs.tf +++ b/common/alerting-message/outputs.tf @@ -1,4 +1,5 @@ output "alerting-message" { description = "The generated message string" - value = "${data.template_file.alerting-message.rendered}" + value = data.template_file.alerting-message.rendered } + diff --git a/common/alerting-message/versions.tf b/common/alerting-message/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/common/alerting-message/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/common/filter-tags/inputs.tf b/common/filter-tags/inputs.tf index c4b8283..be03838 100644 --- a/common/filter-tags/inputs.tf +++ b/common/filter-tags/inputs.tf @@ -1,11 +1,11 @@ variable "environment" { description = "Architecture Environment" - type = "string" + type = string } variable "resource" { description = "The dedicated tag for the resource" - type = "string" + type = string } variable "filter_tags_use_defaults" { @@ -25,12 +25,13 @@ variable "filter_tags_custom_excluded" { variable "extra_tags" { description = "Extra optional tags added to include filtering in any case (i.e. [\"tag1:val1\", \"tag2:val2\"])" - type = "list" + type = list(string) default = [] } variable "extra_tags_excluded" { description = "Extra optional tags added to exclude filtering in any case (i.e. [\"tag1:val1\", \"tag2:val2\"])" - type = "list" + type = list(string) default = [] } + diff --git a/common/filter-tags/locals.tf b/common/filter-tags/locals.tf index 1a3d95e..12a4dd7 100644 --- a/common/filter-tags/locals.tf +++ b/common/filter-tags/locals.tf @@ -1,8 +1,34 @@ locals { - including_default_list = "${compact(concat(split(",", format("dd_monitoring:enabled,dd_%s:enabled,env:%s", var.resource, var.environment)), compact(var.extra_tags)))}" - including_custom_list = "${compact(concat(split(",", var.filter_tags_custom), compact(var.extra_tags)))}" - excluding_list = "${compact(split(",", var.filter_tags_use_defaults == "true" ? join(",", compact(var.extra_tags_excluded)) : join(",", concat(split(",", var.filter_tags_custom_excluded), compact(var.extra_tags_excluded)))))}" + including_default_list = compact( + concat( + split( + ",", + format( + "dd_monitoring:enabled,dd_%s:enabled,env:%s", + var.resource, + var.environment, + ), + ), + compact(var.extra_tags), + ), + ) + including_custom_list = compact( + concat(split(",", var.filter_tags_custom), compact(var.extra_tags)), + ) + excluding_list = compact( + split( + ",", + var.filter_tags_use_defaults == "true" ? join(",", compact(var.extra_tags_excluded)) : join( + ",", + concat( + split(",", var.filter_tags_custom_excluded), + compact(var.extra_tags_excluded), + ), + ), + ), + ) - including_string = "${var.filter_tags_use_defaults == "true" ? join(",", local.including_default_list) : join(",", local.including_custom_list)}" - excluding_string = "${join(",", local.excluding_list)}" + including_string = var.filter_tags_use_defaults == "true" ? join(",", local.including_default_list) : join(",", local.including_custom_list) + excluding_string = join(",", local.excluding_list) } + diff --git a/common/filter-tags/outputs.tf b/common/filter-tags/outputs.tf index c70bbdc..3d9f6c7 100644 --- a/common/filter-tags/outputs.tf +++ b/common/filter-tags/outputs.tf @@ -4,7 +4,15 @@ # query_alert = {tag:val,tag2:val2,!excludedtag:value,!exludedtag2:value2} output "query_alert" { description = "The full filtering pattern including parentheses for service check monitor type" - value = "{${join(",", compact(concat(list(local.including_string), formatlist("!%s", local.excluding_list))))}}" + value = "{${join( + ",", + compact( + concat( + [local.including_string], + formatlist("!%s", local.excluding_list), + ), + ), + )}}" } # service_check = .over("tag:val","tag2:val2").exclude("excludedtag:value","exludedtag2:value2") @@ -18,3 +26,4 @@ output "event_alert" { description = "The full filtering pattern for event alert monitor type" value = "tags:${local.including_string}${local.excluding_string == "" ? "" : " excluded_tags:${local.excluding_string}"}" } + diff --git a/common/filter-tags/versions.tf b/common/filter-tags/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/common/filter-tags/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/database/elasticsearch/inputs.tf b/database/elasticsearch/inputs.tf index d31085a..158684b 100644 --- a/database/elasticsearch/inputs.tf +++ b/database/elasticsearch/inputs.tf @@ -3,7 +3,7 @@ # variable "environment" { description = "Architecture environment" - type = "string" + type = string } variable "filter_tags_use_defaults" { @@ -45,43 +45,43 @@ variable "prefix_slug" { # variable "cluster_status_not_green_message" { description = "Custom message for the Cluster Status monitor" - type = "string" + type = string default = "" } variable "cluster_status_not_green_time_aggregator" { description = "Time aggregator for the Cluster Status monitor" - type = "string" + type = string default = "avg" } variable "cluster_status_not_green_timeframe" { description = "Timeframe for the Cluster Status monitor" - type = "string" + type = string default = "last_5m" } variable "cluster_status_not_green_threshold_warning" { description = "Cluster Status warning threshold" - type = "string" + type = string default = 1 } variable "cluster_status_not_green_threshold_critical" { description = "Cluster Status critical threshold" - type = "string" + type = string default = 0 } variable "cluster_status_not_green_enabled" { description = "Flag to enable Cluster Status monitor" - type = "string" + type = string default = "true" } variable "cluster_status_not_green_extra_tags" { description = "Extra tags for Cluster Status monitor" - type = "list" + type = list(string) default = [] } @@ -90,43 +90,43 @@ variable "cluster_status_not_green_extra_tags" { # variable "cluster_initializing_shards_message" { description = "Custom message for the Cluster Status monitor" - type = "string" + type = string default = "" } variable "cluster_initializing_shards_time_aggregator" { description = "Time aggregator for the Cluster Status monitor" - type = "string" + type = string default = "avg" } variable "cluster_initializing_shards_timeframe" { description = "Timeframe for the Cluster Status monitor" - type = "string" + type = string default = "last_5m" } variable "cluster_initializing_shards_threshold_warning" { description = "Cluster Status warning threshold" - type = "string" + type = string default = 1 } variable "cluster_initializing_shards_threshold_critical" { description = "Cluster Status critical threshold" - type = "string" + type = string default = 2 } variable "cluster_initializing_shards_enabled" { description = "Flag to enable Cluster Status monitor" - type = "string" + type = string default = "true" } variable "cluster_initializing_shards_extra_tags" { description = "Extra tags for Cluster Status monitor" - type = "list" + type = list(string) default = [] } @@ -135,43 +135,43 @@ variable "cluster_initializing_shards_extra_tags" { # variable "cluster_relocating_shards_message" { description = "Custom message for the Cluster Status monitor" - type = "string" + type = string default = "" } variable "cluster_relocating_shards_time_aggregator" { description = "Time aggregator for the Cluster Status monitor" - type = "string" + type = string default = "avg" } variable "cluster_relocating_shards_timeframe" { description = "Timeframe for the Cluster Status monitor" - type = "string" + type = string default = "last_5m" } variable "cluster_relocating_shards_threshold_warning" { description = "Cluster Status warning threshold" - type = "string" + type = string default = 1 } variable "cluster_relocating_shards_threshold_critical" { description = "Cluster Status critical threshold" - type = "string" + type = string default = 2 } variable "cluster_relocating_shards_enabled" { description = "Flag to enable Cluster Status monitor" - type = "string" + type = string default = "true" } variable "cluster_relocating_shards_extra_tags" { description = "Extra tags for Cluster Status monitor" - type = "list" + type = list(string) default = [] } @@ -180,43 +180,43 @@ variable "cluster_relocating_shards_extra_tags" { # variable "cluster_unassigned_shards_message" { description = "Custom message for the Cluster Status monitor" - type = "string" + type = string default = "" } variable "cluster_unassigned_shards_time_aggregator" { description = "Time aggregator for the Cluster Status monitor" - type = "string" + type = string default = "avg" } variable "cluster_unassigned_shards_timeframe" { description = "Timeframe for the Cluster Status monitor" - type = "string" + type = string default = "last_5m" } variable "cluster_unassigned_shards_threshold_warning" { description = "Cluster Status warning threshold" - type = "string" + type = string default = 1 } variable "cluster_unassigned_shards_threshold_critical" { description = "Cluster Status critical threshold" - type = "string" + type = string default = 2 } variable "cluster_unassigned_shards_enabled" { description = "Flag to enable Cluster Status monitor" - type = "string" + type = string default = "true" } variable "cluster_unassigned_shards_extra_tags" { description = "Extra tags for Cluster Status monitor" - type = "list" + type = list(string) default = [] } @@ -225,43 +225,43 @@ variable "cluster_unassigned_shards_extra_tags" { # variable "node_free_space_message" { description = "Custom message for the Cluster Status monitor" - type = "string" + type = string default = "" } variable "node_free_space_time_aggregator" { description = "Time aggregator for the Cluster Status monitor" - type = "string" + type = string default = "sum" } variable "node_free_space_timeframe" { description = "Timeframe for the Cluster Status monitor" - type = "string" + type = string default = "last_5m" } variable "node_free_space_threshold_warning" { description = "Cluster Status warning threshold" - type = "string" + type = string default = 20 } variable "node_free_space_threshold_critical" { description = "Cluster Status critical threshold" - type = "string" + type = string default = 10 } variable "node_free_space_enabled" { description = "Flag to enable Cluster Status monitor" - type = "string" + type = string default = "true" } variable "node_free_space_extra_tags" { description = "Extra tags for Cluster Status monitor" - type = "list" + type = list(string) default = [] } @@ -270,43 +270,43 @@ variable "node_free_space_extra_tags" { # variable "jvm_heap_memory_usage_message" { description = "Custom message for the Cluster Status monitor" - type = "string" + type = string default = "" } variable "jvm_heap_memory_usage_time_aggregator" { description = "Time aggregator for the Cluster Status monitor" - type = "string" + type = string default = "avg" } variable "jvm_heap_memory_usage_timeframe" { description = "Timeframe for the Cluster Status monitor" - type = "string" + type = string default = "last_5m" } variable "jvm_heap_memory_usage_threshold_warning" { description = "Cluster Status warning threshold" - type = "string" + type = string default = 80 } variable "jvm_heap_memory_usage_threshold_critical" { description = "Cluster Status critical threshold" - type = "string" + type = string default = 90 } variable "jvm_heap_memory_usage_enabled" { description = "Flag to enable Cluster Status monitor" - type = "string" + type = string default = "true" } variable "jvm_heap_memory_usage_extra_tags" { description = "Extra tags for Cluster Status monitor" - type = "list" + type = list(string) default = [] } @@ -315,43 +315,43 @@ variable "jvm_heap_memory_usage_extra_tags" { # variable "jvm_memory_young_usage_message" { description = "Custom message for the Cluster Status monitor" - type = "string" + type = string default = "" } variable "jvm_memory_young_usage_time_aggregator" { description = "Time aggregator for the Cluster Status monitor" - type = "string" + type = string default = "avg" } variable "jvm_memory_young_usage_timeframe" { description = "Timeframe for the Cluster Status monitor" - type = "string" + type = string default = "last_10m" } variable "jvm_memory_young_usage_threshold_warning" { description = "Cluster Status warning threshold" - type = "string" + type = string default = 80 } variable "jvm_memory_young_usage_threshold_critical" { description = "Cluster Status critical threshold" - type = "string" + type = string default = 90 } variable "jvm_memory_young_usage_enabled" { description = "Flag to enable Cluster Status monitor" - type = "string" + type = string default = "true" } variable "jvm_memory_young_usage_extra_tags" { description = "Extra tags for Cluster Status monitor" - type = "list" + type = list(string) default = [] } @@ -360,43 +360,43 @@ variable "jvm_memory_young_usage_extra_tags" { # variable "jvm_memory_old_usage_message" { description = "Custom message for the Cluster Status monitor" - type = "string" + type = string default = "" } variable "jvm_memory_old_usage_time_aggregator" { description = "Time aggregator for the Cluster Status monitor" - type = "string" + type = string default = "avg" } variable "jvm_memory_old_usage_timeframe" { description = "Timeframe for the Cluster Status monitor" - type = "string" + type = string default = "last_10m" } variable "jvm_memory_old_usage_threshold_warning" { description = "Cluster Status warning threshold" - type = "string" + type = string default = 80 } variable "jvm_memory_old_usage_threshold_critical" { description = "Cluster Status critical threshold" - type = "string" + type = string default = 90 } variable "jvm_memory_old_usage_enabled" { description = "Flag to enable Cluster Status monitor" - type = "string" + type = string default = "true" } variable "jvm_memory_old_usage_extra_tags" { description = "Extra tags for Cluster Status monitor" - type = "list" + type = list(string) default = [] } @@ -405,43 +405,43 @@ variable "jvm_memory_old_usage_extra_tags" { # variable "jvm_gc_old_collection_latency_message" { description = "Custom message for the Cluster Status monitor" - type = "string" + type = string default = "" } variable "jvm_gc_old_collection_latency_time_aggregator" { description = "Time aggregator for the Cluster Status monitor" - type = "string" + type = string default = "avg" } variable "jvm_gc_old_collection_latency_timeframe" { description = "Timeframe for the Cluster Status monitor" - type = "string" + type = string default = "last_10m" } variable "jvm_gc_old_collection_latency_threshold_warning" { description = "Cluster Status warning threshold" - type = "string" + type = string default = 160 } variable "jvm_gc_old_collection_latency_threshold_critical" { description = "Cluster Status critical threshold" - type = "string" + type = string default = 200 } variable "jvm_gc_old_collection_latency_enabled" { description = "Flag to enable Cluster Status monitor" - type = "string" + type = string default = "true" } variable "jvm_gc_old_collection_latency_extra_tags" { description = "Extra tags for Cluster Status monitor" - type = "list" + type = list(string) default = [] } @@ -450,43 +450,43 @@ variable "jvm_gc_old_collection_latency_extra_tags" { # variable "jvm_gc_young_collection_latency_message" { description = "Custom message for the Cluster Status monitor" - type = "string" + type = string default = "" } variable "jvm_gc_young_collection_latency_time_aggregator" { description = "Time aggregator for the Cluster Status monitor" - type = "string" + type = string default = "avg" } variable "jvm_gc_young_collection_latency_timeframe" { description = "Timeframe for the Cluster Status monitor" - type = "string" + type = string default = "last_10m" } variable "jvm_gc_young_collection_latency_threshold_warning" { description = "Cluster Status warning threshold" - type = "string" + type = string default = 20 } variable "jvm_gc_young_collection_latency_threshold_critical" { description = "Cluster Status critical threshold" - type = "string" + type = string default = 25 } variable "jvm_gc_young_collection_latency_enabled" { description = "Flag to enable Cluster Status monitor" - type = "string" + type = string default = "true" } variable "jvm_gc_young_collection_latency_extra_tags" { description = "Extra tags for Cluster Status monitor" - type = "list" + type = list(string) default = [] } @@ -495,43 +495,43 @@ variable "jvm_gc_young_collection_latency_extra_tags" { # variable "indexing_latency_message" { description = "Custom message for the Cluster Status monitor" - type = "string" + type = string default = "" } variable "indexing_latency_time_aggregator" { description = "Time aggregator for the Cluster Status monitor" - type = "string" + type = string default = "avg" } variable "indexing_latency_timeframe" { description = "Timeframe for the Cluster Status monitor" - type = "string" + type = string default = "last_10m" } variable "indexing_latency_threshold_warning" { description = "Cluster Status warning threshold" - type = "string" + type = string default = 10 } variable "indexing_latency_threshold_critical" { description = "Cluster Status critical threshold" - type = "string" + type = string default = 15 } variable "indexing_latency_enabled" { description = "Flag to enable Cluster Status monitor" - type = "string" + type = string default = "true" } variable "indexing_latency_extra_tags" { description = "Extra tags for Cluster Status monitor" - type = "list" + type = list(string) default = [] } @@ -540,43 +540,43 @@ variable "indexing_latency_extra_tags" { # variable "flush_latency_message" { description = "Custom message for the Cluster Status monitor" - type = "string" + type = string default = "" } variable "flush_latency_time_aggregator" { description = "Time aggregator for the Cluster Status monitor" - type = "string" + type = string default = "avg" } variable "flush_latency_timeframe" { description = "Timeframe for the Cluster Status monitor" - type = "string" + type = string default = "last_10m" } variable "flush_latency_threshold_warning" { description = "Cluster Status warning threshold" - type = "string" + type = string default = 50 } variable "flush_latency_threshold_critical" { description = "Cluster Status critical threshold" - type = "string" + type = string default = 100 } variable "flush_latency_enabled" { description = "Flag to enable Cluster Status monitor" - type = "string" + type = string default = "true" } variable "flush_latency_extra_tags" { description = "Extra tags for Cluster Status monitor" - type = "list" + type = list(string) default = [] } @@ -585,85 +585,85 @@ variable "flush_latency_extra_tags" { # variable "http_connections_anomaly_message" { description = "Custom message for the Cluster Status monitor" - type = "string" + type = string default = "" } variable "http_connections_anomaly_time_aggregator" { description = "Time aggregator for the Cluster Status monitor" - type = "string" + type = string default = "avg" } variable "http_connections_anomaly_timeframe" { description = "Timeframe for the Cluster Status monitor" - type = "string" + type = string default = "last_4h" } variable "http_connections_anomaly_detection_algorithm" { description = "Anomaly Detection Algorithm used" - type = "string" + type = string default = "agile" } variable "http_connections_anomaly_deviations" { description = "Deviations to detect the anomaly" - type = "string" + type = string default = 2 } variable "http_connections_anomaly_direction" { description = "Direction of the anomaly. It can be both, below or above." - type = "string" + type = string default = "above" } variable "http_connections_anomaly_alert_window" { description = "Alert window." - type = "string" + type = string default = "last_15m" } variable "http_connections_anomaly_interval" { description = "Interval." - type = "string" + type = string default = 60 } variable "http_connections_anomaly_count_default_zero" { description = "Count default zero." - type = "string" + type = string default = "true" } variable "http_connections_anomaly_seasonality" { description = "Seasonality of the algorithm" - type = "string" + type = string default = "hourly" } variable "http_connections_anomaly_threshold_warning" { description = "Cluster Status warning threshold" - type = "string" + type = string default = 0.75 } variable "http_connections_anomaly_threshold_critical" { description = "Cluster Status critical threshold" - type = "string" + type = string default = 1 } variable "http_connections_anomaly_enabled" { description = "Flag to enable Cluster Status monitor" - type = "string" + type = string default = "true" } variable "http_connections_anomaly_extra_tags" { description = "Extra tags for Cluster Status monitor" - type = "list" + type = list(string) default = [] } @@ -672,43 +672,43 @@ variable "http_connections_anomaly_extra_tags" { # variable "search_query_latency_message" { description = "Custom message for the Cluster Status monitor" - type = "string" + type = string default = "" } variable "search_query_latency_time_aggregator" { description = "Time aggregator for the Cluster Status monitor" - type = "string" + type = string default = "avg" } variable "search_query_latency_timeframe" { description = "Timeframe for the Cluster Status monitor" - type = "string" + type = string default = "last_10m" } variable "search_query_latency_threshold_warning" { description = "Cluster Status warning threshold" - type = "string" + type = string default = 0.5 } variable "search_query_latency_threshold_critical" { description = "Cluster Status critical threshold" - type = "string" + type = string default = 1 } variable "search_query_latency_enabled" { description = "Flag to enable Cluster Status monitor" - type = "string" + type = string default = "true" } variable "search_query_latency_extra_tags" { description = "Extra tags for Cluster Status monitor" - type = "list" + type = list(string) default = [] } @@ -717,43 +717,43 @@ variable "search_query_latency_extra_tags" { # variable "fetch_latency_message" { description = "Custom message for the Cluster Status monitor" - type = "string" + type = string default = "" } variable "fetch_latency_time_aggregator" { description = "Time aggregator for the Cluster Status monitor" - type = "string" + type = string default = "avg" } variable "fetch_latency_timeframe" { description = "Timeframe for the Cluster Status monitor" - type = "string" + type = string default = "last_10m" } variable "fetch_latency_threshold_warning" { description = "Cluster Status warning threshold" - type = "string" + type = string default = 2 } variable "fetch_latency_threshold_critical" { description = "Cluster Status critical threshold" - type = "string" + type = string default = 4 } variable "fetch_latency_enabled" { description = "Flag to enable Cluster Status monitor" - type = "string" + type = string default = "true" } variable "fetch_latency_extra_tags" { description = "Extra tags for Cluster Status monitor" - type = "list" + type = list(string) default = [] } @@ -762,49 +762,49 @@ variable "fetch_latency_extra_tags" { # variable "search_query_change_message" { description = "Custom message for the Cluster Status monitor" - type = "string" + type = string default = "" } variable "search_query_change_time_aggregator" { description = "Time aggregator for the Cluster Status monitor" - type = "string" + type = string default = "avg" } variable "search_query_change_timeframe" { description = "Timeframe for the Cluster Status monitor" - type = "string" + type = string default = "last_10m" } variable "search_query_change_timeshift" { description = "Timeshift for the Cluster Status monitor" - type = "string" + type = string default = "last_10m" } variable "search_query_change_threshold_warning" { description = "Cluster Status warning threshold" - type = "string" + type = string default = 75 } variable "search_query_change_threshold_critical" { description = "Cluster Status critical threshold" - type = "string" + type = string default = 100 } variable "search_query_change_enabled" { description = "Flag to enable Cluster Status monitor" - type = "string" + type = string default = "true" } variable "search_query_change_extra_tags" { description = "Extra tags for Cluster Status monitor" - type = "list" + type = list(string) default = [] } @@ -813,49 +813,49 @@ variable "search_query_change_extra_tags" { # variable "fetch_change_message" { description = "Custom message for the Cluster Status monitor" - type = "string" + type = string default = "" } variable "fetch_change_time_aggregator" { description = "Time aggregator for the Cluster Status monitor" - type = "string" + type = string default = "avg" } variable "fetch_change_timeframe" { description = "Timeframe for the Cluster Status monitor" - type = "string" + type = string default = "last_10m" } variable "fetch_change_timeshift" { description = "Timeshift for the Cluster Status monitor" - type = "string" + type = string default = "last_10m" } variable "fetch_change_threshold_warning" { description = "Cluster Status warning threshold" - type = "string" + type = string default = 75 } variable "fetch_change_threshold_critical" { description = "Cluster Status critical threshold" - type = "string" + type = string default = 100 } variable "fetch_change_enabled" { description = "Flag to enable Cluster Status monitor" - type = "string" + type = string default = "true" } variable "fetch_change_extra_tags" { description = "Extra tags for Cluster Status monitor" - type = "list" + type = list(string) default = [] } @@ -864,49 +864,49 @@ variable "fetch_change_extra_tags" { # variable "field_data_evictions_change_message" { description = "Custom message for the Cluster Status monitor" - type = "string" + type = string default = "" } variable "field_data_evictions_change_time_aggregator" { description = "Time aggregator for the Cluster Status monitor" - type = "string" + type = string default = "avg" } variable "field_data_evictions_change_timeframe" { description = "Timeframe for the Cluster Status monitor" - type = "string" + type = string default = "last_15m" } variable "field_data_evictions_change_timeshift" { description = "Timeframe for the Cluster Status monitor" - type = "string" + type = string default = "last_15m" } variable "field_data_evictions_change_threshold_warning" { description = "Cluster Status warning threshold" - type = "string" + type = string default = 60 } variable "field_data_evictions_change_threshold_critical" { description = "Cluster Status critical threshold" - type = "string" + type = string default = 120 } variable "field_data_evictions_change_enabled" { description = "Flag to enable Cluster Status monitor" - type = "string" + type = string default = "true" } variable "field_data_evictions_change_extra_tags" { description = "Extra tags for Cluster Status monitor" - type = "list" + type = list(string) default = [] } @@ -915,49 +915,49 @@ variable "field_data_evictions_change_extra_tags" { # variable "query_cache_evictions_change_message" { description = "Custom message for the Cluster Status monitor" - type = "string" + type = string default = "" } variable "query_cache_evictions_change_time_aggregator" { description = "Time aggregator for the Cluster Status monitor" - type = "string" + type = string default = "avg" } variable "query_cache_evictions_change_timeframe" { description = "Timeframe for the Cluster Status monitor" - type = "string" + type = string default = "last_15m" } variable "query_cache_evictions_change_timeshift" { description = "Timeframe for the Cluster Status monitor" - type = "string" + type = string default = "last_15m" } variable "query_cache_evictions_change_threshold_warning" { description = "Cluster Status warning threshold" - type = "string" + type = string default = 60 } variable "query_cache_evictions_change_threshold_critical" { description = "Cluster Status critical threshold" - type = "string" + type = string default = 120 } variable "query_cache_evictions_change_enabled" { description = "Flag to enable Cluster Status monitor" - type = "string" + type = string default = "true" } variable "query_cache_evictions_change_extra_tags" { description = "Extra tags for Cluster Status monitor" - type = "list" + type = list(string) default = [] } @@ -966,49 +966,49 @@ variable "query_cache_evictions_change_extra_tags" { # variable "request_cache_evictions_change_message" { description = "Custom message for the Cluster Status monitor" - type = "string" + type = string default = "" } variable "request_cache_evictions_change_time_aggregator" { description = "Time aggregator for the Cluster Status monitor" - type = "string" + type = string default = "avg" } variable "request_cache_evictions_change_timeframe" { description = "Timeframe for the Cluster Status monitor" - type = "string" + type = string default = "last_15m" } variable "request_cache_evictions_change_timeshift" { description = "Timeshift for the Cluster Status monitor" - type = "string" + type = string default = "last_15m" } variable "request_cache_evictions_change_threshold_warning" { description = "Cluster Status warning threshold" - type = "string" + type = string default = 60 } variable "request_cache_evictions_change_threshold_critical" { description = "Cluster Status critical threshold" - type = "string" + type = string default = 120 } variable "request_cache_evictions_change_enabled" { description = "Flag to enable Cluster Status monitor" - type = "string" + type = string default = "true" } variable "request_cache_evictions_change_extra_tags" { description = "Extra tags for Cluster Status monitor" - type = "list" + type = list(string) default = [] } @@ -1017,49 +1017,49 @@ variable "request_cache_evictions_change_extra_tags" { # variable "task_time_in_queue_change_message" { description = "Custom message for the Cluster Status monitor" - type = "string" + type = string default = "" } variable "task_time_in_queue_change_time_aggregator" { description = "Time aggregator for the Cluster Status monitor" - type = "string" + type = string default = "avg" } variable "task_time_in_queue_change_timeframe" { description = "Timeframe for the Cluster Status monitor" - type = "string" + type = string default = "last_10m" } variable "task_time_in_queue_change_timeshift" { description = "Timeshift for the Cluster Status monitor" - type = "string" + type = string default = "last_10m" } variable "task_time_in_queue_change_threshold_warning" { description = "Cluster Status warning threshold" - type = "string" + type = string default = 100 } variable "task_time_in_queue_change_threshold_critical" { description = "Cluster Status critical threshold" - type = "string" + type = string default = 200 } variable "task_time_in_queue_change_enabled" { description = "Flag to enable Cluster Status monitor" - type = "string" + type = string default = "true" } variable "task_time_in_queue_change_extra_tags" { description = "Extra tags for Cluster Status monitor" - type = "list" + type = list(string) default = [] } @@ -1069,13 +1069,13 @@ variable "task_time_in_queue_change_extra_tags" { variable "not_responding_enabled" { description = "Flag to enable Elasticsearch does not respond monitor" - type = "string" + type = string default = "true" } variable "not_responding_message" { description = "Custom message for Elasticsearch does not respond monitor" - type = "string" + type = string default = "" } @@ -1086,12 +1086,13 @@ variable "not_responding_threshold_warning" { variable "not_responding_no_data_timeframe" { description = "Elasticsearch not responding monitor no data timeframe" - type = "string" + type = string default = 10 } variable "not_responding_extra_tags" { description = "Extra tags for Elasticsearch does not respond monitor" - type = "list" + type = list(string) default = [] } + diff --git a/database/elasticsearch/modules.tf b/database/elasticsearch/modules.tf index 49a9551..6f3dc60 100644 --- a/database/elasticsearch/modules.tf +++ b/database/elasticsearch/modules.tf @@ -1,9 +1,10 @@ module "filter-tags" { source = "../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "elasticsearch" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded } + diff --git a/database/elasticsearch/monitors-elasticsearch.tf b/database/elasticsearch/monitors-elasticsearch.tf index af0328e..369183f 100644 --- a/database/elasticsearch/monitors-elasticsearch.tf +++ b/database/elasticsearch/monitors-elasticsearch.tf @@ -2,211 +2,166 @@ # Service Check # resource "datadog_monitor" "not_responding" { - count = "${var.not_responding_enabled == "true" ? 1 : 0}" + count = var.not_responding_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] ElasticSearch does not respond" - message = "${coalesce(var.not_responding_message, var.message)}" + message = coalesce(var.not_responding_message, var.message) + type = "service check" query = < ${var.cluster_initializing_shards_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.cluster_initializing_shards_threshold_warning}" - critical = "${var.cluster_initializing_shards_threshold_critical}" - } +thresholds = { +warning = var.cluster_initializing_shards_threshold_warning +critical = var.cluster_initializing_shards_threshold_critical +} - notify_audit = false - locked = false - include_tags = true - require_full_window = true - notify_no_data = false +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay +notify_audit = false +locked = false +include_tags = true +require_full_window = true +notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - - tags = [ - "resource:elasticsearch", - "env:${var.environment}", - "created-by:terraform", - "team:claranet", - "type:database", - "provider:elasticsearch", - "${var.cluster_initializing_shards_extra_tags}", - ] +tags = ["resource:elasticsearch", "env:${var.environment}", "created-by:terraform", "team:claranet", "type:database", "provider:elasticsearch", var.cluster_initializing_shards_extra_tags] } # # Cluster Relocating Shards # resource "datadog_monitor" "cluster_relocating_shards" { - count = "${var.cluster_relocating_shards_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] ElasticSearch Cluster is relocating shards" - message = "${coalesce(var.cluster_relocating_shards_message, var.message)}" +count = var.cluster_relocating_shards_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] ElasticSearch Cluster is relocating shards" +message = coalesce(var.cluster_relocating_shards_message, var.message) +type = "metric alert" - type = "metric alert" - - query = < ${var.cluster_relocating_shards_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.cluster_relocating_shards_threshold_warning}" - critical = "${var.cluster_relocating_shards_threshold_critical}" + thresholds = { + warning = var.cluster_relocating_shards_threshold_warning + critical = var.cluster_relocating_shards_threshold_critical } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay notify_audit = false locked = false include_tags = true require_full_window = true notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - - tags = [ - "resource:elasticsearch", - "env:${var.environment}", - "created-by:terraform", - "team:claranet", - "type:database", - "provider:elasticsearch", - "${var.cluster_relocating_shards_extra_tags}", - ] + tags = ["resource:elasticsearch", "env:${var.environment}", "created-by:terraform", "team:claranet", "type:database", "provider:elasticsearch", var.cluster_relocating_shards_extra_tags] } # # Cluster Unassigned Shards # resource "datadog_monitor" "cluster_unassigned_shards" { - count = "${var.cluster_unassigned_shards_enabled == "true" ? 1 : 0}" + count = var.cluster_unassigned_shards_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] ElasticSearch Cluster has unassigned shards" - message = "${coalesce(var.cluster_unassigned_shards_message, var.message)}" - + message = coalesce(var.cluster_unassigned_shards_message, var.message) type = "metric alert" query = < ${var.cluster_unassigned_shards_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.cluster_unassigned_shards_threshold_warning}" - critical = "${var.cluster_unassigned_shards_threshold_critical}" + thresholds = { + warning = var.cluster_unassigned_shards_threshold_warning + critical = var.cluster_unassigned_shards_threshold_critical } - notify_audit = false - locked = false - include_tags = true + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay + notify_audit = false + locked = false + include_tags = true require_full_window = true - notify_no_data = false + notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - tags = [ - "resource:elasticsearch", - "env:${var.environment}", - "created-by:terraform", - "team:claranet", - "type:database", - "provider:elasticsearch", - "${var.cluster_unassigned_shards_extra_tags}", - ] + tags = ["resource:elasticsearch", "env:${var.environment}", "created-by:terraform", "team:claranet", "type:database", "provider:elasticsearch", var.cluster_unassigned_shards_extra_tags] } # # Free Space in nodes # resource "datadog_monitor" "node_free_space" { - count = "${var.node_free_space_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] ElasticSearch free space < 10%" - message = "${coalesce(var.node_free_space_message, var.message)}" + count = var.node_free_space_enabled == "true" ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] ElasticSearch free space < 10%" + message = coalesce(var.node_free_space_message, var.message) type = "query alert" @@ -217,281 +172,218 @@ resource "datadog_monitor" "node_free_space" { min:elasticsearch.fs.total.total_in_bytes${module.filter-tags.query_alert} by {node_name} ) * 100 < ${var.node_free_space_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.node_free_space_threshold_warning}" - critical = "${var.node_free_space_threshold_critical}" - } +thresholds = { +warning = var.node_free_space_threshold_warning +critical = var.node_free_space_threshold_critical +} - notify_audit = false - locked = false - include_tags = true - require_full_window = true - notify_no_data = false +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay +notify_audit = false +locked = false +include_tags = true +require_full_window = true +notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - - tags = [ - "resource:elasticsearch", - "env:${var.environment}", - "created-by:terraform", - "team:claranet", - "type:database", - "provider:elasticsearch", - "${var.node_free_space_extra_tags}", - ] +tags = ["resource:elasticsearch", "env:${var.environment}", "created-by:terraform", "team:claranet", "type:database", "provider:elasticsearch", var.node_free_space_extra_tags] } # # JVM Heap Memory Usage # resource "datadog_monitor" "jvm_heap_memory_usage" { - count = "${var.jvm_heap_memory_usage_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticsearch JVM HEAP memory usage {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.jvm_heap_memory_usage_message, var.message)}" +count = var.jvm_heap_memory_usage_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticsearch JVM HEAP memory usage {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +message = coalesce(var.jvm_heap_memory_usage_message, var.message) +type = "query alert" - type = "query alert" - - query = < ${var.jvm_heap_memory_usage_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.jvm_heap_memory_usage_threshold_warning}" - critical = "${var.jvm_heap_memory_usage_threshold_critical}" - } +thresholds = { +warning = var.jvm_heap_memory_usage_threshold_warning +critical = var.jvm_heap_memory_usage_threshold_critical +} - notify_audit = false - locked = false - include_tags = true - require_full_window = true - notify_no_data = false +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay +notify_audit = false +locked = false +include_tags = true +require_full_window = true +notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - - tags = [ - "resource:elasticsearch", - "env:${var.environment}", - "created-by:terraform", - "team:claranet", - "type:database", - "provider:elasticsearch", - "${var.jvm_heap_memory_usage_extra_tags}", - ] +tags = ["resource:elasticsearch", "env:${var.environment}", "created-by:terraform", "team:claranet", "type:database", "provider:elasticsearch", var.jvm_heap_memory_usage_extra_tags] } # # JVM Memory Young Usage # resource "datadog_monitor" "jvm_memory_young_usage" { - count = "${var.jvm_memory_young_usage_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticsearch JVM memory Young usage {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.jvm_memory_young_usage_message, var.message)}" +count = var.jvm_memory_young_usage_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticsearch JVM memory Young usage {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +message = coalesce(var.jvm_memory_young_usage_message, var.message) +type = "query alert" - type = "query alert" - - query = < ${var.jvm_memory_young_usage_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.jvm_memory_young_usage_threshold_warning}" - critical = "${var.jvm_memory_young_usage_threshold_critical}" + thresholds = { + warning = var.jvm_memory_young_usage_threshold_warning + critical = var.jvm_memory_young_usage_threshold_critical } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay notify_audit = false locked = false include_tags = true require_full_window = true notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - - tags = [ - "resource:elasticsearch", - "env:${var.environment}", - "created-by:terraform", - "team:claranet", - "type:database", - "provider:elasticsearch", - "${var.jvm_memory_young_usage_extra_tags}", - ] + tags = ["resource:elasticsearch", "env:${var.environment}", "created-by:terraform", "team:claranet", "type:database", "provider:elasticsearch", var.jvm_memory_young_usage_extra_tags] } # # JVM Memory Old Usage # resource "datadog_monitor" "jvm_memory_old_usage" { - count = "${var.jvm_memory_old_usage_enabled == "true" ? 1 : 0}" + count = var.jvm_memory_old_usage_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticsearch JVM memory Old usage {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.jvm_memory_old_usage_message, var.message)}" - + message = coalesce(var.jvm_memory_old_usage_message, var.message) type = "query alert" query = < ${var.jvm_memory_old_usage_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.jvm_memory_old_usage_threshold_warning}" - critical = "${var.jvm_memory_old_usage_threshold_critical}" + thresholds = { + warning = var.jvm_memory_old_usage_threshold_warning + critical = var.jvm_memory_old_usage_threshold_critical } - notify_audit = false - locked = false - include_tags = true + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay + notify_audit = false + locked = false + include_tags = true require_full_window = true - notify_no_data = false + notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - - tags = [ - "resource:elasticsearch", - "env:${var.environment}", - "created-by:terraform", - "team:claranet", - "type:database", - "provider:elasticsearch", - "${var.jvm_memory_old_usage_extra_tags}", - ] + tags = ["resource:elasticsearch", "env:${var.environment}", "created-by:terraform", "team:claranet", "type:database", "provider:elasticsearch", var.jvm_memory_old_usage_extra_tags] } # # JVM Garbace Collector Old Collection Latency # resource "datadog_monitor" "jvm_gc_old_collection_latency" { - count = "${var.jvm_gc_old_collection_latency_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticsearch average Old-generation garbage collections latency {{#is_alert}}{{{comparator}}} {{threshold}}ms ({{value}}ms){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}ms ({{value}}ms){{/is_warning}}" - message = "${coalesce(var.jvm_gc_old_collection_latency_message, var.message)}" - + count = var.jvm_gc_old_collection_latency_enabled == "true" ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticsearch average Old-generation garbage collections latency {{#is_alert}}{{{comparator}}} {{threshold}}ms ({{value}}ms){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}ms ({{value}}ms){{/is_warning}}" + message = coalesce(var.jvm_gc_old_collection_latency_message, var.message) type = "query alert" query = < ${var.jvm_gc_old_collection_latency_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.jvm_gc_old_collection_latency_threshold_warning}" - critical = "${var.jvm_gc_old_collection_latency_threshold_critical}" - } +thresholds = { +warning = var.jvm_gc_old_collection_latency_threshold_warning +critical = var.jvm_gc_old_collection_latency_threshold_critical +} - notify_audit = false - locked = false - include_tags = true - require_full_window = true - notify_no_data = false +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay +notify_audit = false +locked = false +include_tags = true +require_full_window = true +notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - - tags = [ - "resource:elasticsearch", - "env:${var.environment}", - "created-by:terraform", - "team:claranet", - "type:database", - "provider:elasticsearch", - "${var.jvm_gc_old_collection_latency_extra_tags}", - ] +tags = ["resource:elasticsearch", "env:${var.environment}", "created-by:terraform", "team:claranet", "type:database", "provider:elasticsearch", var.jvm_gc_old_collection_latency_extra_tags] } # # JVM Garbace Collector Young Collection Latency # resource "datadog_monitor" "jvm_gc_young_collection_latency" { - count = "${var.jvm_gc_young_collection_latency_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticsearch average Young-generation garbage collections latency {{#is_alert}}{{{comparator}}} {{threshold}}ms ({{value}}ms){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}ms ({{value}}ms){{/is_warning}}" - message = "${coalesce(var.jvm_gc_young_collection_latency_message, var.message)}" +count = var.jvm_gc_young_collection_latency_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticsearch average Young-generation garbage collections latency {{#is_alert}}{{{comparator}}} {{threshold}}ms ({{value}}ms){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}ms ({{value}}ms){{/is_warning}}" +message = coalesce(var.jvm_gc_young_collection_latency_message, var.message) +type = "query alert" - type = "query alert" - - query = < ${var.jvm_gc_young_collection_latency_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.jvm_gc_young_collection_latency_threshold_warning}" - critical = "${var.jvm_gc_young_collection_latency_threshold_critical}" - } +thresholds = { +warning = var.jvm_gc_young_collection_latency_threshold_warning +critical = var.jvm_gc_young_collection_latency_threshold_critical +} - notify_audit = false - locked = false - include_tags = true - require_full_window = true - notify_no_data = false +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay +notify_audit = false +locked = false +include_tags = true +require_full_window = true +notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - - tags = [ - "resource:elasticsearch", - "env:${var.environment}", - "created-by:terraform", - "team:claranet", - "type:database", - "provider:elasticsearch", - "${var.jvm_gc_young_collection_latency_extra_tags}", - ] +tags = ["resource:elasticsearch", "env:${var.environment}", "created-by:terraform", "team:claranet", "type:database", "provider:elasticsearch", var.jvm_gc_young_collection_latency_extra_tags] } # # Indexing Latency # resource "datadog_monitor" "indexing_latency" { - count = "${var.indexing_latency_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticsearch average indexing time by document {{#is_alert}}{{{comparator}}} {{threshold}}ms ({{value}}ms){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}ms ({{value}}ms){{/is_warning}}" - message = "${coalesce(var.indexing_latency_message, var.message)}" +count = var.indexing_latency_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticsearch average indexing time by document {{#is_alert}}{{{comparator}}} {{threshold}}ms ({{value}}ms){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}ms ({{value}}ms){{/is_warning}}" +message = coalesce(var.indexing_latency_message, var.message) +type = "query alert" - type = "query alert" - - // TODO add tags to filter by node type and do not apply this monitor on non-data nodes - query = < ${var.indexing_latency_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.indexing_latency_threshold_warning}" - critical = "${var.indexing_latency_threshold_critical}" + thresholds = { + warning = var.indexing_latency_threshold_warning + critical = var.indexing_latency_threshold_critical } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay notify_audit = false locked = false include_tags = true require_full_window = true notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - - tags = [ - "resource:elasticsearch", - "env:${var.environment}", - "created-by:terraform", - "team:claranet", - "type:database", - "provider:elasticsearch", - "${var.indexing_latency_extra_tags}", - ] + tags = ["resource:elasticsearch", "env:${var.environment}", "created-by:terraform", "team:claranet", "type:database", "provider:elasticsearch", var.indexing_latency_extra_tags] } # # Flush Latency # resource "datadog_monitor" "flush_latency" { - count = "${var.flush_latency_enabled == "true" ? 1 : 0}" + count = var.flush_latency_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticsearch average index flushing to disk latency {{#is_alert}}{{{comparator}}} {{threshold}}ms ({{value}}ms){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}ms ({{value}}ms){{/is_warning}}" - message = "${coalesce(var.flush_latency_message, var.message)}" - + message = coalesce(var.flush_latency_message, var.message) type = "query alert" // TODO add tags to filter by node type and do not apply this monitor on non-data nodes @@ -499,40 +391,31 @@ resource "datadog_monitor" "flush_latency" { ${var.flush_latency_time_aggregator}(${var.flush_latency_timeframe}): avg:elasticsearch.flush.total.time${module.filter-tags.query_alert} by {node_name} / avg:elasticsearch.flush.total${module.filter-tags.query_alert} by {node_name} * 1000 > ${var.flush_latency_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.flush_latency_threshold_warning}" - critical = "${var.flush_latency_threshold_critical}" + thresholds = { + warning = var.flush_latency_threshold_warning + critical = var.flush_latency_threshold_critical } - notify_audit = false - locked = false - include_tags = true + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay + notify_audit = false + locked = false + include_tags = true require_full_window = true - notify_no_data = false + notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - - tags = [ - "resource:elasticsearch", - "env:${var.environment}", - "created-by:terraform", - "team:claranet", - "type:database", - "provider:elasticsearch", - "${var.flush_latency_extra_tags}", - ] + tags = ["resource:elasticsearch", "env:${var.environment}", "created-by:terraform", "team:claranet", "type:database", "provider:elasticsearch", var.flush_latency_extra_tags] } # # Open HTTP Connections Anomaly # resource "datadog_monitor" "http_connections_anomaly" { - count = "${var.http_connections_anomaly_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticsearch number of current open HTTP connections anomaly detected" - message = "${coalesce(var.http_connections_anomaly_message, var.message)}" - + count = var.http_connections_anomaly_enabled == "true" ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticsearch number of current open HTTP connections anomaly detected" + message = coalesce(var.http_connections_anomaly_message, var.message) type = "query alert" query = <= ${var.http_connections_anomaly_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.http_connections_anomaly_threshold_warning}" - critical = "${var.http_connections_anomaly_threshold_critical}" - } +thresholds = { +warning = var.http_connections_anomaly_threshold_warning +critical = var.http_connections_anomaly_threshold_critical +} - notify_audit = false - locked = false - include_tags = true - require_full_window = true - notify_no_data = false +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay +notify_audit = false +locked = false +include_tags = true +require_full_window = true +notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - - tags = [ - "resource:elasticsearch", - "env:${var.environment}", - "created-by:terraform", - "team:claranet", - "type:database", - "provider:elasticsearch", - "${var.http_connections_anomaly_extra_tags}", - ] +tags = ["resource:elasticsearch", "env:${var.environment}", "created-by:terraform", "team:claranet", "type:database", "provider:elasticsearch", var.http_connections_anomaly_extra_tags] } # # Query Latency # resource "datadog_monitor" "search_query_latency" { - count = "${var.search_query_latency_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticsearch average search query latency {{#is_alert}}{{{comparator}}} {{threshold}}ms ({{value}}ms){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}ms ({{value}}ms){{/is_warning}}" - message = "${coalesce(var.search_query_latency_message, var.message)}" +count = var.search_query_latency_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticsearch average search query latency {{#is_alert}}{{{comparator}}} {{threshold}}ms ({{value}}ms){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}ms ({{value}}ms){{/is_warning}}" +message = coalesce(var.search_query_latency_message, var.message) +type = "query alert" - type = "query alert" - - // TODO add tags to filter by node type and do not apply this monitor on non-data nodes - query = < ${var.search_query_latency_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.search_query_latency_threshold_warning}" - critical = "${var.search_query_latency_threshold_critical}" - } +thresholds = { +warning = var.search_query_latency_threshold_warning +critical = var.search_query_latency_threshold_critical +} - notify_audit = false - locked = false - include_tags = true - require_full_window = true - notify_no_data = false +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay +notify_audit = false +locked = false +include_tags = true +require_full_window = true +notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - - tags = [ - "resource:elasticsearch", - "env:${var.environment}", - "created-by:terraform", - "team:claranet", - "type:database", - "provider:elasticsearch", - "${var.search_query_latency_extra_tags}", - ] +tags = ["resource:elasticsearch", "env:${var.environment}", "created-by:terraform", "team:claranet", "type:database", "provider:elasticsearch", var.search_query_latency_extra_tags] } # # Fetch Latency # resource "datadog_monitor" "fetch_latency" { - count = "${var.fetch_latency_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticsearch average search fetch latency {{#is_alert}}{{{comparator}}} {{threshold}}ms ({{value}}ms){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}ms ({{value}}ms){{/is_warning}}" - message = "${coalesce(var.fetch_latency_message, var.message)}" +count = var.fetch_latency_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticsearch average search fetch latency {{#is_alert}}{{{comparator}}} {{threshold}}ms ({{value}}ms){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}ms ({{value}}ms){{/is_warning}}" +message = coalesce(var.fetch_latency_message, var.message) +type = "query alert" - type = "query alert" - - // TODO add tags to filter by node type and do not apply this monitor on non-data nodes - query = < ${var.fetch_latency_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.fetch_latency_threshold_warning}" - critical = "${var.fetch_latency_threshold_critical}" + thresholds = { + warning = var.fetch_latency_threshold_warning + critical = var.fetch_latency_threshold_critical } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay notify_audit = false locked = false include_tags = true require_full_window = true notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - - tags = [ - "resource:elasticsearch", - "env:${var.environment}", - "created-by:terraform", - "team:claranet", - "type:database", - "provider:elasticsearch", - "${var.fetch_latency_extra_tags}", - ] + tags = ["resource:elasticsearch", "env:${var.environment}", "created-by:terraform", "team:claranet", "type:database", "provider:elasticsearch", var.fetch_latency_extra_tags] } # # Search Query Change # resource "datadog_monitor" "search_query_change" { - count = "${var.search_query_change_enabled == "true" ? 1 : 0}" + count = var.search_query_change_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticsearch change alert on the number of currently active queries" - message = "${coalesce(var.search_query_change_message, var.message)}" - + message = coalesce(var.search_query_change_message, var.message) type = "query alert" query = <= ${var.search_query_change_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.search_query_change_threshold_warning}" - critical = "${var.search_query_change_threshold_critical}" + thresholds = { + warning = var.search_query_change_threshold_warning + critical = var.search_query_change_threshold_critical } - notify_audit = false - locked = false - include_tags = true + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay + notify_audit = false + locked = false + include_tags = true require_full_window = true - notify_no_data = false + notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - - tags = [ - "resource:elasticsearch", - "env:${var.environment}", - "created-by:terraform", - "team:claranet", - "type:database", - "provider:elasticsearch", - "${var.search_query_change_extra_tags}", - ] + tags = ["resource:elasticsearch", "env:${var.environment}", "created-by:terraform", "team:claranet", "type:database", "provider:elasticsearch", var.search_query_change_extra_tags] } # # Fetch Change # resource "datadog_monitor" "fetch_change" { - count = "${var.fetch_change_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticsearch change alert on the number of search fetches currently running" - message = "${coalesce(var.fetch_change_message, var.message)}" - + count = var.fetch_change_enabled == "true" ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticsearch change alert on the number of search fetches currently running" + message = coalesce(var.fetch_change_message, var.message) type = "query alert" query = <= ${var.fetch_change_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.fetch_change_threshold_warning}" - critical = "${var.fetch_change_threshold_critical}" - } +thresholds = { +warning = var.fetch_change_threshold_warning +critical = var.fetch_change_threshold_critical +} - notify_audit = false - locked = false - include_tags = true - require_full_window = true - notify_no_data = false +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay +notify_audit = false +locked = false +include_tags = true +require_full_window = true +notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - - tags = [ - "resource:elasticsearch", - "env:${var.environment}", - "created-by:terraform", - "team:claranet", - "type:database", - "provider:elasticsearch", - "${var.fetch_change_extra_tags}", - ] +tags = ["resource:elasticsearch", "env:${var.environment}", "created-by:terraform", "team:claranet", "type:database", "provider:elasticsearch", var.fetch_change_extra_tags] } # # Field Data Evictions # resource "datadog_monitor" "field_data_evictions_change" { - count = "${var.field_data_evictions_change_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticsearch change alert on the total number of evictions from the fielddata cache" - message = "${coalesce(var.field_data_evictions_change_message, var.message)}" +count = var.field_data_evictions_change_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticsearch change alert on the total number of evictions from the fielddata cache" +message = coalesce(var.field_data_evictions_change_message, var.message) +type = "query alert" - type = "query alert" - - // TODO add tags to filter by node type and do not apply this monitor on non-data nodes - query = < ${var.field_data_evictions_change_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.field_data_evictions_change_threshold_warning}" - critical = "${var.field_data_evictions_change_threshold_critical}" - } +thresholds = { +warning = var.field_data_evictions_change_threshold_warning +critical = var.field_data_evictions_change_threshold_critical +} - notify_audit = false - locked = false - include_tags = true - require_full_window = true - notify_no_data = false +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay +notify_audit = false +locked = false +include_tags = true +require_full_window = true +notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - - tags = [ - "resource:elasticsearch", - "env:${var.environment}", - "created-by:terraform", - "team:claranet", - "type:database", - "provider:elasticsearch", - "${var.field_data_evictions_change_extra_tags}", - ] +tags = ["resource:elasticsearch", "env:${var.environment}", "created-by:terraform", "team:claranet", "type:database", "provider:elasticsearch", var.field_data_evictions_change_extra_tags] } # # Query Cache Evictions # resource "datadog_monitor" "query_cache_evictions_change" { - count = "${var.query_cache_evictions_change_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticsearch change alert on the number of query cache evictions" - message = "${coalesce(var.query_cache_evictions_change_message, var.message)}" +count = var.query_cache_evictions_change_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticsearch change alert on the number of query cache evictions" +message = coalesce(var.query_cache_evictions_change_message, var.message) +type = "query alert" - type = "query alert" - - // TODO add tags to filter by node type and do not apply this monitor on non-data nodes - query = < ${var.query_cache_evictions_change_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.query_cache_evictions_change_threshold_warning}" - critical = "${var.query_cache_evictions_change_threshold_critical}" + thresholds = { + warning = var.query_cache_evictions_change_threshold_warning + critical = var.query_cache_evictions_change_threshold_critical } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay notify_audit = false locked = false include_tags = true require_full_window = true notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - - tags = [ - "resource:elasticsearch", - "env:${var.environment}", - "created-by:terraform", - "team:claranet", - "type:database", - "provider:elasticsearch", - "${var.query_cache_evictions_change_extra_tags}", - ] + tags = ["resource:elasticsearch", "env:${var.environment}", "created-by:terraform", "team:claranet", "type:database", "provider:elasticsearch", var.query_cache_evictions_change_extra_tags] } # # Request Cache Evictions # resource "datadog_monitor" "request_cache_evictions_change" { - count = "${var.request_cache_evictions_change_enabled == "true" ? 1 : 0}" + count = var.request_cache_evictions_change_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticsearch change alert on the number of request cache evictions" - message = "${coalesce(var.request_cache_evictions_change_message, var.message)}" - + message = coalesce(var.request_cache_evictions_change_message, var.message) type = "query alert" // TODO add tags to filter by node type and do not apply this monitor on non-data nodes @@ -832,68 +652,52 @@ resource "datadog_monitor" "request_cache_evictions_change" { change(${var.request_cache_evictions_change_time_aggregator}(${var.request_cache_evictions_change_timeframe}),${var.request_cache_evictions_change_timeshift}): avg:elasticsearch.indices.request_cache.evictions${module.filter-tags.query_alert} by {node_name} > ${var.request_cache_evictions_change_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.request_cache_evictions_change_threshold_warning}" - critical = "${var.request_cache_evictions_change_threshold_critical}" + thresholds = { + warning = var.request_cache_evictions_change_threshold_warning + critical = var.request_cache_evictions_change_threshold_critical } - notify_audit = false - locked = false - include_tags = true + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay + notify_audit = false + locked = false + include_tags = true require_full_window = true - notify_no_data = false + notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - - tags = [ - "resource:elasticsearch", - "env:${var.environment}", - "created-by:terraform", - "team:claranet", - "type:database", - "provider:elasticsearch", - "${var.request_cache_evictions_change_extra_tags}", - ] + tags = ["resource:elasticsearch", "env:${var.environment}", "created-by:terraform", "team:claranet", "type:database", "provider:elasticsearch", var.request_cache_evictions_change_extra_tags] } # # Task Time in Queue # resource "datadog_monitor" "task_time_in_queue_change" { - count = "${var.task_time_in_queue_change_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticsearch change alert on the average time spent by tasks in the queue" - message = "${coalesce(var.task_time_in_queue_change_message, var.message)}" - + count = var.task_time_in_queue_change_enabled == "true" ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Elasticsearch change alert on the average time spent by tasks in the queue" + message = coalesce(var.task_time_in_queue_change_message, var.message) type = "query alert" query = < ${var.task_time_in_queue_change_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.task_time_in_queue_change_threshold_warning}" - critical = "${var.task_time_in_queue_change_threshold_critical}" - } - - notify_audit = false - locked = false - include_tags = true - require_full_window = true - notify_no_data = false - - evaluation_delay = "${var.evaluation_delay}" - - tags = [ - "resource:elasticsearch", - "env:${var.environment}", - "created-by:terraform", - "team:claranet", - "type:database", - "provider:elasticsearch", - "${var.task_time_in_queue_change_extra_tags}", - ] +thresholds = { +warning = var.task_time_in_queue_change_threshold_warning +critical = var.task_time_in_queue_change_threshold_critical } + +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay +notify_audit = false +locked = false +include_tags = true +require_full_window = true +notify_no_data = false + +tags = ["resource:elasticsearch", "env:${var.environment}", "created-by:terraform", "team:claranet", "type:database", "provider:elasticsearch", var.task_time_in_queue_change_extra_tags] +} + diff --git a/database/elasticsearch/outputs.tf b/database/elasticsearch/outputs.tf index 9c90913..5a694bb 100644 --- a/database/elasticsearch/outputs.tf +++ b/database/elasticsearch/outputs.tf @@ -1,109 +1,110 @@ output "not_responding_id" { description = "id for monitor not_responding" - value = "${datadog_monitor.not_responding.*.id}" + value = datadog_monitor.not_responding.*.id } output "cluster_status_not_green_id" { description = "id for monitor cluster_status_not_green" - value = "${datadog_monitor.cluster_status_not_green.*.id}" + value = datadog_monitor.cluster_status_not_green.*.id } output "cluster_initializing_shards_id" { description = "id for monitor cluster_initializing_shards" - value = "${datadog_monitor.cluster_initializing_shards.*.id}" + value = datadog_monitor.cluster_initializing_shards.*.id } output "cluster_relocating_shards_id" { description = "id for monitor cluster_relocating_shards" - value = "${datadog_monitor.cluster_relocating_shards.*.id}" + value = datadog_monitor.cluster_relocating_shards.*.id } output "cluster_unassigned_shards_id" { description = "id for monitor cluster_unassigned_shards" - value = "${datadog_monitor.cluster_unassigned_shards.*.id}" + value = datadog_monitor.cluster_unassigned_shards.*.id } output "node_free_space_id" { description = "id for monitor node_free_space" - value = "${datadog_monitor.node_free_space.*.id}" + value = datadog_monitor.node_free_space.*.id } output "jvm_heap_memory_usage_id" { description = "id for monitor jvm_heap_memory_usage" - value = "${datadog_monitor.jvm_heap_memory_usage.*.id}" + value = datadog_monitor.jvm_heap_memory_usage.*.id } output "jvm_memory_young_usage_id" { description = "id for monitor jvm_memory_young_usage" - value = "${datadog_monitor.jvm_memory_young_usage.*.id}" + value = datadog_monitor.jvm_memory_young_usage.*.id } output "jvm_memory_old_usage_id" { description = "id for monitor jvm_memory_old_usage" - value = "${datadog_monitor.jvm_memory_old_usage.*.id}" + value = datadog_monitor.jvm_memory_old_usage.*.id } output "jvm_gc_old_collection_latency_id" { description = "id for monitor jvm_gc_old_collection_latency" - value = "${datadog_monitor.jvm_gc_old_collection_latency.*.id}" + value = datadog_monitor.jvm_gc_old_collection_latency.*.id } output "jvm_gc_young_collection_latency_id" { description = "id for monitor jvm_gc_young_collection_latency" - value = "${datadog_monitor.jvm_gc_young_collection_latency.*.id}" + value = datadog_monitor.jvm_gc_young_collection_latency.*.id } output "indexing_latency_id" { description = "id for monitor indexing_latency" - value = "${datadog_monitor.indexing_latency.*.id}" + value = datadog_monitor.indexing_latency.*.id } output "flush_latency_id" { description = "id for monitor flush_latency" - value = "${datadog_monitor.flush_latency.*.id}" + value = datadog_monitor.flush_latency.*.id } output "http_connections_anomaly_id" { description = "id for monitor http_connections_anomaly" - value = "${datadog_monitor.http_connections_anomaly.*.id}" + value = datadog_monitor.http_connections_anomaly.*.id } output "search_query_latency_id" { description = "id for monitor search_query_latency" - value = "${datadog_monitor.search_query_latency.*.id}" + value = datadog_monitor.search_query_latency.*.id } output "fetch_latency_id" { description = "id for monitor fetch_latency" - value = "${datadog_monitor.fetch_latency.*.id}" + value = datadog_monitor.fetch_latency.*.id } output "search_query_change_id" { description = "id for monitor search_query_change" - value = "${datadog_monitor.search_query_change.*.id}" + value = datadog_monitor.search_query_change.*.id } output "fetch_change_id" { description = "id for monitor fetch_change" - value = "${datadog_monitor.fetch_change.*.id}" + value = datadog_monitor.fetch_change.*.id } output "field_data_evictions_change_id" { description = "id for monitor field_data_evictions_change" - value = "${datadog_monitor.field_data_evictions_change.*.id}" + value = datadog_monitor.field_data_evictions_change.*.id } output "query_cache_evictions_change_id" { description = "id for monitor query_cache_evictions_change" - value = "${datadog_monitor.query_cache_evictions_change.*.id}" + value = datadog_monitor.query_cache_evictions_change.*.id } output "request_cache_evictions_change_id" { description = "id for monitor request_cache_evictions_change" - value = "${datadog_monitor.request_cache_evictions_change.*.id}" + value = datadog_monitor.request_cache_evictions_change.*.id } output "task_time_in_queue_change_id" { description = "id for monitor task_time_in_queue_change" - value = "${datadog_monitor.task_time_in_queue_change.*.id}" + value = datadog_monitor.task_time_in_queue_change.*.id } + diff --git a/database/elasticsearch/versions.tf b/database/elasticsearch/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/database/elasticsearch/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/database/mongodb/inputs.tf b/database/mongodb/inputs.tf index 0752b84..521f3ef 100644 --- a/database/mongodb/inputs.tf +++ b/database/mongodb/inputs.tf @@ -1,7 +1,7 @@ # Global Terraform variable "environment" { description = "Architecture Environment" - type = "string" + type = string } # Global DataDog @@ -46,25 +46,25 @@ variable "mongodb_desired_servers_count" { variable "mongodb_primary_timeframe" { description = "Monitor timeframe for MongoDB wrong state for primary node [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_1m" } variable "mongodb_secondary_timeframe" { description = "Monitor timeframe for MongoDB wrong state for secondaries nodes [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } variable "mongodb_server_count_timeframe" { description = "Monitor timeframe for MongoDB wrong server count [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_15m" } variable "mongodb_replication_timeframe" { description = "Monitor timeframe for MongoDB replication lag [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_1m" } @@ -80,90 +80,91 @@ variable "mongodb_lag_critical" { variable "mongodb_primary_enabled" { description = "Flag to enable MongoDB primary state monitor" - type = "string" + type = string default = "true" } variable "mongodb_primary_extra_tags" { description = "Extra tags for MongoDB primary state monitor" - type = "list" + type = list(string) default = [] } variable "mongodb_secondary_enabled" { description = "Flag to enable MongoDB secondary state monitor" - type = "string" + type = string default = "true" } variable "mongodb_secondary_extra_tags" { description = "Extra tags for MongoDB secondary state monitor" - type = "list" + type = list(string) default = [] } variable "mongodb_server_count_enabled" { description = "Flag to enable MongoDB server count monitor" - type = "string" + type = string default = "true" } variable "mongodb_replication_enabled" { description = "Flag to enable MongoDB replication lag monitor" - type = "string" + type = string default = "true" } variable "mongodb_replication_extra_tags" { description = "Extra tags for MongoDB replication lag monitor" - type = "list" + type = list(string) default = [] } variable "mongodb_primary_message" { description = "Custom message for MongoDB primary monitor" - type = "string" + type = string default = "" } variable "mongodb_secondary_message" { description = "Custom message for MongoDB secondary monitor" - type = "string" + type = string default = "" } variable "mongodb_server_count_message" { description = "Custom message for MongoDB server count" - type = "string" + type = string default = "" } variable "mongodb_replication_message" { description = "Custom message for MongoDB replication monitor" - type = "string" + type = string default = "" } variable "mongodb_primary_aggregator" { description = "Monitor aggregator for MongoDB primary state [available values: min, max]" - type = "string" + type = string default = "max" } variable "mongodb_secondary_aggregator" { description = "Monitor aggregator for MongoDB secondary state [available values: min, max]" - type = "string" + type = string default = "max" } variable "mongodb_server_count_aggregator" { description = "Monitor aggregator for MongoDB server count [available values: min, max]" - type = "string" + type = string default = "min" } variable "mongodb_replication_aggregator" { description = "Monitor aggregator for MongoDB replication lag [available values: min, max, sum or avg]" - type = "string" + type = string default = "avg" } + diff --git a/database/mongodb/modules.tf b/database/mongodb/modules.tf index 65fdce3..1ff409d 100644 --- a/database/mongodb/modules.tf +++ b/database/mongodb/modules.tf @@ -1,20 +1,21 @@ module "filter-tags" { source = "../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "mongodb" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded } module "filter-tags-secondary" { source = "../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "mongodb" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded extra_tags = ["replset_state:secondary"] } + diff --git a/database/mongodb/monitors-mongo.tf b/database/mongodb/monitors-mongo.tf index f251bf6..2e3aa0e 100644 --- a/database/mongodb/monitors-mongo.tf +++ b/database/mongodb/monitors-mongo.tf @@ -1,113 +1,111 @@ resource "datadog_monitor" "mongodb_primary" { - count = "${var.mongodb_primary_enabled == "true" ? 1 : 0}" + 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)}" + message = coalesce(var.mongodb_primary_message, var.message) + type = "metric alert" query = <= 2 - EOQ +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 + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay + notify_no_data = true + renotify_interval = 0 + 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}"] + 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)}" + 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) + type = "query alert" query = < 1 - EOQ +EOQ - thresholds { - critical = 1 - warning = 0 - } +thresholds = { +critical = 1 +warning = 0 +} - type = "query alert" +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay +notify_no_data = false +renotify_interval = 0 +notify_audit = false +timeout_h = 0 +include_tags = true +require_full_window = true - 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}"] +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)}" +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) +type = "metric alert" - query = < 99 - EOQ + +EOQ - thresholds { - critical = 99 - warning = "${var.mongodb_desired_servers_count}" - } +thresholds = { +critical = 99 +warning = var.mongodb_desired_servers_count +} - type = "metric alert" +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay +notify_no_data = false +renotify_interval = 0 +notify_audit = false +timeout_h = 0 +include_tags = true +require_full_window = true - 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}"] +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)}" +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) +type = "metric alert" - query = < ${var.mongodb_lag_critical} - EOQ +EOQ - thresholds { - critical = "${var.mongodb_lag_critical}" - warning = "${var.mongodb_lag_warning}" + thresholds = { + critical = var.mongodb_lag_critical + warning = var.mongodb_lag_warning } - type = "metric alert" - + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay 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}"] + tags = ["env:${var.environment}", "type:database", "provider:mongo", "resource:mongodb", "team:claranet", "created-by:terraform", var.mongodb_replication_extra_tags] } + diff --git a/database/mongodb/outputs.tf b/database/mongodb/outputs.tf index 4fb112b..15bf560 100644 --- a/database/mongodb/outputs.tf +++ b/database/mongodb/outputs.tf @@ -1,19 +1,20 @@ output "mongodb_primary_id" { description = "id for monitor mongodb_primary" - value = "${datadog_monitor.mongodb_primary.*.id}" + value = datadog_monitor.mongodb_primary.*.id } output "mongodb_secondary_id" { description = "id for monitor mongodb_secondary" - value = "${datadog_monitor.mongodb_secondary.*.id}" + value = datadog_monitor.mongodb_secondary.*.id } output "mongodb_server_count_id" { description = "id for monitor mongodb_server_count" - value = "${datadog_monitor.mongodb_server_count.*.id}" + value = datadog_monitor.mongodb_server_count.*.id } output "mongodb_replication_id" { description = "id for monitor mongodb_replication" - value = "${datadog_monitor.mongodb_replication.*.id}" + value = datadog_monitor.mongodb_replication.*.id } + diff --git a/database/mongodb/versions.tf b/database/mongodb/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/database/mongodb/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/database/mysql/inputs.tf b/database/mysql/inputs.tf index fe36a33..ee5344e 100644 --- a/database/mysql/inputs.tf +++ b/database/mysql/inputs.tf @@ -1,6 +1,6 @@ variable "environment" { description = "Environment" - type = "string" + type = string } variable "evaluation_delay" { @@ -45,31 +45,31 @@ variable "filter_tags_custom_excluded" { variable "mysql_availability_enabled" { description = "Flag to enable Mysql availability monitor" - type = "string" + type = string default = "true" } variable "mysql_availability_extra_tags" { description = "Extra tags for Mysql availability monitor" - type = "list" + type = list(string) default = [] } variable "mysql_availability_message" { description = "Custom message for Mysql availability monitor" - type = "string" + type = string default = "" } variable "mysql_availability_threshold_warning" { description = "Mysql availability monitor (warning threshold)" - type = "string" + type = string default = 3 } variable "mysql_availability_no_data_timeframe" { description = "Mysql availability monitor no data timeframe" - type = "string" + type = string default = 10 } @@ -79,19 +79,19 @@ variable "mysql_availability_no_data_timeframe" { variable "mysql_connection_enabled" { description = "Flag to enable MySQL connection monitor" - type = "string" + type = string default = "true" } variable "mysql_connection_extra_tags" { description = "Extra tags for MySQL connection monitor" - type = "list" + type = list(string) default = [] } variable "mysql_connection_message" { description = "Custom message for MySQL connection monitor" - type = "string" + type = string default = "" } @@ -107,13 +107,13 @@ variable "mysql_connection_threshold_warning" { variable "mysql_connection_time_aggregator" { description = "Monitor time aggregator for MySQL connection monitor [available values: min, max or avg]" - type = "string" + type = string default = "avg" } variable "mysql_connection_timeframe" { description = "Monitor timeframe for MySQL connection monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_10m" } @@ -123,19 +123,19 @@ variable "mysql_connection_timeframe" { variable "mysql_aborted_enabled" { description = "Flag to enable MySQL aborted connects monitor" - type = "string" + type = string default = "true" } variable "mysql_aborted_extra_tags" { description = "Extra tags for MySQL aborted connects monitor" - type = "list" + type = list(string) default = [] } variable "mysql_aborted_message" { description = "Custom message for MySQL aborted connects monitor" - type = "string" + type = string default = "" } @@ -151,13 +151,13 @@ variable "mysql_aborted_threshold_warning" { variable "mysql_aborted_time_aggregator" { description = "Monitor time aggregator for MySQL aborted connects monitor [available values: min, max or avg]" - type = "string" + type = string default = "avg" } variable "mysql_aborted_timeframe" { description = "Monitor timeframe for MySQL aborted connects monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_10m" } @@ -167,19 +167,19 @@ variable "mysql_aborted_timeframe" { variable "mysql_slow_enabled" { description = "Flag to enable MySQL slow queries monitor" - type = "string" + type = string default = "true" } variable "mysql_slow_extra_tags" { description = "Extra tags for MySQL slow queries monitor" - type = "list" + type = list(string) default = [] } variable "mysql_slow_message" { description = "Custom message for MySQL slow queries monitor" - type = "string" + type = string default = "" } @@ -195,13 +195,13 @@ variable "mysql_slow_threshold_warning" { variable "mysql_slow_time_aggregator" { description = "Monitor time aggregator for MySQL slow queries monitor [available values: min, max or avg]" - type = "string" + type = string default = "avg" } variable "mysql_slow_timeframe" { description = "Monitor timeframe for MySQL slow queries monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_15m" } @@ -211,19 +211,19 @@ variable "mysql_slow_timeframe" { variable "mysql_pool_efficiency_enabled" { description = "Flag to enable MySQL innodb buffer pool efficiency monitor" - type = "string" + type = string default = "true" } variable "mysql_pool_efficiency_extra_tags" { description = "Extra tags for MySQL innodb buffer pool efficiency monitor" - type = "list" + type = list(string) default = [] } variable "mysql_pool_efficiency_message" { description = "Custom message for MySQL innodb buffer pool efficiency monitor" - type = "string" + type = string default = "" } @@ -239,13 +239,13 @@ variable "mysql_pool_efficiency_threshold_warning" { variable "mysql_pool_efficiency_time_aggregator" { description = "Monitor time aggregator for MySQL innodb buffer pool efficiency monitor [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "mysql_pool_efficiency_timeframe" { description = "Monitor timeframe for MySQL innodb buffer pool efficiency monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_1h" } @@ -255,19 +255,19 @@ variable "mysql_pool_efficiency_timeframe" { variable "mysql_pool_utilization_enabled" { description = "Flag to enable MySQL innodb buffer pool utilization monitor" - type = "string" + type = string default = "true" } variable "mysql_pool_utilization_extra_tags" { description = "Extra tags for MySQL innodb buffer pool utilization monitor" - type = "list" + type = list(string) default = [] } variable "mysql_pool_utilization_message" { description = "Custom message for MySQL innodb buffer pool utilization monitor" - type = "string" + type = string default = "" } @@ -283,13 +283,13 @@ variable "mysql_pool_utilization_threshold_warning" { variable "mysql_pool_utilization_time_aggregator" { description = "Monitor time aggregator for MySQL innodb buffer pool utilization monitor [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "mysql_pool_utilization_timeframe" { description = "Monitor timeframe for MySQL innodb buffer pool utilization monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_1h" } @@ -299,19 +299,19 @@ variable "mysql_pool_utilization_timeframe" { variable "mysql_threads_enabled" { description = "Flag to enable mysql threads monitor" - type = "string" + type = string default = "true" } variable "mysql_threads_extra_tags" { description = "Extra tags for MySQL threads monitor" - type = "list" + type = list(string) default = [] } variable "mysql_threads_message" { description = "Custom message for MySQL threads monitor" - type = "string" + type = string default = "" } @@ -322,55 +322,55 @@ variable "mysql_threads_threshold_critical" { variable "mysql_threads_detection_algorithm" { description = "Anomaly Detection Algorithm used" - type = "string" + type = string default = "basic" } variable "mysql_threads_deviations" { description = "Deviations to detect the anomaly" - type = "string" + type = string default = 2 } variable "mysql_threads_direction" { description = "Direction of the anomaly. It can be both, below or above." - type = "string" + type = string default = "above" } variable "mysql_threads_alert_window" { description = "Alert window." - type = "string" + type = string default = "last_15m" } variable "mysql_threads_interval" { description = "Interval." - type = "string" + type = string default = 60 } variable "mysql_threads_count_default_zero" { description = "Count default zero." - type = "string" + type = string default = "true" } variable "mysql_threads_seasonality" { description = "Seasonality of the algorithm" - type = "string" + type = string default = "daily" } variable "mysql_threads_time_aggregator" { description = "Monitor time aggregator for MySQL threads monitor [available values: min, max or avg]" - type = "string" + type = string default = "avg" } variable "mysql_threads_timeframe" { description = "Monitor timeframe for MySQL threads monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_4h" } @@ -380,19 +380,19 @@ variable "mysql_threads_timeframe" { variable "mysql_questions_enabled" { description = "Flag to enable mysql queries monitor" - type = "string" + type = string default = "true" } variable "mysql_questions_extra_tags" { description = "Extra tags for MySQL queries monitor" - type = "list" + type = list(string) default = [] } variable "mysql_questions_message" { description = "Custom message for MySQL queries monitor" - type = "string" + type = string default = "" } @@ -403,54 +403,55 @@ variable "mysql_questions_threshold_critical" { variable "mysql_questions_detection_algorithm" { description = "Anomaly Detection Algorithm used" - type = "string" + type = string default = "agile" } variable "mysql_questions_deviations" { description = "Deviations to detect the anomaly" - type = "string" + type = string default = 5 } variable "mysql_questions_direction" { description = "Direction of the anomaly. It can be both, below or above." - type = "string" + type = string default = "both" } variable "mysql_questions_alert_window" { description = "Alert window." - type = "string" + type = string default = "last_15m" } variable "mysql_questions_interval" { description = "Interval." - type = "string" + type = string default = 60 } variable "mysql_questions_count_default_zero" { description = "Count default zero." - type = "string" + type = string default = "true" } variable "mysql_questions_seasonality" { description = "Seasonality of the algorithm" - type = "string" + type = string default = "daily" } variable "mysql_questions_time_aggregator" { description = "Monitor time aggregator for MySQL queries monitor [available values: min, max or avg]" - type = "string" + type = string default = "avg" } variable "mysql_questions_timeframe" { description = "Monitor timeframe for MySQL queries monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_4h" } + diff --git a/database/mysql/modules.tf b/database/mysql/modules.tf index 90ef22e..37d1850 100644 --- a/database/mysql/modules.tf +++ b/database/mysql/modules.tf @@ -1,9 +1,10 @@ module "filter-tags" { source = "../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "mysql" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded } + diff --git a/database/mysql/monitors-mysql.tf b/database/mysql/monitors-mysql.tf index d599e88..31511fe 100644 --- a/database/mysql/monitors-mysql.tf +++ b/database/mysql/monitors-mysql.tf @@ -1,36 +1,35 @@ resource "datadog_monitor" "mysql_availability" { - count = "${var.mysql_availability_enabled == "true" ? 1 : 0}" + count = var.mysql_availability_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Mysql server does not respond" - message = "${coalesce(var.mysql_availability_message, var.message)}" - + message = coalesce(var.mysql_availability_message, var.message) type = "service check" query = < ${var.mysql_connection_threshold_critical} - EOQ +EOQ - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" +thresholds = { +warning = var.mysql_connection_threshold_warning +critical = var.mysql_connection_threshold_critical +} - thresholds { - warning = "${var.mysql_connection_threshold_warning}" - critical = "${var.mysql_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 - notify_no_data = false - renotify_interval = 0 - require_full_window = true - timeout_h = 0 - include_tags = true - - tags = ["env:${var.environment}", "type:database", "provider:mysql", "resource:mysql", "team:claranet", "created-by:terraform", "${var.mysql_connection_extra_tags}"] +tags = ["env:${var.environment}", "type:database", "provider:mysql", "resource:mysql", "team:claranet", "created-by:terraform", var.mysql_connection_extra_tags] } resource "datadog_monitor" "mysql_aborted" { - count = "${var.mysql_aborted_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Mysql Aborted connects {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.mysql_aborted_message, var.message)}" - type = "query alert" +count = var.mysql_aborted_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Mysql Aborted connects {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +message = coalesce(var.mysql_aborted_message, var.message) +type = "query alert" - query = < ${var.mysql_aborted_threshold_critical} - EOQ +EOQ - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" +thresholds = { +warning = var.mysql_aborted_threshold_warning +critical = var.mysql_aborted_threshold_critical +} - thresholds { - warning = "${var.mysql_aborted_threshold_warning}" - critical = "${var.mysql_aborted_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 - notify_no_data = false - renotify_interval = 0 - require_full_window = true - timeout_h = 0 - include_tags = true - - tags = ["env:${var.environment}", "type:database", "provider:mysql", "resource:mysql", "team:claranet", "created-by:terraform", "${var.mysql_aborted_extra_tags}"] +tags = ["env:${var.environment}", "type:database", "provider:mysql", "resource:mysql", "team:claranet", "created-by:terraform", var.mysql_aborted_extra_tags] } resource "datadog_monitor" "mysql_slow" { - count = "${var.mysql_slow_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Mysql Slow queries {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.mysql_slow_message, var.message)}" - type = "query alert" +count = var.mysql_slow_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Mysql Slow queries {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +message = coalesce(var.mysql_slow_message, var.message) +type = "query alert" - query = < ${var.mysql_slow_threshold_critical} - EOQ +EOQ - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" - - thresholds { - warning = "${var.mysql_slow_threshold_warning}" - critical = "${var.mysql_slow_threshold_critical}" + thresholds = { + warning = var.mysql_slow_threshold_warning + critical = var.mysql_slow_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:mysql", "resource:mysql", "team:claranet", "created-by:terraform", "${var.mysql_slow_extra_tags}"] + tags = ["env:${var.environment}", "type:database", "provider:mysql", "resource:mysql", "team:claranet", "created-by:terraform", var.mysql_slow_extra_tags] } resource "datadog_monitor" "mysql_pool_efficiency" { - count = "${var.mysql_pool_efficiency_enabled == "true" ? 1 : 0}" + count = var.mysql_pool_efficiency_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Mysql Innodb buffer pool efficiency {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}" - message = "${coalesce(var.mysql_pool_efficiency_message, var.message)}" + message = coalesce(var.mysql_pool_efficiency_message, var.message) type = "query alert" query = < ${var.mysql_pool_efficiency_threshold_critical} - EOQ +EOQ - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" - - thresholds { - warning = "${var.mysql_pool_efficiency_threshold_warning}" - critical = "${var.mysql_pool_efficiency_threshold_critical}" + thresholds = { + warning = var.mysql_pool_efficiency_threshold_warning + critical = var.mysql_pool_efficiency_threshold_critical } - notify_no_data = false - renotify_interval = 0 + 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 + timeout_h = 0 + include_tags = true - tags = ["env:${var.environment}", "type:database", "provider:mysql", "resource:mysql", "team:claranet", "created-by:terraform", "${var.mysql_pool_efficiency_extra_tags}"] + tags = ["env:${var.environment}", "type:database", "provider:mysql", "resource:mysql", "team:claranet", "created-by:terraform", var.mysql_pool_efficiency_extra_tags] } resource "datadog_monitor" "mysql_pool_utilization" { - count = "${var.mysql_pool_utilization_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Mysql Innodb buffer pool utilization {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}" - message = "${coalesce(var.mysql_pool_utilization_message, var.message)}" + count = var.mysql_pool_utilization_enabled == "true" ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Mysql Innodb buffer pool utilization {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}" + message = coalesce(var.mysql_pool_utilization_message, var.message) type = "query alert" query = < ${var.mysql_pool_utilization_threshold_critical} - EOQ +EOQ - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" +thresholds = { +warning = var.mysql_pool_utilization_threshold_warning +critical = var.mysql_pool_utilization_threshold_critical +} - thresholds { - warning = "${var.mysql_pool_utilization_threshold_warning}" - critical = "${var.mysql_pool_utilization_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 - notify_no_data = false - renotify_interval = 0 - require_full_window = true - timeout_h = 0 - include_tags = true - - tags = ["env:${var.environment}", "type:database", "provider:mysql", "resource:mysql", "team:claranet", "created-by:terraform", "${var.mysql_pool_utilization_extra_tags}"] +tags = ["env:${var.environment}", "type:database", "provider:mysql", "resource:mysql", "team:claranet", "created-by:terraform", var.mysql_pool_utilization_extra_tags] } resource "datadog_monitor" "mysql_threads_anomaly" { - count = "${var.mysql_threads_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Mysql threads changed abnormally" - message = "${coalesce(var.mysql_threads_message, var.message)}" - type = "metric alert" +count = var.mysql_threads_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Mysql threads changed abnormally" +message = coalesce(var.mysql_threads_message, var.message) +type = "metric alert" - query = <= ${var.mysql_threads_threshold_critical} - EOQ +EOQ - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" +thresholds = { +critical = var.mysql_threads_threshold_critical +critical_recovery = 0 +} - thresholds { - critical = "${var.mysql_threads_threshold_critical}" - critical_recovery = 0 - } +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 - notify_no_data = false - renotify_interval = 0 - require_full_window = true - timeout_h = 0 - include_tags = true - - tags = ["env:${var.environment}", "type:database", "provider:mysql", "resource:mysql", "team:claranet", "created-by:terraform", "${var.mysql_threads_extra_tags}"] +tags = ["env:${var.environment}", "type:database", "provider:mysql", "resource:mysql", "team:claranet", "created-by:terraform", var.mysql_threads_extra_tags] } resource "datadog_monitor" "mysql_questions_anomaly" { - count = "${var.mysql_questions_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Mysql queries changed abnormally" - message = "${coalesce(var.mysql_questions_message, var.message)}" - type = "metric alert" +count = var.mysql_questions_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Mysql queries changed abnormally" +message = coalesce(var.mysql_questions_message, var.message) +type = "metric alert" - query = <= ${var.mysql_questions_threshold_critical} - EOQ +EOQ - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" - - thresholds { - critical = "${var.mysql_questions_threshold_critical}" + thresholds = { + critical = var.mysql_questions_threshold_critical critical_recovery = 0 } + 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:mysql", "resource:mysql", "team:claranet", "created-by:terraform", "${var.mysql_questions_extra_tags}"] + tags = ["env:${var.environment}", "type:database", "provider:mysql", "resource:mysql", "team:claranet", "created-by:terraform", var.mysql_questions_extra_tags] } + diff --git a/database/mysql/outputs.tf b/database/mysql/outputs.tf index 0c35ddc..0e1681c 100644 --- a/database/mysql/outputs.tf +++ b/database/mysql/outputs.tf @@ -1,39 +1,40 @@ output "mysql_availability_id" { description = "id for monitor mysql_availability" - value = "${datadog_monitor.mysql_availability.*.id}" + value = datadog_monitor.mysql_availability.*.id } output "mysql_connection_id" { description = "id for monitor mysql_connection" - value = "${datadog_monitor.mysql_connection.*.id}" + value = datadog_monitor.mysql_connection.*.id } output "mysql_aborted_id" { description = "id for monitor mysql_aborted" - value = "${datadog_monitor.mysql_aborted.*.id}" + value = datadog_monitor.mysql_aborted.*.id } output "mysql_slow_id" { description = "id for monitor mysql_slow" - value = "${datadog_monitor.mysql_slow.*.id}" + value = datadog_monitor.mysql_slow.*.id } output "mysql_pool_efficiency_id" { description = "id for monitor mysql_pool_efficiency" - value = "${datadog_monitor.mysql_pool_efficiency.*.id}" + value = datadog_monitor.mysql_pool_efficiency.*.id } output "mysql_pool_utilization_id" { description = "id for monitor mysql_pool_utilization" - value = "${datadog_monitor.mysql_pool_utilization.*.id}" + value = datadog_monitor.mysql_pool_utilization.*.id } output "mysql_threads_anomaly_id" { description = "id for monitor mysql_threads_anomaly" - value = "${datadog_monitor.mysql_threads_anomaly.*.id}" + value = datadog_monitor.mysql_threads_anomaly.*.id } output "mysql_questions_anomaly_id" { description = "id for monitor mysql_questions_anomaly" - value = "${datadog_monitor.mysql_questions_anomaly.*.id}" + value = datadog_monitor.mysql_questions_anomaly.*.id } + diff --git a/database/mysql/versions.tf b/database/mysql/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/database/mysql/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/database/postgresql/inputs.tf b/database/postgresql/inputs.tf index e761e1e..b505161 100644 --- a/database/postgresql/inputs.tf +++ b/database/postgresql/inputs.tf @@ -1,6 +1,6 @@ variable "environment" { description = "Environment" - type = "string" + type = string } # Global DataDog @@ -45,31 +45,31 @@ variable "filter_tags_custom_excluded" { variable "postgresql_availability_enabled" { description = "Flag to enable PostgreSQL availability monitor" - type = "string" + type = string default = "true" } variable "postgresql_availability_extra_tags" { description = "Extra tags for PostgreSQL availability monitor" - type = "list" + type = list(string) default = [] } variable "postgresql_availability_message" { description = "Custom message for PostgreSQL availability monitor" - type = "string" + type = string default = "" } variable "postgresql_availability_threshold_warning" { description = "PostgreSQL availability monitor (warning threshold)" - type = "string" + type = string default = 3 } variable "postgresql_availability_no_data_timeframe" { description = "PostgreSQL availability monitor no data timeframe" - type = "string" + type = string default = 10 } @@ -89,31 +89,31 @@ variable "postgresql_connection_threshold_warning" { variable "postgresql_connection_enabled" { description = "Flag to enable PostgreSQL connection monitor" - type = "string" + type = string default = "true" } variable "postgresql_connection_extra_tags" { description = "Extra tags for PostgreSQL connection connects monitor" - type = "list" + type = list(string) default = [] } variable "postgresql_connection_message" { description = "Custom message for PostgreSQL connection monitor" - type = "string" + type = string default = "" } variable "postgresql_connection_time_aggregator" { description = "Monitor time aggregator for PostgreSQL connection monitor [available values: min, max or avg]" - type = "string" + type = string default = "avg" } variable "postgresql_connection_timeframe" { description = "Monitor timeframe for PostgreSQL connection monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_15m" } @@ -133,30 +133,31 @@ variable "postgresql_lock_threshold_warning" { variable "postgresql_lock_enabled" { description = "Flag to enable PostgreSQL lock monitor" - type = "string" + type = string default = "true" } variable "postgresql_lock_extra_tags" { description = "Extra tags for PostgreSQL lock connects monitor" - type = "list" + type = list(string) default = [] } variable "postgresql_lock_message" { description = "Custom message for PostgreSQL lock monitor" - type = "string" + type = string default = "" } variable "postgresql_lock_time_aggregator" { description = "Monitor time aggregator for PostgreSQL lock monitor [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "postgresql_lock_timeframe" { description = "Monitor timeframe for PostgreSQL lock monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } + diff --git a/database/postgresql/modules.tf b/database/postgresql/modules.tf index b18547d..4004ab7 100644 --- a/database/postgresql/modules.tf +++ b/database/postgresql/modules.tf @@ -1,9 +1,10 @@ module "filter-tags" { source = "../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "postgres" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded } + diff --git a/database/postgresql/monitors-postgresql.tf b/database/postgresql/monitors-postgresql.tf index 2612638..230a466 100644 --- a/database/postgresql/monitors-postgresql.tf +++ b/database/postgresql/monitors-postgresql.tf @@ -1,86 +1,84 @@ resource "datadog_monitor" "postgresql_availability" { - count = "${var.postgresql_availability_enabled == "true" ? 1 : 0}" + 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)}" - + message = coalesce(var.postgresql_availability_message, var.message) type = "service check" query = < ${var.postgresql_connection_threshold_critical} - EOQ +EOQ - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" +thresholds = { +warning = var.postgresql_connection_threshold_warning +critical = var.postgresql_connection_threshold_critical +} - 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 - 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}"] +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" +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 +EOQ - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" - - thresholds { - warning = "${var.postgresql_lock_threshold_warning}" - critical = "${var.postgresql_lock_threshold_critical}" - } - - 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}"] +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] +} + diff --git a/database/postgresql/outputs.tf b/database/postgresql/outputs.tf index 24c26d1..bb81f0b 100644 --- a/database/postgresql/outputs.tf +++ b/database/postgresql/outputs.tf @@ -1,14 +1,15 @@ output "postgresql_availability_id" { description = "id for monitor postgresql_availability" - value = "${datadog_monitor.postgresql_availability.*.id}" + value = datadog_monitor.postgresql_availability.*.id } output "postgresql_connection_too_high_id" { description = "id for monitor postgresql_connection_too_high" - value = "${datadog_monitor.postgresql_connection_too_high.*.id}" + value = datadog_monitor.postgresql_connection_too_high.*.id } output "postgresql_too_many_locks_id" { description = "id for monitor postgresql_too_many_locks" - value = "${datadog_monitor.postgresql_too_many_locks.*.id}" + value = datadog_monitor.postgresql_too_many_locks.*.id } + diff --git a/database/postgresql/versions.tf b/database/postgresql/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/database/postgresql/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/database/redis/inputs.tf b/database/redis/inputs.tf index 7866bec..7ecc6d9 100644 --- a/database/redis/inputs.tf +++ b/database/redis/inputs.tf @@ -1,7 +1,7 @@ # Global Terraform variable "environment" { description = "Architecture environment" - type = "string" + type = string } # Global DataDog @@ -43,31 +43,31 @@ variable "filter_tags_custom_excluded" { variable "evictedkeys_change_enabled" { description = "Flag to enable Redis evicted keys monitor" - type = "string" + type = string default = "true" } variable "evictedkeys_change_message" { description = "Custom message for Redis evicted keys monitor" - type = "string" + type = string default = "" } variable "evictedkeys_change_extra_tags" { description = "Extra tags for Redis evicted keys monitor" - type = "list" + type = list(string) default = [] } variable "evictedkeys_change_time_aggregator" { description = "Monitor aggregator for Redis evicted keys [available values: min, max or avg]" - type = "string" + type = string default = "avg" } variable "evictedkeys_change_timeframe" { description = "Monitor timeframe for Redis evicted keys [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -83,31 +83,31 @@ variable "evictedkeys_change_threshold_critical" { variable "expirations_rate_enabled" { description = "Flag to enable Redis keys expirations monitor" - type = "string" + type = string default = "true" } variable "expirations_rate_message" { description = "Custom message for Redis keys expirations monitor" - type = "string" + type = string default = "" } variable "expirations_rate_extra_tags" { description = "Extra tags for Redis keys expirations monitor" - type = "list" + type = list(string) default = [] } variable "expirations_rate_time_aggregator" { description = "Monitor aggregator for Redis keys expirations [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "expirations_rate_timeframe" { description = "Monitor timeframe for Redis keys expirations [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -123,31 +123,31 @@ variable "expirations_rate_threshold_warning" { variable "blocked_clients_enabled" { description = "Flag to enable Redis Blocked clients monitor" - type = "string" + type = string default = "true" } variable "blocked_clients_message" { description = "Custom message for Redis Blocked clients monitor" - type = "string" + type = string default = "" } variable "blocked_clients_extra_tags" { description = "Extra tags for Redis Blocked clients monitor" - type = "list" + type = list(string) default = [] } variable "blocked_clients_time_aggregator" { description = "Monitor aggregator for Redis Blocked clients [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "blocked_clients_timeframe" { description = "Monitor timeframe for Redis Blocked clients [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -163,31 +163,31 @@ variable "blocked_clients_threshold_warning" { variable "keyspace_enabled" { description = "Flag to enable Redis keyspace monitor" - type = "string" + type = string default = "true" } variable "keyspace_message" { description = "Custom message for Redis keyspace monitor" - type = "string" + type = string default = "" } variable "keyspace_extra_tags" { description = "Extra tags for Redis keyspace monitor" - type = "list" + type = list(string) default = [] } variable "keyspace_time_aggregator" { description = "Monitor aggregator for Redis keyspace [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "keyspace_timeframe" { description = "Monitor timeframe for Redis keyspace [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -203,31 +203,31 @@ variable "keyspace_threshold_warning" { variable "mem_used_enabled" { description = "Flag to enable Redis RAM memory used monitor" - type = "string" + type = string default = "true" } variable "mem_used_message" { description = "Custom message for Redis RAM memory used monitor" - type = "string" + type = string default = "" } variable "mem_used_extra_tags" { description = "Extra tags for Redis RAM memory used monitor" - type = "list" + type = list(string) default = [] } variable "mem_used_time_aggregator" { description = "Monitor aggregator for Redis RAM memory used [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "mem_used_timeframe" { description = "Monitor timeframe for Redis RAM memory used [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -243,31 +243,31 @@ variable "mem_used_threshold_warning" { variable "mem_frag_enabled" { description = "Flag to enable Redis memory RAM fragmentation monitor" - type = "string" + type = string default = "true" } variable "mem_frag_message" { description = "Custom message for Redis memory RAM fragmentation monitor" - type = "string" + type = string default = "" } variable "mem_frag_extra_tags" { description = "Extra tags for Redis memory RAM fragmentation monitor" - type = "list" + type = list(string) default = [] } variable "mem_frag_time_aggregator" { description = "Monitor aggregator for Redis memory RAM fragmentation [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "mem_frag_timeframe" { description = "Monitor timeframe for Redis memory RAM fragmentation [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -283,31 +283,31 @@ variable "mem_frag_threshold_warning" { variable "rejected_con_enabled" { description = "Flag to enable Redis rejected connections errors monitor" - type = "string" + type = string default = "true" } variable "rejected_con_message" { description = "Custom message for Redis rejected connections errors monitor" - type = "string" + type = string default = "" } variable "rejected_con_extra_tags" { description = "Extra tags for Redis rejected connections errors monitor" - type = "list" + type = list(string) default = [] } variable "rejected_con_time_aggregator" { description = "Monitor aggregator for Redis rejected connections errors [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "rejected_con_timeframe" { description = "Monitor timeframe for Redis rejected connections errors [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -323,31 +323,31 @@ variable "rejected_con_threshold_warning" { variable "latency_enabled" { description = "Flag to enable Redis latency monitor" - type = "string" + type = string default = "true" } variable "latency_message" { description = "Custom message for Redis latency monitor" - type = "string" + type = string default = "" } variable "latency_extra_tags" { description = "Extra tags for Redis latency monitor" - type = "list" + type = list(string) default = [] } variable "latency_time_aggregator" { description = "Monitor aggregator for Redis latency [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "latency_timeframe" { description = "Monitor timeframe for Redis latency [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -363,31 +363,31 @@ variable "latency_threshold_warning" { variable "hitrate_enabled" { description = "Flag to enable Redis hitrate monitor" - type = "string" + type = string default = "true" } variable "hitrate_message" { description = "Custom message for Redis hitrate monitor" - type = "string" + type = string default = "" } variable "hitrate_extra_tags" { description = "Extra tags for Redis hitrate monitor" - type = "list" + type = list(string) default = [] } variable "hitrate_time_aggregator" { description = "Monitor aggregator for Redis hitrate [available values: min, max or avg]" - type = "string" + type = string default = "max" } variable "hitrate_timeframe" { description = "Monitor timeframe for Redis hitrate [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -407,30 +407,31 @@ variable "hitrate_threshold_warning" { variable "not_responding_enabled" { description = "Flag to enable Redis does not respond monitor" - type = "string" + type = string default = "true" } variable "not_responding_message" { description = "Custom message for Redis does not respond monitor" - type = "string" + type = string default = "" } variable "not_responding_extra_tags" { description = "Extra tags for Redis does not respond monitor" - type = "list" + type = list(string) default = [] } variable "not_responding_threshold_warning" { description = "Redis does not respond monitor (warning threshold)" - type = "string" + type = string default = 3 } variable "not_responding_no_data_timeframe" { description = "Redis does not respond monitor no data timeframe" - type = "string" + type = string default = 10 } + diff --git a/database/redis/modules.tf b/database/redis/modules.tf index 5223605..f923fe0 100644 --- a/database/redis/modules.tf +++ b/database/redis/modules.tf @@ -1,9 +1,10 @@ module "filter-tags" { source = "../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "redis" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded } + diff --git a/database/redis/monitors-redis.tf b/database/redis/monitors-redis.tf index b2ce347..51568b6 100644 --- a/database/redis/monitors-redis.tf +++ b/database/redis/monitors-redis.tf @@ -2,289 +2,280 @@ # Service Check # resource "datadog_monitor" "not_responding" { - count = "${var.not_responding_enabled == "true" ? 1 : 0}" + count = var.not_responding_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Redis does not respond" - message = "${coalesce(var.not_responding_message, var.message)}" - + message = coalesce(var.not_responding_message, var.message) type = "service check" query = < ${var.evictedkeys_change_threshold_critical} - EOQ +EOQ - type = "query alert" +thresholds = { +warning = var.evictedkeys_change_threshold_warning +critical = var.evictedkeys_change_threshold_critical +} - thresholds { - warning = "${var.evictedkeys_change_threshold_warning}" - critical = "${var.evictedkeys_change_threshold_critical}" - } +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay +notify_no_data = false +renotify_interval = 0 +notify_audit = false +timeout_h = 0 +include_tags = true +locked = false +require_full_window = true - 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 = true - new_host_delay = "${var.new_host_delay}" - - tags = ["env:${var.environment}", "type:database", "provider:redisdb", "resource:redis", "team:claranet", "created-by:terraform", "${var.evictedkeys_change_extra_tags}"] +tags = ["env:${var.environment}", "type:database", "provider:redisdb", "resource:redis", "team:claranet", "created-by:terraform", var.evictedkeys_change_extra_tags] } resource "datadog_monitor" "expirations" { - count = "${var.expirations_rate_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Redis expired keys {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.expirations_rate_message, var.message)}" +count = var.expirations_rate_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Redis expired keys {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +message = coalesce(var.expirations_rate_message, var.message) +type = "query alert" - query = < ${var.expirations_rate_threshold_critical} - EOQ +EOQ - type = "query alert" +thresholds = { +warning = var.expirations_rate_threshold_warning +critical = var.expirations_rate_threshold_critical +} - thresholds { - warning = "${var.expirations_rate_threshold_warning}" - critical = "${var.expirations_rate_threshold_critical}" - } +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay +notify_no_data = false +renotify_interval = 0 +notify_audit = false +timeout_h = 0 +include_tags = true +locked = false +require_full_window = false - 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:database", "provider:redisdb", "resource:redis", "team:claranet", "created-by:terraform", "${var.expirations_rate_extra_tags}"] +tags = ["env:${var.environment}", "type:database", "provider:redisdb", "resource:redis", "team:claranet", "created-by:terraform", var.expirations_rate_extra_tags] } resource "datadog_monitor" "blocked_clients" { - count = "${var.blocked_clients_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Redis blocked clients {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.blocked_clients_message, var.message)}" +count = var.blocked_clients_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Redis blocked clients {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +message = coalesce(var.blocked_clients_message, var.message) +type = "query alert" - query = < ${var.blocked_clients_threshold_critical} - EOQ +EOQ - type = "query alert" - - thresholds { - warning = "${var.blocked_clients_threshold_warning}" - critical = "${var.blocked_clients_threshold_critical}" + thresholds = { + warning = var.blocked_clients_threshold_warning + critical = var.blocked_clients_threshold_critical } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay 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:database", "provider:redisdb", "resource:redis", "team:claranet", "created-by:terraform", "${var.blocked_clients_extra_tags}"] + tags = ["env:${var.environment}", "type:database", "provider:redisdb", "resource:redis", "team:claranet", "created-by:terraform", var.blocked_clients_extra_tags] } resource "datadog_monitor" "keyspace_full" { - count = "${var.keyspace_enabled == "true" ? 1 : 0}" + count = var.keyspace_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Redis keyspace seems full (no changes since ${var.keyspace_timeframe})" - message = "${coalesce(var.keyspace_message, var.message)}" + message = coalesce(var.keyspace_message, var.message) + type = "query alert" query = < ${var.mem_used_threshold_critical} - EOQ +EOQ - type = "query alert" +thresholds = { +warning = var.mem_used_threshold_warning +critical = var.mem_used_threshold_critical +} - thresholds { - warning = "${var.mem_used_threshold_warning}" - critical = "${var.mem_used_threshold_critical}" - } +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay +notify_no_data = false +renotify_interval = 0 +notify_audit = false +timeout_h = 0 +include_tags = true +locked = false +require_full_window = false - 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:database", "provider:redisdb", "resource:redis", "team:claranet", "created-by:terraform", "${var.mem_used_extra_tags}"] +tags = ["env:${var.environment}", "type:database", "provider:redisdb", "resource:redis", "team:claranet", "created-by:terraform", var.mem_used_extra_tags] } resource "datadog_monitor" "memory_frag" { - count = "${var.mem_frag_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Redis memory fragmented {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.mem_frag_message, var.message)}" +count = var.mem_frag_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Redis memory fragmented {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +message = coalesce(var.mem_frag_message, var.message) +type = "query alert" - query = < ${var.mem_frag_threshold_critical} - EOQ +EOQ - type = "query alert" +thresholds = { +warning = var.mem_frag_threshold_warning +critical = var.mem_frag_threshold_critical +} - thresholds { - warning = "${var.mem_frag_threshold_warning}" - critical = "${var.mem_frag_threshold_critical}" - } +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay +notify_no_data = false +renotify_interval = 0 +notify_audit = false +timeout_h = 0 +include_tags = true +locked = false +require_full_window = false - 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:database", "provider:redisdb", "resource:redis", "team:claranet", "created-by:terraform", "${var.mem_frag_extra_tags}"] +tags = ["env:${var.environment}", "type:database", "provider:redisdb", "resource:redis", "team:claranet", "created-by:terraform", var.mem_frag_extra_tags] } resource "datadog_monitor" "rejected_connections" { - count = "${var.rejected_con_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Redis rejected connections {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}" - message = "${coalesce(var.rejected_con_message, var.message)}" +count = var.rejected_con_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Redis rejected connections {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}" +message = coalesce(var.rejected_con_message, var.message) +type = "query alert" - query = < ${var.rejected_con_threshold_critical} - EOQ +EOQ - type = "query alert" - - thresholds { - warning = "${var.rejected_con_threshold_warning}" - critical = "${var.rejected_con_threshold_critical}" + thresholds = { + warning = var.rejected_con_threshold_warning + critical = var.rejected_con_threshold_critical } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay 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:database", "provider:redisdb", "resource:redis", "team:claranet", "created-by:terraform", "${var.rejected_con_extra_tags}"] + tags = ["env:${var.environment}", "type:database", "provider:redisdb", "resource:redis", "team:claranet", "created-by:terraform", var.rejected_con_extra_tags] } resource "datadog_monitor" "latency" { - count = "${var.latency_enabled == "true" ? 1 : 0}" + count = var.latency_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Redis latency {{#is_alert}}{{{comparator}}} {{threshold}}ms ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}ms ({{value}}){{/is_warning}}" - message = "${coalesce(var.latency_message, var.message)}" + message = coalesce(var.latency_message, var.message) + type = "query alert" query = < ${var.latency_threshold_critical} - EOQ +EOQ - type = "query alert" - - thresholds { - warning = "${var.latency_threshold_warning}" - critical = "${var.latency_threshold_critical}" + thresholds = { + warning = var.latency_threshold_warning + critical = var.latency_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 + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay + notify_no_data = false + 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:database", "provider:redisdb", "resource:redis", "team:claranet", "created-by:terraform", "${var.latency_extra_tags}"] + tags = ["env:${var.environment}", "type:database", "provider:redisdb", "resource:redis", "team:claranet", "created-by:terraform", var.latency_extra_tags] } resource "datadog_monitor" "hitrate" { - count = "${var.hitrate_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Redis hitrate {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.hitrate_message, var.message)}" + count = var.hitrate_enabled == "true" ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Redis hitrate {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" + message = coalesce(var.hitrate_message, var.message) + type = "query alert" query = < ${var.nginx_dropped_threshold_critical} - EOQ +EOQ - thresholds { - critical = "${var.nginx_dropped_threshold_critical}" - } - - notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" - notify_audit = false - timeout_h = 0 - include_tags = true - locked = false - require_full_window = true - - tags = ["env:${var.environment}", "type:middleware", "provider:nginx", "resource:nginx", "team:claranet", "created-by:terraform", "${var.nginx_dropped_extra_tags}"] +thresholds = { +critical = var.nginx_dropped_threshold_critical } + +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay +notify_no_data = false +notify_audit = false +timeout_h = 0 +include_tags = true +locked = false +require_full_window = true + +tags = ["env:${var.environment}", "type:middleware", "provider:nginx", "resource:nginx", "team:claranet", "created-by:terraform", var.nginx_dropped_extra_tags] +} + diff --git a/middleware/nginx/outputs.tf b/middleware/nginx/outputs.tf index 970174c..33dacc8 100644 --- a/middleware/nginx/outputs.tf +++ b/middleware/nginx/outputs.tf @@ -1,9 +1,10 @@ output "datadog_nginx_process_id" { description = "id for monitor datadog_nginx_process" - value = "${datadog_monitor.datadog_nginx_process.*.id}" + value = datadog_monitor.datadog_nginx_process.*.id } output "datadog_nginx_dropped_connections_id" { description = "id for monitor datadog_nginx_dropped_connections" - value = "${datadog_monitor.datadog_nginx_dropped_connections.*.id}" + value = datadog_monitor.datadog_nginx_dropped_connections.*.id } + diff --git a/middleware/nginx/versions.tf b/middleware/nginx/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/middleware/nginx/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/middleware/php-fpm/inputs.tf b/middleware/php-fpm/inputs.tf index 4887ecd..95ce388 100644 --- a/middleware/php-fpm/inputs.tf +++ b/middleware/php-fpm/inputs.tf @@ -1,7 +1,7 @@ # Global Terraform variable "environment" { description = "Architecture Environment" - type = "string" + type = string } # Global DataDog @@ -43,31 +43,31 @@ variable "filter_tags_custom_excluded" { variable "php_fpm_busy_enabled" { description = "Flag to enable PHP FPM busy worker monitor" - type = "string" + type = string default = "true" } variable "php_fpm_busy_extra_tags" { description = "Extra tags for PHP FPM busy worker monitor" - type = "list" + type = list(string) default = [] } variable "php_fpm_busy_message" { description = "Custom message for PHP FPM busy worker monitor" - type = "string" + type = string default = "" } variable "php_fpm_busy_time_aggregator" { description = "Monitor aggregator for PHP FPM busy worker [available values: min, max or avg]" - type = "string" + type = string default = "avg" } variable "php_fpm_busy_timeframe" { description = "Monitor timeframe for PHP FPM busy worker [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_10m" } @@ -83,30 +83,31 @@ variable "php_fpm_busy_threshold_critical" { variable "php_fpm_connect_enabled" { description = "Flag to enable PHP FPM status monitor" - type = "string" + type = string default = "true" } variable "php_fpm_connect_extra_tags" { description = "Extra tags for PHP FPM status monitor" - type = "list" + type = list(string) default = [] } variable "php_fpm_connect_message" { description = "Custom message for PHP FPM status monitor" - type = "string" + type = string default = "" } variable "php_fpm_connect_threshold_warning" { description = "PHP FPM status monitor (warning threshold)" - type = "string" + type = string default = 3 } variable "php_fpm_connect_no_data_timeframe" { description = "PHP FPM status monitor no data timeframe" - type = "string" + type = string default = 10 } + diff --git a/middleware/php-fpm/modules.tf b/middleware/php-fpm/modules.tf index 3f2f324..9d90639 100644 --- a/middleware/php-fpm/modules.tf +++ b/middleware/php-fpm/modules.tf @@ -1,9 +1,10 @@ module "filter-tags" { source = "../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "php-fpm" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded } + diff --git a/middleware/php-fpm/monitors-fpm.tf b/middleware/php-fpm/monitors-fpm.tf index 464cd5e..9f5984d 100644 --- a/middleware/php-fpm/monitors-fpm.tf +++ b/middleware/php-fpm/monitors-fpm.tf @@ -1,37 +1,35 @@ resource "datadog_monitor" "php_fpm_connect" { - count = "${var.php_fpm_connect_enabled == "true" ? 1 : 0}" + count = var.php_fpm_connect_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Php-fpm ping url does not respond" - message = "${coalesce(var.php_fpm_connect_message, var.message)}" - + message = coalesce(var.php_fpm_connect_message, var.message) type = "service check" query = < ${var.php_fpm_busy_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.php_fpm_busy_threshold_warning}" - critical = "${var.php_fpm_busy_threshold_critical}" - } - - notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" - notify_audit = false - timeout_h = 0 - include_tags = true - locked = false - require_full_window = true - - tags = ["env:${var.environment}", "type:middleware", "provider:php-fpm", "resource:php-fpm", "team:claranet", "created-by:terraform", "${var.php_fpm_busy_extra_tags}"] +thresholds = { +warning = var.php_fpm_busy_threshold_warning +critical = var.php_fpm_busy_threshold_critical } + +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay +notify_no_data = false +notify_audit = false +timeout_h = 0 +include_tags = true +locked = false +require_full_window = true + +tags = ["env:${var.environment}", "type:middleware", "provider:php-fpm", "resource:php-fpm", "team:claranet", "created-by:terraform", var.php_fpm_busy_extra_tags] +} + diff --git a/middleware/php-fpm/outputs.tf b/middleware/php-fpm/outputs.tf index 5aa48d2..1d7408a 100644 --- a/middleware/php-fpm/outputs.tf +++ b/middleware/php-fpm/outputs.tf @@ -1,9 +1,10 @@ output "php_fpm_connect_id" { description = "id for monitor php_fpm_connect" - value = "${datadog_monitor.php_fpm_connect.*.id}" + value = datadog_monitor.php_fpm_connect.*.id } output "php_fpm_connect_idle_id" { description = "id for monitor php_fpm_connect_idle" - value = "${datadog_monitor.php_fpm_connect_idle.*.id}" + value = datadog_monitor.php_fpm_connect_idle.*.id } + diff --git a/middleware/php-fpm/versions.tf b/middleware/php-fpm/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/middleware/php-fpm/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/system/generic/inputs.tf b/system/generic/inputs.tf index 0b0b52a..49c0c39 100644 --- a/system/generic/inputs.tf +++ b/system/generic/inputs.tf @@ -1,7 +1,7 @@ # Global Terraform variable "environment" { description = "Architecture Environment" - type = "string" + type = string } # Global DataDog @@ -43,31 +43,31 @@ variable "filter_tags_custom_excluded" { variable "cpu_enabled" { description = "Flag to enable CPU high monitor" - type = "string" + type = string default = "true" } variable "cpu_extra_tags" { description = "Extra tags for CPU high monitor" - type = "list" + type = list(string) default = [] } variable "cpu_message" { description = "Custom message for CPU high monitor" - type = "string" + type = string default = "" } variable "cpu_time_aggregator" { description = "Monitor aggregator for CPU high [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "cpu_timeframe" { description = "Monitor timeframe for CPU high [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_10m" } @@ -83,31 +83,31 @@ variable "cpu_threshold_critical" { variable "load_enabled" { description = "Flag to enable CPU load ratio monitor" - type = "string" + type = string default = "true" } variable "load_extra_tags" { description = "Extra tags for CPU load ratio monitor" - type = "list" + type = list(string) default = [] } variable "load_message" { description = "Custom message for CPU load ratio monitor" - type = "string" + type = string default = "" } variable "load_time_aggregator" { description = "Monitor aggregator for CPU load ratio [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "load_timeframe" { description = "Monitor timeframe for CPU load ratio [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_15m" } @@ -123,31 +123,31 @@ variable "load_threshold_critical" { variable "disk_space_enabled" { description = "Flag to enable Free diskspace monitor" - type = "string" + type = string default = "true" } variable "disk_space_extra_tags" { description = "Extra tags for Free diskspace monitor" - type = "list" + type = list(string) default = [] } variable "disk_space_message" { description = "Custom message for Free diskspace monitor" - type = "string" + type = string default = "" } variable "disk_space_time_aggregator" { description = "Monitor aggregator for Free diskspace [available values: min, max or avg]" - type = "string" + type = string default = "max" } variable "disk_space_timeframe" { description = "Monitor timeframe for Free diskspace [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -163,67 +163,67 @@ variable "disk_space_threshold_critical" { variable "disk_space_forecast_enabled" { description = "Flag to enable Free diskspace forecast monitor" - type = "string" + type = string default = "true" } variable "disk_space_forecast_extra_tags" { description = "Extra tags for Free diskspace forecast monitor" - type = "list" + type = list(string) default = [] } variable "disk_space_forecast_message" { description = "Custom message for Free diskspace forecast monitor" - type = "string" + type = string default = "" } variable "disk_space_forecast_time_aggregator" { description = "Monitor aggregator for Free diskspace forecast [available values: min, max or avg]" - type = "string" + type = string default = "max" } variable "disk_space_forecast_timeframe" { description = "Monitor timeframe for Free diskspace forecast [available values: `next_12h`, `next_#d` (1, 2, or 3), `next_#w` (1 or 2) or `next_#mo` (1, 2 or 3)]" - type = "string" + type = string default = "next_1w" } variable "disk_space_forecast_algorithm" { description = "Algorithm for the Free diskspace Forecast monitor [available values: `linear` or `seasonal`]" - type = "string" + type = string default = "linear" } variable "disk_space_forecast_deviations" { description = "Deviations for the Free diskspace Forecast monitor [available values: `1`, `2`, `3`, `4` or `5`]" - type = "string" + type = string default = 1 } variable "disk_space_forecast_interval" { description = "Interval for the Free diskspace Forecast monitor [available values: `30m`, `60m` or `120m`]" - type = "string" + type = string default = "60m" } variable "disk_space_forecast_linear_history" { description = "History for the Free diskspace Forecast monitor [available values: `12h`, `#d` (1, 2, or 3), `#w` (1, or 2) or `#mo` (1, 2 or 3)]" - type = "string" + type = string default = "1w" } variable "disk_space_forecast_linear_model" { description = "Model for the Free diskspace Forecast monitor [available values: `default`, `simple` or `reactive`]" - type = "string" + type = string default = "default" } variable "disk_space_forecast_seasonal_seasonality" { description = "Seasonality for the Free diskspace Forecast monitor" - type = "string" + type = string default = "weekly" } @@ -239,31 +239,31 @@ variable "disk_space_forecast_threshold_critical" { variable "disk_inodes_enabled" { description = "Flag to enable Free disk inodes monitor" - type = "string" + type = string default = "true" } variable "disk_inodes_extra_tags" { description = "Extra tags for Free disk inodes monitor" - type = "list" + type = list(string) default = [] } variable "disk_inodes_message" { description = "Custom message for Free disk inodes monitor" - type = "string" + type = string default = "" } variable "disk_inodes_time_aggregator" { description = "Monitor aggregator for Free disk inodes [available values: min, max or avg]" - type = "string" + type = string default = "min" } variable "disk_inodes_timeframe" { description = "Monitor timeframe for Free disk inodes [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -279,30 +279,30 @@ variable "disk_inodes_threshold_critical" { variable "memory_enabled" { description = "Flag to enable Free memory monitor" - type = "string" + type = string default = "true" } variable "memory_extra_tags" { description = "Extra tags for Free memory monitor" - type = "list" + type = list(string) default = [] } variable "memory_message" { description = "Mandatory message for Free memory monitor to avoid NBH alerting by default" - type = "string" + type = string } variable "memory_time_aggregator" { description = "Monitor aggregator for Free memory [available values: min, max or avg]" - type = "string" + type = string default = "max" } variable "memory_timeframe" { description = "Monitor timeframe for Free memory [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" - type = "string" + type = string default = "last_5m" } @@ -315,3 +315,4 @@ variable "memory_threshold_critical" { description = "Free disk space critical threshold" default = 5 } + diff --git a/system/generic/modules.tf b/system/generic/modules.tf index fe7a5d1..fc2e056 100644 --- a/system/generic/modules.tf +++ b/system/generic/modules.tf @@ -1,20 +1,21 @@ module "filter-tags" { source = "../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "system" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded } module "filter-tags-disk" { source = "../../common/filter-tags" - environment = "${var.environment}" + environment = var.environment resource = "system" - filter_tags_use_defaults = "${var.filter_tags_use_defaults}" - filter_tags_custom = "${var.filter_tags_custom}" - filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded extra_tags = ["dd_disk:enabled"] } + diff --git a/system/generic/monitors-system.tf b/system/generic/monitors-system.tf index b6dfb90..860db6e 100644 --- a/system/generic/monitors-system.tf +++ b/system/generic/monitors-system.tf @@ -1,117 +1,122 @@ resource "datadog_monitor" "cpu" { - count = "${var.cpu_enabled == "true" ? 1 : 0}" + count = var.cpu_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] CPU usage {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.cpu_message, var.message)}" + message = coalesce(var.cpu_message, var.message) + type = "query alert" query = < ${var.cpu_threshold_critical} - EOQ +EOQ - type = "query alert" - - thresholds { - warning = "${var.cpu_threshold_warning}" - critical = "${var.cpu_threshold_critical}" + thresholds = { + warning = var.cpu_threshold_warning + critical = var.cpu_threshold_critical } - notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" - notify_audit = false - timeout_h = 0 - include_tags = true - locked = false + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay + notify_no_data = false + notify_audit = false + timeout_h = 0 + include_tags = true + locked = false require_full_window = true - tags = ["env:${var.environment}", "type:system", "provider:system-check", "resource:generic", "team:claranet", "created-by:terraform", "${var.cpu_extra_tags}"] + tags = ["env:${var.environment}", "type:system", "provider:system-check", "resource:generic", "team:claranet", "created-by:terraform", var.cpu_extra_tags] } resource "datadog_monitor" "load" { - count = "${var.load_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] CPU load 5 ratio {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}" - message = "${coalesce(var.load_message, var.message)}" + count = var.load_enabled == "true" ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] CPU load 5 ratio {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}" + message = coalesce(var.load_message, var.message) + type = "query alert" query = < ${var.load_threshold_critical} - EOQ +EOQ - type = "query alert" +thresholds = { +warning = var.load_threshold_warning +critical = var.load_threshold_critical +} - thresholds { - warning = "${var.load_threshold_warning}" - critical = "${var.load_threshold_critical}" - } +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay +notify_no_data = false +notify_audit = false +timeout_h = 0 +include_tags = true +locked = false +require_full_window = true - notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" - notify_audit = false - timeout_h = 0 - include_tags = true - locked = false - require_full_window = true - - tags = ["env:${var.environment}", "type:system", "provider:system-core", "resource:generic", "team:claranet", "created-by:terraform", "${var.load_extra_tags}"] +tags = ["env:${var.environment}", "type:system", "provider:system-core", "resource:generic", "team:claranet", "created-by:terraform", var.load_extra_tags] } resource "datadog_monitor" "disk_space" { - count = "${var.disk_space_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Disk space usage {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.disk_space_message, var.message)}" +count = var.disk_space_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Disk space usage {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" +message = coalesce(var.disk_space_message, var.message) +type = "query alert" - query = < ${var.disk_space_threshold_critical} - EOQ +EOQ - type = "query alert" +thresholds = { +warning = var.disk_space_threshold_warning +critical = var.disk_space_threshold_critical +} - thresholds { - warning = "${var.disk_space_threshold_warning}" - critical = "${var.disk_space_threshold_critical}" - } +evaluation_delay = var.evaluation_delay +new_host_delay = var.new_host_delay +notify_no_data = false +notify_audit = false +timeout_h = 0 +include_tags = true +locked = false +require_full_window = true - notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" - notify_audit = false - timeout_h = 0 - include_tags = true - locked = false - require_full_window = true - - tags = ["env:${var.environment}", "type:system", "provider:disk", "resource:generic", "team:claranet", "created-by:terraform", "${var.disk_space_extra_tags}"] +tags = ["env:${var.environment}", "type:system", "provider:disk", "resource:generic", "team:claranet", "created-by:terraform", var.disk_space_extra_tags] } resource "datadog_monitor" "disk_space_forecast" { - count = "${var.disk_space_forecast_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Disk Space usage could reach {{#is_alert}}{{threshold}}%{{/is_alert}} in a near future" - message = "${coalesce(var.disk_space_forecast_message, var.message)}" +count = var.disk_space_forecast_enabled == "true" ? 1 : 0 +name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Disk Space usage could reach {{#is_alert}}{{threshold}}%%{{/is_alert}} in a near future" +message = coalesce(var.disk_space_forecast_message, var.message) +type = "query alert" - query = <= ${var.disk_space_forecast_threshold_critical} - EOQ +EOQ - type = "query alert" - - thresholds { - critical_recovery = "${var.disk_space_forecast_threshold_critical_recovery}" - critical = "${var.disk_space_forecast_threshold_critical}" + thresholds = { + critical_recovery = var.disk_space_forecast_threshold_critical_recovery + critical = var.disk_space_forecast_threshold_critical } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay notify_audit = false locked = false timeout_h = 0 @@ -120,70 +125,66 @@ resource "datadog_monitor" "disk_space_forecast" { notify_no_data = false renotify_interval = 0 - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" - - tags = ["env:${var.environment}", "type:system", "provider:disk", "resource:generic", "team:claranet", "created-by:terraform", "${var.disk_space_forecast_extra_tags}"] + tags = ["env:${var.environment}", "type:system", "provider:disk", "resource:generic", "team:claranet", "created-by:terraform", var.disk_space_forecast_extra_tags] } resource "datadog_monitor" "disk_inodes" { - count = "${var.disk_inodes_enabled == "true" ? 1 : 0}" + count = var.disk_inodes_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Disk inodes usage {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${coalesce(var.disk_inodes_message, var.message)}" + message = coalesce(var.disk_inodes_message, var.message) + type = "query alert" query = < ${var.disk_inodes_threshold_critical} - EOQ +EOQ - type = "query alert" - - thresholds { - warning = "${var.disk_inodes_threshold_warning}" - critical = "${var.disk_inodes_threshold_critical}" + thresholds = { + warning = var.disk_inodes_threshold_warning + critical = var.disk_inodes_threshold_critical } - notify_no_data = false - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" - notify_audit = false - timeout_h = 0 - include_tags = true - locked = false + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay + notify_no_data = false + notify_audit = false + timeout_h = 0 + include_tags = true + locked = false require_full_window = true - tags = ["env:${var.environment}", "type:system", "provider:disk", "resource:generic", "team:claranet", "created-by:terraform", "${var.disk_inodes_extra_tags}"] + tags = ["env:${var.environment}", "type:system", "provider:disk", "resource:generic", "team:claranet", "created-by:terraform", var.disk_inodes_extra_tags] } resource "datadog_monitor" "memory" { - count = "${var.memory_enabled == "true" ? 1 : 0}" - name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Usable Memory {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" - message = "${var.memory_message}" + count = var.memory_enabled == "true" ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Usable Memory {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" + message = var.memory_message + type = "query alert" query = <