diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4ec2c9c..a9a7e8b 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.3 stage: test script: - apk add --no-cache bash git grep coreutils diff --git a/README.md b/README.md index 0aa27ee..acab7c5 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,7 @@ This repository is used to store all our monitors templates ready to use for generic purpose. - -### How to contribute ? ### +## How to contribute ? ## First, you may refresh your knowledge and look at the [terminology](https://confluence.fr.clara.net/display/DAT/Getting+started). @@ -13,7 +12,7 @@ If you would like to resolve an issue or implement new monitors you must follow After any change you should run `./scripts/auto_update.sh ./` command to make sure all is up to date else the CI pipeline will fail on the branch. -### Important notes ### +## Important notes ## * This repository represents a terraform feature and each first level directory could be imported as a terraform module, you must choose the one(s) you need. * Each of these modules contains the most commons monitors, but they probably do not fulfill all your customer needs @@ -21,54 +20,107 @@ After any change you should run `./scripts/auto_update.sh ./` command to make su * You will find a complete `README.md` on each module, explaining how to use it. * The `alerting-message` module could be used to easily generate a templating message to use by default but it could be used also multiple times to generate messages for specific monitors. -### The DataDog provider ### +## Getting started ## -Before importing some modules, you must define the DataDog provider in your `main.tf` +### Terraform ### + +Version >= 0.12 is required to use these modules of monitors. + +``` +terraform { + required_version = "~> 0.12" +} + +``` + +### DataDog provider ### + +Here is the last tester terraform provider version for datadog but next versions should work too. ``` provider "datadog" { - version = "2.0.2" + version = "2.0.2" # last tested working version - api_key = "${var.datadog_api_key}" - app_key = "${var.datadog_app_key}" + api_key = var.datadog_api_key + app_key = var.datadog_app_key } + ``` -Both of the `datadog_api_key` and `datadog_app_key` are unique to the client. - -### Module declaration example ### - -A quick example of using a set of monitors for a given terraform module: +Both of the `datadog_api_key` and `datadog_app_key` are unique to the each datadog account. You can define them in `terraform.tfvars` file: ``` -variable "oncall_24x7" { - default = "@pagerduty-Public_Cloud_FR_-_Yoda_-_Unibail_HNO" +datadog_api_key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +datadog_app_key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +``` + +### Variables ### + +Some variables need to be declared. + +``` +variable "environment" { + type = string + default = "dev" } -variable "oncall_office_hours" { - default = "@pagerduty-Public_Cloud_FR_-_Yoda_-_Unibail_HO" +variable "datadog_api_key" { + type = string } -variable "oncall_nodata" { - default = "@pagerduty-Public_Cloud_FR_-_Yoda_-_Unibail_HNO" +variable "datadog_app_key" { + type = string +} + +``` + +## Modules declaration example ## + +A quick example of alerting message module declaration: + +``` +locals { + oncall_24x7 = "@pagerduty-MyPagerService_NBH" + oncall_office_hours = "@pagerduty-MyPagerService_BH" } module "datadog-message-alerting" { - source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//common/alerting-message" + source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//common/alerting-message?ref={RELEASE}" - message_alert = "${var.oncall_24x7}" - message_warning = "${var.oncall_office_hours}" - message_nodata = "${var.oncall_nodata}" + message_alert = local.oncall_24x7 + message_warning = local.oncall_office_hours + message_nodata = local.oncall_24x7 } -module "datadog-monitors-my-monitors-set" { - source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//my/monitors/set?ref={revision}" +module "datadog-message-alerting-bh-only" { + source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//common/alerting-message?ref={RELEASE}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + message_alert = local.oncall_office_hours + message_warning = local.oncall_office_hours + message_nodata = local.oncall_office_hours } + +module "datadog-monitors-system-generic" { + source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//system/generic?ref={RELEASE}" + + environment = var.environment + message = module.datadog-message-alerting.alerting-message + + memory_message = module.datadog-message-alerting-bh-only.alerting-message + # Use variables to customize monitors configuration +} + +# Other monitors modules to declare ... +#module "datadog-monitors-my-monitors-set" { +# source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//my/monitors/set?ref={RELEASE}" +# +# environment = var.environment +# message = module.datadog-message-alerting.alerting-message +#} + ``` +Replace `{revision}` to the last git tag available on this repository. The `//` is very important, it's a terraform specific syntax used to separate git url and folder path. `my/monitors/set` represents the path to a monitors set sub directory listed below. diff --git a/caas/kubernetes/ark/README.md b/caas/kubernetes/ark/README.md index 1950b0c..1d3d142 100644 --- a/caas/kubernetes/ark/README.md +++ b/caas/kubernetes/ark/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-caas-kubernetes-ark" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//caas/kubernetes/ark?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -23,7 +23,7 @@ Creates DataDog monitors with the following checks: | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| | ark\_schedules\_enabled | Flag to enable Ark schedules monitor | string | `"true"` | no | -| ark\_schedules\_extra\_tags | Extra tags for Ark schedules monitor | list | `[]` | no | +| ark\_schedules\_extra\_tags | Extra tags for Ark schedules monitor | list(string) | `[]` | no | | ark\_schedules\_monitor\_message | Custom message for Ark schedules monitor | string | `""` | no | | ark\_schedules\_monitor\_no\_data\_timeframe | No data timeframe in minutes | string | `"1440"` | no | | ark\_schedules\_monitor\_timeframe | 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`] | string | `"last_1d"` | no | 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..1e91228 100644 --- a/caas/kubernetes/ark/monitors-ark.tf +++ b/caas/kubernetes/ark/monitors-ark.tf @@ -1,21 +1,21 @@ 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 } - 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 @@ -25,5 +25,6 @@ resource "datadog_monitor" "ark_schedules_monitor" { 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 = concat(["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/cluster/README.md b/caas/kubernetes/cluster/README.md index 21c1dc4..2a41621 100644 --- a/caas/kubernetes/cluster/README.md +++ b/caas/kubernetes/cluster/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-caas-kubernetes-cluster" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//caas/kubernetes/cluster?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -23,7 +23,7 @@ Creates DataDog monitors with the following checks: | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| | apiserver\_enabled | Flag to enable API server monitor | string | `"true"` | no | -| apiserver\_extra\_tags | Extra tags for API server monitor | list | `[]` | no | +| apiserver\_extra\_tags | Extra tags for API server monitor | list(string) | `[]` | no | | apiserver\_message | Custom message for API server monitor | string | `""` | no | | apiserver\_threshold\_warning | API server monitor (warning threshold) | string | `"3"` | no | | environment | Architecture environment | string | n/a | yes | 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..f6f9406 100644 --- a/caas/kubernetes/cluster/monitors-k8s-cluster.tf +++ b/caas/kubernetes/cluster/monitors-k8s-cluster.tf @@ -1,20 +1,20 @@ 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 } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay 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 @@ -27,31 +26,30 @@ resource "datadog_monitor" "nginx_ingress_too_many_5xx" { 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 = concat(["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}" + 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)}" + message = coalesce(var.ingress_4xx_message, var.message) + type = "query alert" query = < ${var.ingress_4xx_threshold_critical} - EOQ +EOQ - type = "query alert" - - thresholds { - warning = "${var.ingress_4xx_threshold_warning}" - critical = "${var.ingress_4xx_threshold_critical}" + thresholds = { + warning = var.ingress_4xx_threshold_warning + critical = var.ingress_4xx_threshold_critical } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay 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 @@ -59,5 +57,6 @@ resource "datadog_monitor" "nginx_ingress_too_many_4xx" { 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}"] + tags = concat(["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/node/README.md b/caas/kubernetes/node/README.md index 01e8d2a..d310f53 100644 --- a/caas/kubernetes/node/README.md +++ b/caas/kubernetes/node/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-caas-kubernetes-node" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//caas/kubernetes/node?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -32,11 +32,11 @@ Creates DataDog monitors with the following checks: | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| | disk\_out\_enabled | Flag to enable Out of disk monitor | string | `"true"` | no | -| disk\_out\_extra\_tags | Extra tags for Out of disk monitor | list | `[]` | no | +| disk\_out\_extra\_tags | Extra tags for Out of disk monitor | list(string) | `[]` | no | | disk\_out\_message | Custom message for Out of disk monitor | string | `""` | no | | disk\_out\_threshold\_warning | Out of disk monitor (warning threshold) | string | `"3"` | no | | disk\_pressure\_enabled | Flag to enable Disk pressure monitor | string | `"true"` | no | -| disk\_pressure\_extra\_tags | Extra tags for Disk pressure monitor | list | `[]` | no | +| disk\_pressure\_extra\_tags | Extra tags for Disk pressure monitor | list(string) | `[]` | no | | disk\_pressure\_message | Custom message for Disk pressure monitor | string | `""` | no | | disk\_pressure\_threshold\_warning | Disk pressure monitor (warning threshold) | string | `"3"` | no | | environment | Architecture environment | string | n/a | yes | @@ -45,44 +45,44 @@ Creates DataDog monitors with the following checks: | filter\_tags\_custom\_excluded | Tags excluded for custom filtering when filter_tags_use_defaults is false | string | `""` | no | | filter\_tags\_use\_defaults | Use default filter tags convention | string | `"true"` | no | | kubelet\_ping\_enabled | Flag to enable Kubelet ping monitor | string | `"true"` | no | -| kubelet\_ping\_extra\_tags | Extra tags for Kubelet ping monitor | list | `[]` | no | +| kubelet\_ping\_extra\_tags | Extra tags for Kubelet ping monitor | list(string) | `[]` | no | | kubelet\_ping\_message | Custom message for Kubelet ping monitor | string | `""` | no | | kubelet\_ping\_threshold\_warning | Kubelet ping monitor (warning threshold) | string | `"3"` | no | | kubelet\_syncloop\_enabled | Flag to enable Kubelet sync loop monitor | string | `"true"` | no | -| kubelet\_syncloop\_extra\_tags | Extra tags for Kubelet sync loop monitor | list | `[]` | no | +| kubelet\_syncloop\_extra\_tags | Extra tags for Kubelet sync loop monitor | list(string) | `[]` | no | | kubelet\_syncloop\_message | Custom message for Kubelet sync loop monitor | string | `""` | no | | kubelet\_syncloop\_threshold\_warning | Kubelet sync loop monitor (warning threshold) | string | `"3"` | no | | memory\_pressure\_enabled | Flag to enable Memory pressure monitor | string | `"true"` | no | -| memory\_pressure\_extra\_tags | Extra tags for Memory pressure monitor | list | `[]` | no | +| memory\_pressure\_extra\_tags | Extra tags for Memory pressure monitor | list(string) | `[]` | no | | memory\_pressure\_message | Custom message for Memory pressure monitor | string | `""` | no | | memory\_pressure\_threshold\_warning | Memory pressure monitor (warning threshold) | string | `"3"` | no | | message | Message sent when a monitor is triggered | string | n/a | yes | | new\_host\_delay | Delay in seconds before monitor new resource | string | `"300"` | no | | node\_unschedulable\_enabled | Flag to enable node unschedulable monitor | string | `"true"` | no | -| node\_unschedulable\_extra\_tags | Extra tags for node unschedulable monitor | list | `[]` | no | +| node\_unschedulable\_extra\_tags | Extra tags for node unschedulable monitor | list(string) | `[]` | no | | node\_unschedulable\_message | Custom message for node unschedulable monitor | string | `""` | no | | node\_unschedulable\_time\_aggregator | Monitor aggregator for node unschedulable [available values: min, max or avg] | string | `"min"` | no | | node\_unschedulable\_timeframe | Monitor timeframe for node unschedulable [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_1h"` | no | | prefix\_slug | Prefix string to prepend between brackets on every monitors names | string | `""` | no | | ready\_enabled | Flag to enable Node ready monitor | string | `"true"` | no | -| ready\_extra\_tags | Extra tags for Node ready monitor | list | `[]` | no | +| ready\_extra\_tags | Extra tags for Node ready monitor | list(string) | `[]` | no | | ready\_message | Custom message for Node ready monitor | string | `""` | no | | ready\_threshold\_warning | Node ready monitor (warning threshold) | string | `"3"` | no | | unregister\_net\_device\_enabled | Flag to enable Unregister net device monitor | string | `"true"` | no | -| unregister\_net\_device\_extra\_tags | Extra tags for Unregister net device monitor | list | `[]` | no | +| unregister\_net\_device\_extra\_tags | Extra tags for Unregister net device monitor | list(string) | `[]` | no | | unregister\_net\_device\_message | Custom message for Unregister net device monitor | string | `""` | no | | unregister\_net\_device\_threshold\_critical | Unregister net device critical threshold | string | `"3"` | no | | unregister\_net\_device\_time\_aggregator | Monitor aggregator for Unregister net device [available values: min, max or avg] | string | `"min"` | no | | unregister\_net\_device\_timeframe | 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`] | string | `"15m"` | no | | volume\_inodes\_enabled | Flag to enable Volume inodes monitor | string | `"true"` | no | -| volume\_inodes\_extra\_tags | Extra tags for Volume inodes monitor | list | `[]` | no | +| volume\_inodes\_extra\_tags | Extra tags for Volume inodes monitor | list(string) | `[]` | no | | volume\_inodes\_message | Custom message for Volume inodes monitor | string | `""` | no | | volume\_inodes\_threshold\_critical | Volume inodes critical threshold | string | `"95"` | no | | volume\_inodes\_threshold\_warning | Volume inodes warning threshold | string | `"90"` | no | | volume\_inodes\_time\_aggregator | Monitor aggregator for Volume inodes [available values: min, max or avg] | string | `"min"` | no | | volume\_inodes\_timeframe | Monitor timeframe for Volume inodes [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_5m"` | no | | volume\_space\_enabled | Flag to enable Volume space monitor | string | `"true"` | no | -| volume\_space\_extra\_tags | Extra tags for Volume space monitor | list | `[]` | no | +| volume\_space\_extra\_tags | Extra tags for Volume space monitor | list(string) | `[]` | no | | volume\_space\_message | Custom message for Volume space monitor | string | `""` | no | | volume\_space\_threshold\_critical | Volume space critical threshold | string | `"95"` | no | | volume\_space\_threshold\_warning | Volume space warning threshold | string | `"90"` | no | 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..b60f729 100644 --- a/caas/kubernetes/node/monitors-k8s-node.tf +++ b/caas/kubernetes/node/monitors-k8s-node.tf @@ -1,20 +1,19 @@ 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)}" - - type = "service check" + message = coalesce(var.disk_pressure_message, var.message) + type = "service check" query = < ${var.unregister_net_device_threshold_critical} - EOQ - - new_host_delay = "${var.new_host_delay}" +EOQ + new_host_delay = var.new_host_delay notify_no_data = false renotify_interval = 0 notify_audit = false @@ -185,28 +178,27 @@ resource "datadog_monitor" "unregister_net_device" { 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 = concat(["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}" + count = var.node_unschedulable_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Kubernetes Node unschedulable" + message = coalesce(var.node_unschedulable_message, var.message) 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 notify_audit = false @@ -215,30 +207,29 @@ 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 = concat(["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}}" + message = coalesce(var.volume_space_message, var.message) type = "query alert" - 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 @@ -247,30 +238,29 @@ resource "datadog_monitor" "volume_space" { 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 = concat(["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}" + 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}}" + message = coalesce(var.volume_inodes_message, var.message) type = "query alert" - 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}" + 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}" - + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay notify_no_data = false renotify_interval = 0 notify_audit = false @@ -279,5 +269,6 @@ resource "datadog_monitor" "volume_inodes" { 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}"] + tags = concat(["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/pod/README.md b/caas/kubernetes/pod/README.md index 91c7366..1dbae32 100644 --- a/caas/kubernetes/pod/README.md +++ b/caas/kubernetes/pod/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-caas-kubernetes-pod" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//caas/kubernetes/pod?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -25,7 +25,7 @@ Creates DataDog monitors with the following checks: |------|-------------|:----:|:-----:|:-----:| | environment | Architecture environment | string | n/a | yes | | error\_enabled | Flag to enable Pod errors monitor | string | `"true"` | no | -| error\_extra\_tags | Extra tags for Pod errors monitor | list | `[]` | no | +| error\_extra\_tags | Extra tags for Pod errors monitor | list(string) | `[]` | no | | error\_message | Custom message for Pod errors monitor | string | `""` | no | | error\_threshold\_critical | error critical threshold | string | `"0.5"` | no | | error\_threshold\_warning | error warning threshold | string | `"0"` | no | @@ -38,7 +38,7 @@ Creates DataDog monitors with the following checks: | message | Message sent when a monitor is triggered | string | n/a | yes | | new\_host\_delay | Delay in seconds before monitor new resource | string | `"300"` | no | | pod\_phase\_status\_enabled | Flag to enable Pod phase status monitor | string | `"true"` | no | -| pod\_phase\_status\_extra\_tags | Extra tags for Pod phase status monitor | list | `[]` | no | +| pod\_phase\_status\_extra\_tags | Extra tags for Pod phase status monitor | list(string) | `[]` | no | | pod\_phase\_status\_message | Custom message for Pod phase status monitor | string | `""` | no | | pod\_phase\_status\_time\_aggregator | Monitor aggregator for Pod phase status [available values: min, max or avg] | string | `"max"` | no | | pod\_phase\_status\_timeframe | 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`] | string | `"last_5m"` | no | 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..ab5154c 100644 --- a/caas/kubernetes/pod/monitors-k8s-pod.tf +++ b/caas/kubernetes/pod/monitors-k8s-pod.tf @@ -1,20 +1,20 @@ 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" + message = coalesce(var.pod_phase_status_message, var.message) type = "metric alert" - 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 @@ -24,29 +24,28 @@ resource "datadog_monitor" "pod_phase_status" { 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 = concat(["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}" + count = var.error_enabled == "true" ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Kubernetes Pod waiting errors" + message = coalesce(var.error_message, var.message) type = "query alert" - 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}" + thresholds = { + critical = var.error_threshold_critical + warning = var.error_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 @@ -55,5 +54,6 @@ resource "datadog_monitor" "error" { 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}"] + tags = concat(["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/workload/README.md b/caas/kubernetes/workload/README.md index f377c9e..09c8b0a 100644 --- a/caas/kubernetes/workload/README.md +++ b/caas/kubernetes/workload/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-caas-kubernetes-workload" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//caas/kubernetes/workload?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -27,7 +27,7 @@ Creates DataDog monitors with the following checks: | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| | cronjob\_enabled | Flag to enable Cronjob monitor | string | `"true"` | no | -| cronjob\_extra\_tags | Extra tags for Cronjob monitor | list | `[]` | no | +| cronjob\_extra\_tags | Extra tags for Cronjob monitor | list(string) | `[]` | no | | cronjob\_message | Custom message for Cronjob monitor | string | `""` | no | | cronjob\_threshold\_warning | Cronjob monitor (warning threshold) | string | `"3"` | no | | environment | Architecture environment | string | n/a | yes | @@ -36,26 +36,26 @@ Creates DataDog monitors with the following checks: | filter\_tags\_custom\_excluded | Tags excluded for custom filtering when filter_tags_use_defaults is false | string | `""` | no | | filter\_tags\_use\_defaults | Use default filter tags convention | string | `"true"` | no | | job\_enabled | Flag to enable Job monitor | string | `"true"` | no | -| job\_extra\_tags | Extra tags for Job monitor | list | `[]` | no | +| job\_extra\_tags | Extra tags for Job monitor | list(string) | `[]` | no | | job\_message | Custom message for Job monitor | string | `""` | no | | job\_threshold\_warning | Job monitor (warning threshold) | string | `"3"` | no | | message | Message sent when a monitor is triggered | string | n/a | yes | | new\_host\_delay | Delay in seconds before monitor new resource | string | `"300"` | no | | prefix\_slug | Prefix string to prepend between brackets on every monitors names | string | `""` | no | | replica\_available\_enabled | Flag to enable Available replica monitor | string | `"true"` | no | -| replica\_available\_extra\_tags | Extra tags for Available replicamonitor | list | `[]` | no | +| replica\_available\_extra\_tags | Extra tags for Available replicamonitor | list(string) | `[]` | no | | replica\_available\_message | Custom message for Available replica monitor | string | `""` | no | | replica\_available\_threshold\_critical | Available replica critical threshold | string | `"1"` | no | | replica\_available\_time\_aggregator | Monitor aggregator for Available replica [available values: min, max or avg] | string | `"max"` | no | | replica\_available\_timeframe | Monitor timeframe for Available replica [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_15m"` | no | | replica\_current\_enabled | Flag to enable Current replica monitor | string | `"true"` | no | -| replica\_current\_extra\_tags | Extra tags for Current replica monitor | list | `[]` | no | +| replica\_current\_extra\_tags | Extra tags for Current replica monitor | list(string) | `[]` | no | | replica\_current\_message | Custom message for Current replica monitor | string | `""` | no | | replica\_current\_threshold\_critical | Current replica critical threshold | string | `"1"` | no | | replica\_current\_time\_aggregator | Monitor aggregator for Current replica [available values: min, max or avg] | string | `"max"` | no | | replica\_current\_timeframe | Monitor timeframe for Current replica [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_15m"` | no | | replica\_ready\_enabled | Flag to enable Ready replica monitor | string | `"true"` | no | -| replica\_ready\_extra\_tags | Extra tags for Ready replica monitor | list | `[]` | no | +| replica\_ready\_extra\_tags | Extra tags for Ready replica monitor | list(string) | `[]` | no | | replica\_ready\_message | Custom message for Ready replica monitor | string | `""` | no | | replica\_ready\_threshold\_critical | Ready replica critical threshold | string | `"1"` | no | | replica\_ready\_time\_aggregator | Monitor aggregator for Ready replica [available values: min, max or avg] | string | `"max"` | no | 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..60308b8 100644 --- a/caas/kubernetes/workload/monitors-k8s-workload.tf +++ b/caas/kubernetes/workload/monitors-k8s-workload.tf @@ -1,20 +1,19 @@ 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)}" - - type = "service check" + 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 - tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:alb", "team:claranet", "created-by:terraform", "${var.latency_extra_tags}"] + tags = concat(["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}" + 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 - tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:alb", "team:claranet", "created-by:terraform", "${var.httpcode_alb_5xx_extra_tags}"] + tags = concat(["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}" + 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 = concat(["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 } + 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}"] + tags = concat(["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}" + 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}" + 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}"] + tags = concat(["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/apigateway/README.md b/cloud/aws/apigateway/README.md index 1a0206b..9da0102 100644 --- a/cloud/aws/apigateway/README.md +++ b/cloud/aws/apigateway/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-cloud-aws-apigateway" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//cloud/aws/apigateway?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -29,21 +29,21 @@ Creates DataDog monitors with the following checks: | evaluation\_delay | Delay in seconds for the metric evaluation | string | `"900"` | no | | filter\_tags | Tags used for filtering | string | `"*"` | no | | http\_4xx\_requests\_enabled | Flag to enable API Gateway HTTP 4xx requests monitor | string | `"true"` | no | -| http\_4xx\_requests\_extra\_tags | Extra tags for API Gateway HTTP 4xx requests monitor | list | `[]` | no | +| http\_4xx\_requests\_extra\_tags | Extra tags for API Gateway HTTP 4xx requests monitor | list(string) | `[]` | no | | http\_4xx\_requests\_message | Custom message for API Gateway HTTP 4xx requests monitor | string | `""` | no | | http\_4xx\_requests\_threshold\_critical | Maximum critical acceptable percent of 4xx errors | string | `"30"` | no | | http\_4xx\_requests\_threshold\_warning | Maximum warning acceptable percent of 4xx errors | string | `"15"` | no | | http\_4xx\_requests\_time\_aggregator | Monitor aggregator for API HTTP 4xx requests [available values: min, max or avg] | string | `"min"` | no | | http\_4xx\_requests\_timeframe | 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`] | string | `"last_5m"` | no | | http\_5xx\_requests\_enabled | Flag to enable API Gateway HTTP 5xx requests monitor | string | `"true"` | no | -| http\_5xx\_requests\_extra\_tags | Extra tags for API Gateway HTTP 5xx requests monitor | list | `[]` | no | +| http\_5xx\_requests\_extra\_tags | Extra tags for API Gateway HTTP 5xx requests monitor | list(string) | `[]` | no | | http\_5xx\_requests\_message | Custom message for API Gateway HTTP 5xx requests monitor | string | `""` | no | | http\_5xx\_requests\_threshold\_critical | Maximum critical acceptable percent of 5xx errors | string | `"20"` | no | | http\_5xx\_requests\_threshold\_warning | Maximum warning acceptable percent of 5xx errors | string | `"10"` | no | | http\_5xx\_requests\_time\_aggregator | Monitor aggregator for API HTTP 5xx requests [available values: min, max or avg] | string | `"min"` | no | | http\_5xx\_requests\_timeframe | 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`] | string | `"last_5m"` | no | | latency\_enabled | Flag to enable API Gateway latency monitor | string | `"true"` | no | -| latency\_extra\_tags | Extra tags for API Gateway latency monitor | list | `[]` | no | +| latency\_extra\_tags | Extra tags for API Gateway latency monitor | list(string) | `[]` | no | | latency\_message | Custom message for API Gateway latency monitor | string | `""` | no | | latency\_threshold\_critical | Alerting threshold in milliseconds | string | `"800"` | no | | latency\_threshold\_warning | Warning threshold in milliseconds | string | `"400"` | no | 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..d318f81 100644 --- a/cloud/aws/apigateway/monitors-api.tf +++ b/cloud/aws/apigateway/monitors-api.tf @@ -1,91 +1,89 @@ # 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}}" + message = coalesce(var.latency_message, var.message) type = "query alert" - 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}" - - 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 + 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:apigateway", "team:claranet", "created-by:terraform", "${var.latency_extra_tags}"] + tags = concat(["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}" + 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}}" + 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 } - notify_no_data = false # Will NOT notify when no data is received + 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:aws", "resource:apigateway", "team:claranet", "created-by:terraform", "${var.http_5xx_requests_extra_tags}"] + tags = concat(["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}" + 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}}" + message = coalesce(var.http_4xx_requests_message, var.message) type = "query alert" - 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 } - notify_no_data = false # Will NOT notify when no data is received + 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:aws", "resource:apigateway", "team:claranet", "created-by:terraform", "${var.http_4xx_requests_extra_tags}"] + tags = concat(["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/elasticache/common/README.md b/cloud/aws/elasticache/common/README.md index bfb099f..4cacdd6 100644 --- a/cloud/aws/elasticache/common/README.md +++ b/cloud/aws/elasticache/common/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-cloud-aws-elasticache-common" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//cloud/aws/elasticache/common?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -30,10 +30,10 @@ Creates DataDog monitors with the following checks: | environment | Infrastructure Environment | string | n/a | yes | | evaluation\_delay | Delay in seconds for the metric evaluation | string | `"900"` | no | | eviction\_enabled | Flag to enable Elasticache eviction monitor | string | `"true"` | no | -| eviction\_extra\_tags | Extra tags for Elasticache eviction monitor | list | `[]` | no | +| eviction\_extra\_tags | Extra tags for Elasticache eviction monitor | list(string) | `[]` | no | | eviction\_growing\_condition\_timeframe | 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`] | string | `"last_5m"` | no | | eviction\_growing\_enabled | Flag to enable Elasticache eviction growing monitor | string | `"true"` | no | -| eviction\_growing\_extra\_tags | Extra tags for Elasticache eviction growing monitor | list | `[]` | no | +| eviction\_growing\_extra\_tags | Extra tags for Elasticache eviction growing monitor | list(string) | `[]` | no | | eviction\_growing\_message | Custom message for Elasticache eviction growing monitor | string | `""` | no | | eviction\_growing\_threshold\_critical | Elasticache eviction growing critical threshold in percentage | string | `"30"` | no | | eviction\_growing\_threshold\_warning | Elasticache eviction growing warning threshold in percentage | string | `"10"` | no | @@ -47,26 +47,26 @@ Creates DataDog monitors with the following checks: | filter\_tags\_use\_defaults | Use default filter tags convention | string | `"true"` | no | | free\_memory\_condition\_timeframe | 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`] | string | `"last_15m"` | no | | free\_memory\_enabled | Flag to enable Elasticache free memory monitor | string | `"true"` | no | -| free\_memory\_extra\_tags | Extra tags for Elasticache free memory monitor | list | `[]` | no | +| free\_memory\_extra\_tags | Extra tags for Elasticache free memory monitor | list(string) | `[]` | no | | free\_memory\_message | Custom message for Elasticache free memory monitor | string | `""` | no | | free\_memory\_threshold\_critical | Elasticache free memory critical threshold in percentage | string | `"-70"` | no | | free\_memory\_threshold\_warning | Elasticache free memory warning threshold in percentage | string | `"-50"` | no | | free\_memory\_timeframe | 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`] | string | `"last_15m"` | no | | max\_connection\_enabled | Flag to enable Elasticache max connection monitor | string | `"true"` | no | -| max\_connection\_extra\_tags | Extra tags for Elasticache max connection monitor | list | `[]` | no | +| max\_connection\_extra\_tags | Extra tags for Elasticache max connection monitor | list(string) | `[]` | no | | max\_connection\_message | Custom message for Elasticache max connection monitor | string | `""` | no | | max\_connection\_time\_aggregator | Monitor aggregator for Elasticache max connection [available values: min, max or avg] | string | `"max"` | no | | max\_connection\_timeframe | 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`] | string | `"last_5m"` | no | | message | Message sent when an alert is triggered | string | n/a | yes | | new\_host\_delay | Delay in seconds before monitor new resource | string | `"300"` | no | | no\_connection\_enabled | Flag to enable Elasticache no connection monitor | string | `"true"` | no | -| no\_connection\_extra\_tags | Extra tags for Elasticache no connection monitor | list | `[]` | no | +| no\_connection\_extra\_tags | Extra tags for Elasticache no connection monitor | list(string) | `[]` | no | | no\_connection\_message | Custom message for Elasticache no connection monitor | string | `""` | no | | no\_connection\_time\_aggregator | Monitor aggregator for Elasticache no connection [available values: min, max or avg] | string | `"min"` | no | | no\_connection\_timeframe | 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`] | string | `"last_5m"` | no | | prefix\_slug | Prefix string to prepend between brackets on every monitors names | string | `""` | no | | swap\_enabled | Flag to enable Elasticache swap monitor | string | `"true"` | no | -| swap\_extra\_tags | Extra tags for Elasticache swap monitor | list | `[]` | no | +| swap\_extra\_tags | Extra tags for Elasticache swap monitor | list(string) | `[]` | no | | swap\_message | Custom message for Elasticache swap monitor | string | `""` | no | | swap\_threshold\_critical | Elasticache swap critical threshold in bytes | string | `"50000000"` | no | | swap\_threshold\_warning | Elasticache swap warning threshold in bytes | string | `"0"` | no | 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..c59fb54 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)}" - - type = "query alert" + 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 } + 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.eviction_extra_tags}"] + tags = concat(["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}" + 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" + message = coalesce(var.max_connection_message, var.message) + type = "query alert" query = <= 65000 - EOQ +EOQ + evaluation_delay = var.evaluation_delay + 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", "team:claranet", "created-by:terraform", "${var.max_connection_extra_tags}"] + tags = concat(["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}" + 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)}" + 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 = concat(["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)}" - - type = "query alert" + 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}" + 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 - 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}"] + tags = concat(["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/memcached/README.md b/cloud/aws/elasticache/memcached/README.md index 7af26dc..36d903f 100644 --- a/cloud/aws/elasticache/memcached/README.md +++ b/cloud/aws/elasticache/memcached/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-cloud-aws-elasticache-memcached" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//cloud/aws/elasticache/memcached?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -24,7 +24,7 @@ Creates DataDog monitors with the following checks: | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| | cpu\_high\_enabled | Flag to enable Elasticache memcached cpu high monitor | string | `"true"` | no | -| cpu\_high\_extra\_tags | Extra tags for Elasticache memcached cpu high monitor | list | `[]` | no | +| cpu\_high\_extra\_tags | Extra tags for Elasticache memcached cpu high monitor | list(string) | `[]` | no | | cpu\_high\_message | Custom message for Elasticache memcached cpu high monitor | string | `""` | no | | cpu\_high\_threshold\_critical | Elasticache memcached cpu high critical threshold in percentage | string | `"90"` | no | | cpu\_high\_threshold\_warning | Elasticache memcached cpu high warning threshold in percentage | string | `"75"` | no | @@ -36,7 +36,7 @@ Creates DataDog monitors with the following checks: | filter\_tags\_custom\_excluded | Tags excluded for custom filtering when filter_tags_use_defaults is false | string | `""` | no | | filter\_tags\_use\_defaults | Use default filter tags convention | string | `"true"` | no | | get\_hits\_enabled | Flag to enable Elasticache memcached get hits monitor | string | `"true"` | no | -| get\_hits\_extra\_tags | Extra tags for Elasticache memcached get hits monitor | list | `[]` | no | +| get\_hits\_extra\_tags | Extra tags for Elasticache memcached get hits monitor | list(string) | `[]` | no | | get\_hits\_message | Custom message for Elasticache memcached get hits monitor | string | `""` | no | | get\_hits\_threshold\_critical | Elasticache memcached get hits critical threshold in percentage | string | `"60"` | no | | get\_hits\_threshold\_warning | Elasticache memcached get hits warning threshold in percentage | string | `"80"` | no | 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..4dcb3d0 100644 --- a/cloud/aws/elasticache/memcached/monitors-memcached.tf +++ b/cloud/aws/elasticache/memcached/monitors-memcached.tf @@ -1,9 +1,8 @@ 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)}" - - type = "query alert" + message = coalesce(var.get_hits_message, var.message) + type = "query alert" query = < ${var.cpu_high_threshold_critical} - EOQ +EOQ - thresholds { - warning = "${var.cpu_high_threshold_warning}" - critical = "${var.cpu_high_threshold_critical}" + thresholds = { + warning = var.cpu_high_threshold_warning + critical = var.cpu_high_threshold_critical } + evaluation_delay = var.evaluation_delay + 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-memcached", "team:claranet", "created-by:terraform", "engine:memcached", "${var.cpu_high_extra_tags}"] + tags = concat(["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/redis/README.md b/cloud/aws/elasticache/redis/README.md index a1ef9c3..e3d6d8b 100644 --- a/cloud/aws/elasticache/redis/README.md +++ b/cloud/aws/elasticache/redis/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-cloud-aws-elasticache-redis" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//cloud/aws/elasticache/redis?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -26,18 +26,18 @@ Creates DataDog monitors with the following checks: | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| | cache\_hits\_enabled | Flag to enable Elasticache redis cache hits monitor | string | `"true"` | no | -| cache\_hits\_extra\_tags | Extra tags for Elasticache redis cache hits monitor | list | `[]` | no | +| cache\_hits\_extra\_tags | Extra tags for Elasticache redis cache hits monitor | list(string) | `[]` | no | | cache\_hits\_message | Custom message for Elasticache redis cache hits monitor | string | `""` | no | | cache\_hits\_threshold\_critical | Elasticache redis cache hits critical threshold in percentage | string | `"60"` | no | | cache\_hits\_threshold\_warning | Elasticache redis cache hits warning threshold in percentage | string | `"80"` | no | | cache\_hits\_time\_aggregator | Monitor aggregator for Elasticache redis cache hits [available values: min, max or avg] | string | `"max"` | no | | cache\_hits\_timeframe | 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`] | string | `"last_15m"` | no | | commands\_enabled | Flag to enable Elasticache redis commands monitor | string | `"true"` | no | -| commands\_extra\_tags | Extra tags for Elasticache redis commands monitor | list | `[]` | no | +| commands\_extra\_tags | Extra tags for Elasticache redis commands monitor | list(string) | `[]` | no | | commands\_message | Custom message for Elasticache redis commands monitor | string | `""` | no | | commands\_timeframe | 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`] | string | `"last_5m"` | no | | cpu\_high\_enabled | Flag to enable Elasticache redis cpu high monitor | string | `"true"` | no | -| cpu\_high\_extra\_tags | Extra tags for Elasticache redis cpu high monitor | list | `[]` | no | +| cpu\_high\_extra\_tags | Extra tags for Elasticache redis cpu high monitor | list(string) | `[]` | no | | cpu\_high\_message | Custom message for Elasticache redis cpu high monitor | string | `""` | no | | cpu\_high\_threshold\_critical | Elasticache redis cpu high critical threshold in percentage | string | `"90"` | no | | cpu\_high\_threshold\_warning | Elasticache redis cpu high warning threshold in percentage | string | `"75"` | no | @@ -52,7 +52,7 @@ Creates DataDog monitors with the following checks: | new\_host\_delay | Delay in seconds before monitor new resource | string | `"300"` | no | | prefix\_slug | Prefix string to prepend between brackets on every monitors names | string | `""` | no | | replication\_lag\_enabled | Flag to enable Elasticache redis replication lag monitor | string | `"true"` | no | -| replication\_lag\_extra\_tags | Extra tags for Elasticache redis replication lag monitor | list | `[]` | no | +| replication\_lag\_extra\_tags | Extra tags for Elasticache redis replication lag monitor | list(string) | `[]` | no | | replication\_lag\_message | Custom message for Elasticache redis replication lag monitor | string | `""` | no | | replication\_lag\_threshold\_critical | Elasticache redis replication lag critical threshold in seconds | string | `"180"` | no | | replication\_lag\_threshold\_warning | Elasticache redis replication lag warning threshold in seconds | string | `"90"` | no | 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..c3bf595 100644 --- a/cloud/aws/elasticache/redis/monitors-redis.tf +++ b/cloud/aws/elasticache/redis/monitors-redis.tf @@ -1,9 +1,8 @@ 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)}" - - type = "query alert" + message = coalesce(var.cache_hits_message, var.message) + type = "query alert" query = < ${var.cpu_high_threshold_critical} - EOQ +EOQ + evaluation_delay = var.evaluation_delay + 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 = concat(["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}" + 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)}" + message = coalesce(var.replication_lag_message, var.message) + type = "query alert" - 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 } + 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-redis", "team:claranet", "created-by:terraform", "engine:redis", "${var.replication_lag_extra_tags}"] + tags = concat(["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}" + 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)}" + message = coalesce(var.commands_message, var.message) + type = "query alert" - 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)}" - - type = "query alert" + message = coalesce(var.es_cluster_status_message, var.message) + type = "query alert" query = <= 2 - EOQ +EOQ - thresholds { + thresholds = { warning = 1 critical = 2 } + evaluation_delay = var.evaluation_delay + 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:elasticsearch", "team:claranet", "created-by:terraform", "${var.es_cluster_status_extra_tags}"] + tags = concat(["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}" + 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" + 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}" + thresholds = { + warning = var.cpu_threshold_warning + critical = var.cpu_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:elasticsearch", "team:claranet", "created-by:terraform", "${var.cpu_extra_tags}"] + tags = concat(["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/elb/README.md b/cloud/aws/elb/README.md index ae1e91a..430ae50 100644 --- a/cloud/aws/elb/README.md +++ b/cloud/aws/elb/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-cloud-aws-elb" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//cloud/aws/elb?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -29,38 +29,38 @@ Creates DataDog monitors with the following checks: |------|-------------|:----:|:-----:|:-----:| | artificial\_requests\_count | Number of false requests used to mitigate false positive in case of low trafic | string | `"5"` | no | | elb\_4xx\_enabled | Flag to enable ELB 4xx errors monitor | string | `"true"` | no | -| elb\_4xx\_extra\_tags | Extra tags for ELB 4xx errors monitor | list | `[]` | no | +| elb\_4xx\_extra\_tags | Extra tags for ELB 4xx errors monitor | list(string) | `[]` | no | | elb\_4xx\_message | Custom message for ELB 4xx errors monitor | string | `""` | no | | elb\_4xx\_threshold\_critical | loadbalancer 4xx critical threshold in percentage | string | `"10"` | no | | elb\_4xx\_threshold\_warning | loadbalancer 4xx warning threshold in percentage | string | `"5"` | no | | elb\_4xx\_timeframe | 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`] | string | `"last_5m"` | no | | elb\_5xx\_enabled | Flag to enable ELB 5xx errors monitor | string | `"true"` | no | -| elb\_5xx\_extra\_tags | Extra tags for ELB 5xx errors monitor | list | `[]` | no | +| elb\_5xx\_extra\_tags | Extra tags for ELB 5xx errors monitor | list(string) | `[]` | no | | elb\_5xx\_message | Custom message for ELB 5xx errors monitor | string | `""` | no | | elb\_5xx\_threshold\_critical | loadbalancer 5xx critical threshold in percentage | string | `"10"` | no | | elb\_5xx\_threshold\_warning | loadbalancer 5xx warning threshold in percentage | string | `"5"` | no | | elb\_5xx\_timeframe | 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`] | string | `"last_5m"` | no | | elb\_backend\_4xx\_enabled | Flag to enable ELB backend 4xx errors monitor | string | `"true"` | no | -| elb\_backend\_4xx\_extra\_tags | Extra tags for ELB backend 4xx errors monitor | list | `[]` | no | +| elb\_backend\_4xx\_extra\_tags | Extra tags for ELB backend 4xx errors monitor | list(string) | `[]` | no | | elb\_backend\_4xx\_message | Custom message for ELB backend 4xx errors monitor | string | `""` | no | | elb\_backend\_4xx\_threshold\_critical | loadbalancer backend 4xx critical threshold in percentage | string | `"10"` | no | | elb\_backend\_4xx\_threshold\_warning | loadbalancer backend 4xx warning threshold in percentage | string | `"5"` | no | | elb\_backend\_4xx\_timeframe | 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`] | string | `"last_5m"` | no | | elb\_backend\_5xx\_enabled | Flag to enable ELB backend 5xx errors monitor | string | `"true"` | no | -| elb\_backend\_5xx\_extra\_tags | Extra tags for ELB backend 5xx errors monitor | list | `[]` | no | +| elb\_backend\_5xx\_extra\_tags | Extra tags for ELB backend 5xx errors monitor | list(string) | `[]` | no | | elb\_backend\_5xx\_message | Custom message for ELB backend 5xx errors monitor | string | `""` | no | | elb\_backend\_5xx\_threshold\_critical | loadbalancer backend 5xx critical threshold in percentage | string | `"10"` | no | | elb\_backend\_5xx\_threshold\_warning | loadbalancer backend 5xx warning threshold in percentage | string | `"5"` | no | | elb\_backend\_5xx\_timeframe | 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`] | string | `"last_5m"` | no | | elb\_backend\_latency\_critical | latency critical threshold in seconds | string | `"5"` | no | | elb\_backend\_latency\_enabled | Flag to enable ELB backend latency monitor | string | `"true"` | no | -| elb\_backend\_latency\_extra\_tags | Extra tags for ELB backend latency monitor | list | `[]` | no | +| elb\_backend\_latency\_extra\_tags | Extra tags for ELB backend latency monitor | list(string) | `[]` | no | | elb\_backend\_latency\_message | Custom message for ELB backend latency monitor | string | `""` | no | | elb\_backend\_latency\_time\_aggregator | Monitor aggregator for ELB backend latency [available values: min, max or avg] | string | `"min"` | no | | elb\_backend\_latency\_timeframe | 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`] | string | `"last_5m"` | no | | elb\_backend\_latency\_warning | latency warning threshold in seconds | string | `"1"` | no | | elb\_no\_healthy\_instance\_enabled | Flag to enable ELB no healty instance monitor | string | `"true"` | no | -| elb\_no\_healthy\_instance\_extra\_tags | Extra tags for ELB no healty instance monitor | list | `[]` | no | +| elb\_no\_healthy\_instance\_extra\_tags | Extra tags for ELB no healty instance monitor | list(string) | `[]` | no | | elb\_no\_healthy\_instance\_message | Custom message for ELB no healty instance monitor | string | `""` | no | | elb\_no\_healthy\_instance\_time\_aggregator | Monitor aggregator for ELB no healty instance [available values: min or max] | string | `"min"` | no | | elb\_no\_healthy\_instance\_timeframe | 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`] | string | `"last_5m"` | no | 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..aca05f2 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 } + 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:elb", "team:claranet", "created-by:terraform", "${var.elb_4xx_extra_tags}"] + tags = concat(["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}" + 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)}" + 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 } + 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:elb", "team:claranet", "created-by:terraform", "${var.elb_5xx_extra_tags}"] + tags = concat(["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}" + 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)}" + 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 } + 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:elb", "team:claranet", "created-by:terraform", "${var.elb_backend_4xx_extra_tags}"] + tags = concat(["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 } + 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:elb", "team:claranet", "created-by:terraform", "${var.elb_backend_5xx_extra_tags}"] + tags = concat(["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}" + 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)}" + 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}" + thresholds = { + warning = var.elb_backend_latency_warning + critical = var.elb_backend_latency_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:elb", "team:claranet", "created-by:terraform", "${var.elb_backend_latency_extra_tags}"] + tags = concat(["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/kinesis-firehose/README.md b/cloud/aws/kinesis-firehose/README.md index b8130ce..5cdf537 100644 --- a/cloud/aws/kinesis-firehose/README.md +++ b/cloud/aws/kinesis-firehose/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-cloud-aws-kinesis-firehose" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//cloud/aws/kinesis-firehose?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -28,7 +28,7 @@ Creates DataDog monitors with the following checks: | filter\_tags\_custom\_excluded | Tags excluded for custom filtering when filter_tags_use_defaults is false | string | `""` | no | | filter\_tags\_use\_defaults | Use default filter tags convention | string | `"true"` | no | | incoming\_records\_enabled | Flag to enable Kinesis Firehorse incoming records monitor | string | `"true"` | no | -| incoming\_records\_extra\_tags | Extra tags for Kinesis Firehorse incoming records monitor | list | `[]` | no | +| incoming\_records\_extra\_tags | Extra tags for Kinesis Firehorse incoming records monitor | list(string) | `[]` | no | | incoming\_records\_message | Custom message for Kinesis Firehorse incoming records monitor | string | `""` | no | | incoming\_records\_timeframe | 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`] | string | `"last_15m"` | no | | message | Message sent when an alert is triggered | string | n/a | yes | 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..41faf73 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)}" - - type = "query alert" + 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 } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay 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}" - tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:rds-aurora-mysql", "team:claranet", "created-by:terraform", "${var.aurora_replicalag_extra_tags}"] + tags = concat(["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/postgresql/README.md b/cloud/aws/rds/aurora/postgresql/README.md index aa14718..75eb888 100644 --- a/cloud/aws/rds/aurora/postgresql/README.md +++ b/cloud/aws/rds/aurora/postgresql/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-cloud-aws-rds-aurora-postgresql" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//cloud/aws/rds/aurora/postgresql?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -23,7 +23,7 @@ Creates DataDog monitors with the following checks: | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| | aurora\_replicalag\_enabled | Flag to enable RDS Aurora replica lag monitor | string | `"true"` | no | -| aurora\_replicalag\_extra\_tags | Extra tags for RDS Aurora replica lag monitor | list | `[]` | no | +| aurora\_replicalag\_extra\_tags | Extra tags for RDS Aurora replica lag monitor | list(string) | `[]` | no | | aurora\_replicalag\_message | Custom message for RDS Aurora replica lag monitor | string | `""` | no | | aurora\_replicalag\_threshold\_critical | Aurora replica lag in milliseconds (critical threshold) | string | `"200"` | no | | aurora\_replicalag\_threshold\_warning | Aurora replica lag in milliseconds (warning threshold) | string | `"100"` | no | 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..399c0ce 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)}" - - type = "query alert" + 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 } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay 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}" - tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:rds-aurora-postgresql", "team:claranet", "created-by:terraform", "${var.aurora_replicalag_extra_tags}"] + tags = concat(["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/common/README.md b/cloud/aws/rds/common/README.md index 7a98914..b2402be 100644 --- a/cloud/aws/rds/common/README.md +++ b/cloud/aws/rds/common/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-cloud-aws-rds-common" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//cloud/aws/rds/common?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -25,14 +25,14 @@ Creates DataDog monitors with the following checks: | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| | cpu\_enabled | Flag to enable RDS CPU usage monitor | string | `"true"` | no | -| cpu\_extra\_tags | Extra tags for RDS CPU usage monitor | list | `[]` | no | +| cpu\_extra\_tags | Extra tags for RDS CPU usage monitor | list(string) | `[]` | no | | cpu\_message | Custom message for RDS CPU usage monitor | string | `""` | no | | cpu\_threshold\_critical | CPU usage in percent (critical threshold) | string | `"90"` | no | | cpu\_threshold\_warning | CPU usage in percent (warning threshold) | string | `"80"` | no | | cpu\_time\_aggregator | Monitor aggregator for RDS CPU usage [available values: min, max or avg] | string | `"min"` | no | | cpu\_timeframe | 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`] | string | `"last_15m"` | no | | diskspace\_enabled | Flag to enable RDS free diskspace monitor | string | `"true"` | no | -| diskspace\_extra\_tags | Extra tags for RDS free diskspace monitor | list | `[]` | no | +| diskspace\_extra\_tags | Extra tags for RDS free diskspace monitor | list(string) | `[]` | no | | diskspace\_message | Custom message for RDS free diskspace monitor | string | `""` | no | | diskspace\_threshold\_critical | Disk free space in percent (critical threshold) | string | `"10"` | no | | diskspace\_threshold\_warning | Disk free space in percent (warning threshold) | string | `"20"` | no | @@ -47,7 +47,7 @@ Creates DataDog monitors with the following checks: | new\_host\_delay | Delay in seconds before monitor new resource | string | `"300"` | no | | prefix\_slug | Prefix string to prepend between brackets on every monitors names | string | `""` | no | | replicalag\_enabled | Flag to enable RDS replica lag monitor | string | `"true"` | no | -| replicalag\_extra\_tags | Extra tags for RDS replica lag monitor | list | `[]` | no | +| replicalag\_extra\_tags | Extra tags for RDS replica lag monitor | list(string) | `[]` | no | | replicalag\_message | Custom message for RDS replica lag monitor | string | `""` | no | | replicalag\_threshold\_critical | replica lag in seconds (critical threshold) | string | `"300"` | no | | replicalag\_threshold\_warning | replica lag in seconds (warning threshold) | string | `"200"` | no | 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..d8c7931 100644 --- a/cloud/aws/rds/common/monitors-rds-common.tf +++ b/cloud/aws/rds/common/monitors-rds-common.tf @@ -1,93 +1,91 @@ ### 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)}" - - type = "query alert" + 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 } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay 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.cpu_extra_tags}"] + tags = concat(["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}" + 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" + 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}" + thresholds = { + warning = var.replicalag_threshold_warning + critical = var.replicalag_threshold_critical } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay 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}"] + tags = concat(["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/vpn/README.md b/cloud/aws/vpn/README.md index 3d57f63..43b1e44 100644 --- a/cloud/aws/vpn/README.md +++ b/cloud/aws/vpn/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-cloud-aws-vpn" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//cloud/aws/vpn?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -29,7 +29,7 @@ Creates DataDog monitors with the following checks: | new\_host\_delay | Delay in seconds before monitor new resource | string | `"300"` | no | | prefix\_slug | Prefix string to prepend between brackets on every monitors names | string | `""` | no | | vpn\_status\_enabled | Flag to enable VPN status monitor | string | `"true"` | no | -| vpn\_status\_extra\_tags | Extra tags for VPN status monitor | list | `[]` | no | +| vpn\_status\_extra\_tags | Extra tags for VPN status monitor | list(string) | `[]` | no | | vpn\_status\_message | Custom message for VPN status monitor | string | `""` | no | | vpn\_status\_time\_aggregator | Monitor aggregator for VPN status [available values: min, max or avg] | string | `"max"` | no | | vpn\_status\_timeframe | Monitor timeframe for VPN status [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_5m"` | no | 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..10480a3 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" + new_host_delay = var.new_host_delay + evaluation_delay = var.evaluation_delay 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 = concat(["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}" + 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)}" + 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" + new_host_delay = var.new_host_delay + evaluation_delay = var.evaluation_delay 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 = concat(["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}" + 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)}" + 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" + new_host_delay = var.new_host_delay + evaluation_delay = var.evaluation_delay 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.unauthorized_requests_extra_tags}"] + tags = concat(["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 + 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:app-services", "team:claranet", "created-by:terraform", "${var.response_time_extra_tags}"] + tags = concat(["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}" + 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}}" + message = coalesce(var.memory_usage_message, var.message) type = "query alert" - 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 } - notify_no_data = false # Will NOT notify when no data is received + 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:app-services", "team:claranet", "created-by:terraform", "${var.memory_usage_extra_tags}"] + tags = concat(["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}" + 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 } - notify_no_data = false # Will NOT notify when no data is received + 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:app-services", "team:claranet", "created-by:terraform", "${var.http_5xx_requests_extra_tags}"] + tags = concat(["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}" + 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}}" + message = coalesce(var.http_4xx_requests_message, var.message) type = "query alert" - 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 = concat(["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 + 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 - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:azure-search", "team:claranet", "created-by:terraform", "${var.latency_extra_tags}"] + tags = concat(["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}" + 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}" + 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 + 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}"] + tags = concat(["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/cosmosdb/README.md b/cloud/azure/cosmosdb/README.md index bdb1b99..e21ffd5 100644 --- a/cloud/azure/cosmosdb/README.md +++ b/cloud/azure/cosmosdb/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-cloud-azure-cosmosdb" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//cloud/azure/cosmosdb?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -25,14 +25,14 @@ Creates DataDog monitors with the following checks: | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| -| cosmos\_db\_4xx\_request\_extra\_tags | Extra tags for Cosmos DB 4xx requests monitor | list | `[]` | no | +| cosmos\_db\_4xx\_request\_extra\_tags | Extra tags for Cosmos DB 4xx requests monitor | list(string) | `[]` | no | | cosmos\_db\_4xx\_request\_rate\_threshold\_critical | Critical threshold for Cosmos DB 4xx requests monitor | string | `"80"` | no | | cosmos\_db\_4xx\_request\_rate\_threshold\_warning | Warning threshold for Cosmos DB 4xx requests monitor | string | `"50"` | no | | cosmos\_db\_4xx\_request\_time\_aggregator | Monitor aggregator for Cosmos DB 4xx requests [available values: min, max or avg] | string | `"min"` | no | | cosmos\_db\_4xx\_request\_timeframe | 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`] | string | `"last_5m"` | no | | cosmos\_db\_4xx\_requests\_enabled | Flag to enable Cosmos DB 4xx requests monitor | string | `"true"` | no | | cosmos\_db\_4xx\_requests\_message | Custom message for Cosmos DB 4xx requests monitor | string | `""` | no | -| cosmos\_db\_5xx\_request\_rate\_extra\_tags | Extra tags for Cosmos DB 5xx requests monitor | list | `[]` | no | +| cosmos\_db\_5xx\_request\_rate\_extra\_tags | Extra tags for Cosmos DB 5xx requests monitor | list(string) | `[]` | no | | cosmos\_db\_5xx\_request\_rate\_threshold\_critical | Critical threshold for Cosmos DB 5xx requests monitor | string | `"80"` | no | | cosmos\_db\_5xx\_request\_rate\_threshold\_warning | Warning threshold for Cosmos DB 5xx requests monitor | string | `"50"` | no | | cosmos\_db\_5xx\_request\_time\_aggregator | Monitor aggregator for Cosmos DB 5xx requests [available values: min, max or avg] | string | `"min"` | no | @@ -42,7 +42,7 @@ Creates DataDog monitors with the following checks: | cosmos\_db\_scaling\_enabled | Flag to enable Cosmos DB scaling monitor | string | `"true"` | no | | cosmos\_db\_scaling\_error\_rate\_threshold\_critical | Critical threshold for Cosmos DB scaling monitor | string | `"10"` | no | | cosmos\_db\_scaling\_error\_rate\_threshold\_warning | Warning threshold for Cosmos DB scaling monitor | string | `"5"` | no | -| cosmos\_db\_scaling\_extra\_tags | Extra tags for Cosmos DB scaling monitor | list | `[]` | no | +| cosmos\_db\_scaling\_extra\_tags | Extra tags for Cosmos DB scaling monitor | list(string) | `[]` | no | | cosmos\_db\_scaling\_message | Custom message for Cosmos DB scaling monitor | string | `""` | no | | cosmos\_db\_scaling\_time\_aggregator | Monitor aggregator for Cosmos DB scaling [available values: min, max or avg] | string | `"min"` | no | | cosmos\_db\_scaling\_timeframe | 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`] | string | `"last_5m"` | no | @@ -55,7 +55,7 @@ Creates DataDog monitors with the following checks: | new\_host\_delay | Delay in seconds before monitor new resource | string | `"300"` | no | | prefix\_slug | Prefix string to prepend between brackets on every monitors names | string | `""` | no | | status\_enabled | Flag to enable Cosmos DB status monitor | string | `"true"` | no | -| status\_extra\_tags | Extra tags for Cosmos DB status monitor | list | `[]` | no | +| status\_extra\_tags | Extra tags for Cosmos DB status monitor | list(string) | `[]` | no | | status\_message | Custom message for Cosmos DB status monitor | string | `""` | no | | status\_time\_aggregator | Monitor aggregator for Cosmos DB status [available values: min, max or avg] | string | `"max"` | no | | status\_timeframe | 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`] | string | `"last_5m"` | no | 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..df3ed86 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 } + 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:azure", "resource:cosmos_db", "team:claranet", "created-by:terraform", "${var.cosmos_db_4xx_request_extra_tags}"] + tags = concat(["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)}" + message = coalesce(var.cosmos_db_5xx_requests_message, var.message) + type = "query alert" - 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 } + 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:azure", "resource:cosmos_db", "team:claranet", "created-by:terraform", "${var.cosmos_db_5xx_request_rate_extra_tags}"] + tags = concat(["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)}" + message = coalesce(var.cosmos_db_scaling_message, var.message) + type = "query alert" # 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 } + 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:azure", "resource:cosmos_db", "team:claranet", "created-by:terraform", "${var.cosmos_db_scaling_extra_tags}"] + tags = concat(["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/datalakestore/README.md b/cloud/azure/datalakestore/README.md index 6f5883b..7a927af 100644 --- a/cloud/azure/datalakestore/README.md +++ b/cloud/azure/datalakestore/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-cloud-azure-datalakestore" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//cloud/azure/datalakestore?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -31,7 +31,7 @@ Creates DataDog monitors with the following checks: | new\_host\_delay | Delay in seconds before monitor new resource | string | `"300"` | no | | prefix\_slug | Prefix string to prepend between brackets on every monitors names | string | `""` | no | | status\_enabled | Flag to enable Datalake Store status monitor | string | `"true"` | no | -| status\_extra\_tags | 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`] | list | `[]` | no | +| status\_extra\_tags | 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`] | list(string) | `[]` | no | | status\_message | Custom message for Datalake Store status monitor | string | `""` | no | | status\_time\_aggregator | Monitor aggregator for Datalake Store status [available values: min, max or avg] | string | `"max"` | no | | status\_timeframe | Monitor timeframe for Datalake Store status [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_5m"` | no | 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..2619065 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 } + 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:azure", "resource:eventgrid", "team:claranet", "created-by:terraform", "${var.failed_messages_rate_extra_tags}"] + tags = concat(["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}" + 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)}" + 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}" + thresholds = { + critical = var.unmatched_events_rate_thresold_critical + warning = var.unmatched_events_rate_thresold_warning } + 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:azure", "resource:eventgrid", "team:claranet", "created-by:terraform", "${var.unmatched_events_rate_extra_tags}"] + tags = concat(["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/eventhub/README.md b/cloud/azure/eventhub/README.md index bee96c1..67d796a 100644 --- a/cloud/azure/eventhub/README.md +++ b/cloud/azure/eventhub/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-cloud-azure-eventhub" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//cloud/azure/eventhub?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -26,7 +26,7 @@ Creates DataDog monitors with the following checks: |------|-------------|:----:|:-----:|:-----:| | environment | Architecture environment | string | n/a | yes | | errors\_rate\_enabled | Flag to enable Event Hub errors monitor | string | `"true"` | no | -| errors\_rate\_extra\_tags | Extra tags for Event Hub errors monitor | list | `[]` | no | +| errors\_rate\_extra\_tags | Extra tags for Event Hub errors monitor | list(string) | `[]` | no | | errors\_rate\_message | Custom message for Event Hub errors monitor | string | `""` | no | | errors\_rate\_thresold\_critical | Errors ratio (percentage) to trigger the critical alert | string | `"90"` | no | | errors\_rate\_thresold\_warning | Errors ratio (percentage) to trigger a warning alert | string | `"50"` | no | @@ -34,7 +34,7 @@ Creates DataDog monitors with the following checks: | errors\_rate\_timeframe | 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`] | string | `"last_5m"` | no | | evaluation\_delay | Delay in seconds for the metric evaluation | string | `"900"` | no | | failed\_requests\_rate\_enabled | Flag to enable Event Hub failed requests monitor | string | `"true"` | no | -| failed\_requests\_rate\_extra\_tags | Extra tags for Event Hub failed requests monitor | list | `[]` | no | +| failed\_requests\_rate\_extra\_tags | Extra tags for Event Hub failed requests monitor | list(string) | `[]` | no | | failed\_requests\_rate\_message | Custom message for Event Hub failed requests monitor | string | `""` | no | | failed\_requests\_rate\_thresold\_critical | Failed requests ratio (percentage) to trigger the critical alert | string | `"90"` | no | | failed\_requests\_rate\_thresold\_warning | Failed requests ratio (percentage) to trigger a warning alert | string | `"50"` | no | @@ -47,7 +47,7 @@ Creates DataDog monitors with the following checks: | new\_host\_delay | Delay in seconds before monitor new resource | string | `"300"` | no | | prefix\_slug | Prefix string to prepend between brackets on every monitors names | string | `""` | no | | status\_enabled | Flag to enable Event Hub status monitor | string | `"true"` | no | -| status\_extra\_tags | Extra tags for Event Hub status monitor | list | `[]` | no | +| status\_extra\_tags | Extra tags for Event Hub status monitor | list(string) | `[]` | no | | status\_message | Custom message for Event Hub status monitor | string | `""` | no | | status\_time\_aggregator | Monitor aggregator for Event Hub status [available values: min, max or avg] | string | `"max"` | no | | status\_timeframe | 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`] | string | `"last_5m"` | no | 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..aa2945b 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 } + 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:azure", "resource:eventhub", "team:claranet", "created-by:terraform", "${var.failed_requests_rate_extra_tags}"] + tags = concat(["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}" + 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)}" + 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}" + thresholds = { + critical = var.errors_rate_thresold_critical + warning = var.errors_rate_thresold_warning } + 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:azure", "resource:eventhub", "team:claranet", "created-by:terraform", "${var.errors_rate_extra_tags}"] + tags = concat(["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/functions/README.md b/cloud/azure/functions/README.md index b3a39b0..d74794d 100644 --- a/cloud/azure/functions/README.md +++ b/cloud/azure/functions/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-cloud-azure-functions" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//cloud/azure/functions?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -30,21 +30,21 @@ Creates DataDog monitors with the following checks: | filter\_tags\_custom\_excluded | Tags excluded for custom filtering when filter_tags_use_defaults is false | string | `""` | no | | filter\_tags\_use\_defaults | Use default filter tags convention | string | `"true"` | no | | high\_connections\_count\_enabled | Flag to enable Functions high connections count monitor | string | `"true"` | no | -| high\_connections\_count\_extra\_tags | Extra tags for Functions high connections count monitor | list | `[]` | no | +| high\_connections\_count\_extra\_tags | Extra tags for Functions high connections count monitor | list(string) | `[]` | no | | high\_connections\_count\_message | Custom message for Functions high connections count monitor | string | `""` | no | | high\_connections\_count\_threshold\_critical | Alerting threshold for Functions high connections count | string | `"590"` | no | | high\_connections\_count\_threshold\_warning | Warning threshold for Functions high connections count | string | `"550"` | no | | high\_connections\_count\_time\_aggregator | Monitor aggregator for Functions high connections count [available values: min, max or avg] | string | `"min"` | no | | high\_connections\_count\_timeframe | 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`] | string | `"last_5m"` | no | | high\_threads\_count\_enabled | Flag to enable Functions high threads count monitor | string | `"true"` | no | -| high\_threads\_count\_extra\_tags | Extra tags for Functions high threads count monitor | list | `[]` | no | +| high\_threads\_count\_extra\_tags | Extra tags for Functions high threads count monitor | list(string) | `[]` | no | | high\_threads\_count\_message | Custom message for Functions high threads count monitor | string | `""` | no | | high\_threads\_count\_threshold\_critical | Alerting threshold for Functions high threads count | string | `"510"` | no | | high\_threads\_count\_threshold\_warning | Warning threshold for Functions high threads count | string | `"490"` | no | | high\_threads\_count\_time\_aggregator | Monitor aggregator for Functions high threads count [available values: min, max or avg] | string | `"min"` | no | | high\_threads\_count\_timeframe | 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`] | string | `"last_5m"` | no | | http\_5xx\_errors\_rate\_enabled | Flag to enable Functions Http 5xx errors rate monitor | string | `"true"` | no | -| http\_5xx\_errors\_rate\_extra\_tags | Extra tags for Functions Http 5xx errors rate monitor | list | `[]` | no | +| http\_5xx\_errors\_rate\_extra\_tags | Extra tags for Functions Http 5xx errors rate monitor | list(string) | `[]` | no | | http\_5xx\_errors\_rate\_message | Custom message for Functions Http 5xx errors rate monitor | string | `""` | no | | http\_5xx\_errors\_rate\_threshold\_critical | Alerting threshold for Functions Http 5xx errors rate | string | `"20"` | no | | http\_5xx\_errors\_rate\_threshold\_warning | Warning threshold for Functions Http 5xx errors rate | string | `"10"` | no | 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..2d97cce 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}}" + message = coalesce(var.http_5xx_errors_rate_message, var.message) type = "query alert" - 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 } + 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.http_5xx_errors_rate_extra_tags}"] + tags = concat(["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}" + 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}}" + message = coalesce(var.high_connections_count_message, var.message) type = "query alert" - 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 - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:azure_functions", "team:claranet", "created-by:terraform", "${var.high_connections_count_extra_tags}"] + tags = concat(["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}" + 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}}" + message = coalesce(var.high_threads_count_message, var.message) type = "query alert" - 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}" + 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}"] + tags = concat(["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/iothubs/README.md b/cloud/azure/iothubs/README.md index d9a0c26..de92272 100644 --- a/cloud/azure/iothubs/README.md +++ b/cloud/azure/iothubs/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-cloud-azure-iothubs" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//cloud/azure/iothubs?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -36,7 +36,7 @@ Creates DataDog monitors with the following checks: | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| | dropped\_d2c\_telemetry\_egress\_enabled | Flag to enable IoT Hub dropped d2c telemetry monitor | string | `"true"` | no | -| dropped\_d2c\_telemetry\_egress\_extra\_tags | Extra tags for IoT Hub dropped d2c telemetry monitor | list | `[]` | no | +| dropped\_d2c\_telemetry\_egress\_extra\_tags | Extra tags for IoT Hub dropped d2c telemetry monitor | list(string) | `[]` | no | | dropped\_d2c\_telemetry\_egress\_message | Custom message for IoT Hub dropped d2c telemetry monitor | string | `""` | no | | dropped\_d2c\_telemetry\_egress\_rate\_threshold\_critical | D2C Telemetry Dropped limit (critical threshold) | string | `"90"` | no | | dropped\_d2c\_telemetry\_egress\_rate\_threshold\_warning | D2C Telemetry Dropped limit (warning threshold) | string | `"50"` | no | @@ -45,56 +45,56 @@ Creates DataDog monitors with the following checks: | environment | Architecture Environment | string | n/a | yes | | evaluation\_delay | Delay in seconds for the metric evaluation | string | `"900"` | no | | failed\_c2d\_methods\_rate\_enabled | Flag to enable IoT Hub failed c2d methods monitor | string | `"true"` | no | -| failed\_c2d\_methods\_rate\_extra\_tags | Extra tags for IoT Hub failed c2d methods monitor | list | `[]` | no | +| failed\_c2d\_methods\_rate\_extra\_tags | Extra tags for IoT Hub failed c2d methods monitor | list(string) | `[]` | no | | failed\_c2d\_methods\_rate\_message | Custom message for IoT Hub failed c2d method monitor | string | `""` | no | | failed\_c2d\_methods\_rate\_threshold\_critical | C2D Methods Failed rate limit (critical threshold) | string | `"90"` | no | | failed\_c2d\_methods\_rate\_threshold\_warning | C2D Methods Failed rate limit (warning threshold) | string | `"50"` | no | | failed\_c2d\_methods\_rate\_time\_aggregator | Monitor aggregator for IoT Hub failed c2d method [available values: min, max, sum or avg] | string | `"min"` | no | | failed\_c2d\_methods\_rate\_timeframe | 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`] | string | `"last_5m"` | no | | failed\_c2d\_twin\_read\_rate\_enabled | Flag to enable IoT Hub failed c2d twin read monitor | string | `"true"` | no | -| failed\_c2d\_twin\_read\_rate\_extra\_tags | Extra tags for IoT Hub failed c2d twin read monitor | list | `[]` | no | +| failed\_c2d\_twin\_read\_rate\_extra\_tags | Extra tags for IoT Hub failed c2d twin read monitor | list(string) | `[]` | no | | failed\_c2d\_twin\_read\_rate\_message | Custom message for IoT Hub failed c2d twin read monitor | string | `""` | no | | failed\_c2d\_twin\_read\_rate\_threshold\_critical | C2D Twin Read Failed rate limit (critical threshold) | string | `"90"` | no | | failed\_c2d\_twin\_read\_rate\_threshold\_warning | C2D Twin Read Failed rate limit (warning threshold) | string | `"50"` | no | | failed\_c2d\_twin\_read\_rate\_time\_aggregator | Monitor aggregator for IoT Hub failed c2d twin read [available values: min, max, sum or avg] | string | `"min"` | no | | failed\_c2d\_twin\_read\_rate\_timeframe | 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`] | string | `"last_5m"` | no | | failed\_c2d\_twin\_update\_rate\_enabled | Flag to enable IoT Hub failed c2d twin update monitor | string | `"true"` | no | -| failed\_c2d\_twin\_update\_rate\_extra\_tags | Extra tags for IoT Hub failed c2d twin update monitor | list | `[]` | no | +| failed\_c2d\_twin\_update\_rate\_extra\_tags | Extra tags for IoT Hub failed c2d twin update monitor | list(string) | `[]` | no | | failed\_c2d\_twin\_update\_rate\_message | Custom message for IoT Hub failed c2d twin update monitor | string | `""` | no | | failed\_c2d\_twin\_update\_rate\_threshold\_critical | C2D Twin Update Failed rate limit (critical threshold) | string | `"90"` | no | | failed\_c2d\_twin\_update\_rate\_threshold\_warning | C2D Twin Update Failed rate limit (warning threshold) | string | `"50"` | no | | failed\_c2d\_twin\_update\_rate\_time\_aggregator | Monitor aggregator for IoT Hub failed c2d twin update [available values: min, max, sum or avg] | string | `"min"` | no | | failed\_c2d\_twin\_update\_rate\_timeframe | 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`] | string | `"last_5m"` | no | | failed\_d2c\_twin\_read\_rate\_enabled | Flag to enable IoT Hub failed d2c twin read monitor | string | `"true"` | no | -| failed\_d2c\_twin\_read\_rate\_extra\_tags | Extra tags for IoT Hub failed d2c twin read monitor | list | `[]` | no | +| failed\_d2c\_twin\_read\_rate\_extra\_tags | Extra tags for IoT Hub failed d2c twin read monitor | list(string) | `[]` | no | | failed\_d2c\_twin\_read\_rate\_message | Custom message for IoT Hub failed d2c twin read monitor | string | `""` | no | | failed\_d2c\_twin\_read\_rate\_threshold\_critical | D2C Twin Read Failed rate limit (critical threshold) | string | `"90"` | no | | failed\_d2c\_twin\_read\_rate\_threshold\_warning | D2C Twin Read Failed rate limit (warning threshold) | string | `"50"` | no | | failed\_d2c\_twin\_read\_rate\_time\_aggregator | Monitor aggregator for IoT Hub failed d2c twin read [available values: min, max, sum or avg] | string | `"min"` | no | | failed\_d2c\_twin\_read\_rate\_timeframe | 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`] | string | `"last_5m"` | no | | failed\_d2c\_twin\_update\_rate\_enabled | Flag to enable IoT Hub failed d2c twin update monitor | string | `"true"` | no | -| failed\_d2c\_twin\_update\_rate\_extra\_tags | Extra tags for IoT Hub failed d2c twin update monitor | list | `[]` | no | +| failed\_d2c\_twin\_update\_rate\_extra\_tags | Extra tags for IoT Hub failed d2c twin update monitor | list(string) | `[]` | no | | failed\_d2c\_twin\_update\_rate\_message | Custom message for IoT Hub failed d2c twin update monitor | string | `""` | no | | failed\_d2c\_twin\_update\_rate\_threshold\_critical | D2C Twin Update Failed rate limit (critical threshold) | string | `"90"` | no | | failed\_d2c\_twin\_update\_rate\_threshold\_warning | D2C Twin Update Failed rate limit (warning threshold) | string | `"50"` | no | | failed\_d2c\_twin\_update\_rate\_time\_aggregator | Monitor aggregator for IoT Hub failed d2c twin update [available values: min, max, sum or avg] | string | `"min"` | no | | failed\_d2c\_twin\_update\_rate\_timeframe | 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`] | string | `"last_5m"` | no | | failed\_jobs\_rate\_enabled | Flag to enable IoT Hub failed jobs monitor | string | `"true"` | no | -| failed\_jobs\_rate\_extra\_tags | Extra tags for IoT Hub failed jobs monitor | list | `[]` | no | +| failed\_jobs\_rate\_extra\_tags | Extra tags for IoT Hub failed jobs monitor | list(string) | `[]` | no | | failed\_jobs\_rate\_message | Custom message for IoT Hub failed jobs monitor | string | `""` | no | | failed\_jobs\_rate\_threshold\_critical | Jobs Failed rate limit (critical threshold) | string | `"90"` | no | | failed\_jobs\_rate\_threshold\_warning | Jobs Failed rate limit (warning threshold) | string | `"50"` | no | | failed\_jobs\_rate\_time\_aggregator | Monitor aggregator for IoT Hub failed jobs [available values: min, max, sum or avg] | string | `"min"` | no | | failed\_jobs\_rate\_timeframe | 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`] | string | `"last_5m"` | no | | failed\_listjobs\_rate\_enabled | Flag to enable IoT Hub failed list jobs monitor | string | `"true"` | no | -| failed\_listjobs\_rate\_extra\_tags | Extra tags for IoT Hub failed list jobs monitor | list | `[]` | no | +| failed\_listjobs\_rate\_extra\_tags | Extra tags for IoT Hub failed list jobs monitor | list(string) | `[]` | no | | failed\_listjobs\_rate\_message | Custom message for IoT Hub failed list jobs monitor | string | `""` | no | | failed\_listjobs\_rate\_threshold\_critical | ListJobs Failed rate limit (critical threshold) | string | `"90"` | no | | failed\_listjobs\_rate\_threshold\_warning | ListJobs Failed rate limit (warning threshold) | string | `"50"` | no | | failed\_listjobs\_rate\_time\_aggregator | Monitor aggregator for IoT Hub failed list jobs [available values: min, max, sum or avg] | string | `"min"` | no | | failed\_listjobs\_rate\_timeframe | 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`] | string | `"last_5m"` | no | | failed\_queryjobs\_rate\_enabled | Flag to enable IoT Hub failed query jobs monitor | string | `"true"` | no | -| failed\_queryjobs\_rate\_extra\_tags | Extra tags for IoT Hub failed query jobs monitor | list | `[]` | no | +| failed\_queryjobs\_rate\_extra\_tags | Extra tags for IoT Hub failed query jobs monitor | list(string) | `[]` | no | | failed\_queryjobs\_rate\_message | Custom message for IoT Hub failed query jobs monitor | string | `""` | no | | failed\_queryjobs\_rate\_threshold\_critical | QueryJobs Failed rate limit (critical threshold) | string | `"90"` | no | | failed\_queryjobs\_rate\_threshold\_warning | QueryJobs Failed rate limit (warning threshold) | string | `"50"` | no | @@ -104,7 +104,7 @@ Creates DataDog monitors with the following checks: | filter\_tags\_custom\_excluded | Tags excluded for custom filtering when filter_tags_use_defaults is false | string | `""` | no | | filter\_tags\_use\_defaults | Use default filter tags convention | string | `"true"` | no | | invalid\_d2c\_telemetry\_egress\_enabled | Flag to enable IoT Hub invalid d2c telemetry monitor | string | `"true"` | no | -| invalid\_d2c\_telemetry\_egress\_extra\_tags | Extra tags for IoT Hub invalid d2c telemetry monitor | list | `[]` | no | +| invalid\_d2c\_telemetry\_egress\_extra\_tags | Extra tags for IoT Hub invalid d2c telemetry monitor | list(string) | `[]` | no | | invalid\_d2c\_telemetry\_egress\_message | Custom message for IoT Hub invalid d2c telemetry monitor | string | `""` | no | | invalid\_d2c\_telemetry\_egress\_rate\_threshold\_critical | D2C Telemetry Invalid limit (critical threshold) | string | `"90"` | no | | invalid\_d2c\_telemetry\_egress\_rate\_threshold\_warning | D2C Telemetry Invalid limit (warning threshold) | string | `"50"` | no | @@ -113,7 +113,7 @@ Creates DataDog monitors with the following checks: | message | Message sent when an alert is triggered | string | n/a | yes | | new\_host\_delay | Delay in seconds before monitor new resource | string | `"300"` | no | | orphaned\_d2c\_telemetry\_egress\_enabled | Flag to enable IoT Hub orphaned d2c telemetry monitor | string | `"true"` | no | -| orphaned\_d2c\_telemetry\_egress\_extra\_tags | Extra tags for IoT Hub orphaned d2c telemetry monitor | list | `[]` | no | +| orphaned\_d2c\_telemetry\_egress\_extra\_tags | Extra tags for IoT Hub orphaned d2c telemetry monitor | list(string) | `[]` | no | | orphaned\_d2c\_telemetry\_egress\_message | Custom message for IoT Hub orphaned d2c telemetry monitor | string | `""` | no | | orphaned\_d2c\_telemetry\_egress\_rate\_threshold\_critical | D2C Telemetry Orphaned limit (critical threshold) | string | `"90"` | no | | orphaned\_d2c\_telemetry\_egress\_rate\_threshold\_warning | D2C Telemetry Orphaned limit (warning threshold) | string | `"50"` | no | @@ -121,16 +121,16 @@ Creates DataDog monitors with the following checks: | orphaned\_d2c\_telemetry\_egress\_timeframe | 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`] | string | `"last_5m"` | no | | prefix\_slug | Prefix string to prepend between brackets on every monitors names | string | `""` | no | | status\_enabled | Flag to enable IoT Hub status monitor | string | `"true"` | no | -| status\_extra\_tags | Extra tags for IoT Hub status monitor | list | `[]` | no | +| status\_extra\_tags | Extra tags for IoT Hub status monitor | list(string) | `[]` | no | | status\_message | Custom message for IoT Hub status monitor | string | `""` | no | | status\_time\_aggregator | Monitor aggregator for IoT Hub status [available values: min, max, sum or avg] | string | `"max"` | no | | status\_timeframe | 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`] | string | `"last_5m"` | no | | too\_many\_d2c\_telemetry\_ingress\_nosent\_enabled | Flag to enable IoT Hub unsent d2c telemetry monitor | string | `"true"` | no | -| too\_many\_d2c\_telemetry\_ingress\_nosent\_extra\_tags | Extra tags for IoT Hub unsent d2c telemetry monitor | list | `[]` | no | +| too\_many\_d2c\_telemetry\_ingress\_nosent\_extra\_tags | Extra tags for IoT Hub unsent d2c telemetry monitor | list(string) | `[]` | no | | too\_many\_d2c\_telemetry\_ingress\_nosent\_message | Custom message for IoT Hub unsent d2c telemetry monitor | string | `""` | no | | too\_many\_d2c\_telemetry\_ingress\_nosent\_timeframe | 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`] | string | `"last_5m"` | no | | total\_devices\_enabled | Flag to enable IoT Hub total devices monitor | string | `"true"` | no | -| total\_devices\_extra\_tags | Extra tags for IoT Hub total devices monitor | list | `[]` | no | +| total\_devices\_extra\_tags | Extra tags for IoT Hub total devices monitor | list(string) | `[]` | no | | total\_devices\_message | Custom message for IoT Hub total devices monitor | string | `""` | no | | total\_devices\_time\_aggregator | Monitor aggregator for IoT Hub total devices [available values: min, max, sum or avg] | string | `"min"` | no | | total\_devices\_timeframe | 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`] | string | `"last_5m"` | no | 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..ed1b3ee 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 } + 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 = 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_jobs_rate_extra_tags}"] + tags = concat(["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}" + 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)}" + 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 } + 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 = 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 = concat(["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}" + 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)}" + 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 } + 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 = 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 = concat(["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}" + 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)}" + 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 } + 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 = 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 = concat(["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}" + 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)}" + 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 } + 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 = 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 = concat(["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}" + 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)}" + 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 } + 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 = 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_update_rate_extra_tags}"] + tags = concat(["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 } + 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 = 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_read_rate_extra_tags}"] + tags = concat(["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}" + 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)}" + 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 } + 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 = 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 = concat(["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}" + 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)}" + 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 } + 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 = 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 = concat(["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}" + 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)}" + 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 } + 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 = 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.orphaned_d2c_telemetry_egress_extra_tags}"] + tags = concat(["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 } + 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 = 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.invalid_d2c_telemetry_egress_extra_tags}"] + tags = concat(["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}" + 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)}" + message = coalesce(var.too_many_d2c_telemetry_ingress_nosent_message, var.message) + type = "query alert" query = < 0 - EOQ - - type = "query alert" +EOQ + 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 = 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 = concat(["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/keyvault/README.md b/cloud/azure/keyvault/README.md index 9aa83a0..6da9e4d 100644 --- a/cloud/azure/keyvault/README.md +++ b/cloud/azure/keyvault/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-cloud-azure-keyvault" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//cloud/azure/keyvault?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -25,14 +25,14 @@ Creates DataDog monitors with the following checks: | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| | api\_latency\_enabled | Flag to enable Key Vault API latency monitor | string | `"true"` | no | -| api\_latency\_extra\_tags | Extra tags for Key Vault API latency monitor | list | `[]` | no | +| api\_latency\_extra\_tags | Extra tags for Key Vault API latency monitor | list(string) | `[]` | no | | api\_latency\_message | Custom message for Key Vault API latency monitor | string | `""` | no | | api\_latency\_threshold\_critical | Critical threshold for Key Vault API latency rate | string | `"100"` | no | | api\_latency\_threshold\_warning | Warning threshold for Key Vault API latency rate | string | `"80"` | no | | api\_latency\_time\_aggregator | Monitor aggregator for Key Vault API latency [available values: min, max or avg] | string | `"min"` | no | | api\_latency\_timeframe | Monitor timeframe for Key Vault API latency [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_5m"` | no | | api\_result\_enabled | Flag to enable Key Vault API result monitor | string | `"true"` | no | -| api\_result\_extra\_tags | Extra tags for Key Vault API result monitor | list | `[]` | no | +| api\_result\_extra\_tags | Extra tags for Key Vault API result monitor | list(string) | `[]` | no | | api\_result\_message | Custom message for Key Vault API result monitor | string | `""` | no | | api\_result\_threshold\_critical | Critical threshold for Key Vault API result rate | string | `"10"` | no | | api\_result\_threshold\_warning | Warning threshold for Key Vault API result rate | string | `"30"` | no | @@ -47,7 +47,7 @@ Creates DataDog monitors with the following checks: | new\_host\_delay | Delay in seconds before monitor new resource | string | `"300"` | no | | prefix\_slug | Prefix string to prepend between brackets on every monitors names | string | `""` | no | | status\_enabled | Flag to enable Key Vault status monitor | string | `"true"` | no | -| status\_extra\_tags | Extra tags for Key Vault status monitor | list | `[]` | no | +| status\_extra\_tags | Extra tags for Key Vault status monitor | list(string) | `[]` | no | | status\_message | Custom message for Key Vault status monitor | string | `""` | no | | status\_time\_aggregator | Monitor aggregator for Key Vault status [available values: min, max or avg] | string | `"max"` | no | | status\_timeframe | Monitor timeframe for Key Vault status [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_5m"` | no | 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..d814756 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}" + thresholds = { + critical = var.api_latency_threshold_critical + warning = var.api_latency_threshold_warning } - type = "metric alert" - + 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:azure", "resource:keyvault", "team:claranet", "created-by:terraform", "${var.api_latency_extra_tags}"] + tags = concat(["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/load-balancer/README.md b/cloud/azure/load-balancer/README.md index 27cd5a1..3933000 100644 --- a/cloud/azure/load-balancer/README.md +++ b/cloud/azure/load-balancer/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-cloud-azure-load-balancer" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//cloud/azure/load-balancer?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -31,7 +31,7 @@ Creates DataDog monitors with the following checks: | new\_host\_delay | Delay in seconds before monitor new resource | string | `"300"` | no | | prefix\_slug | Prefix string to prepend between brackets on every monitors names | string | `""` | no | | status\_enabled | Flag to enable Load Balancer status monitor | string | `"true"` | no | -| status\_extra\_tags | Extra tags for Load Balancer status monitor | list | `[]` | no | +| status\_extra\_tags | Extra tags for Load Balancer status monitor | list(string) | `[]` | no | | status\_message | Custom message for Load Balancer status monitor | string | `""` | no | | status\_time\_aggregator | Monitor aggregator for Load Balancer status [available values: min, max or avg] | string | `"max"` | no | | status\_timeframe | Monitor timeframe for Load Balancer status [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_5m"` | no | 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..a782a31 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 } + 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:azure", "resource:mysql", "team:claranet", "created-by:terraform", "${var.cpu_usage_extra_tags}"] + tags = concat(["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}" + 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)}" + 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 } + 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:azure", "resource:mysql", "team:claranet", "created-by:terraform", "${var.io_consumption_extra_tags}"] + tags = concat(["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}" + 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)}" + 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 } + 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:azure", "resource:mysql", "team:claranet", "created-by:terraform", "${var.memory_usage_extra_tags}"] + tags = concat(["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/postgresql/README.md b/cloud/azure/postgresql/README.md index f52a20a..daccdee 100644 --- a/cloud/azure/postgresql/README.md +++ b/cloud/azure/postgresql/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-cloud-azure-postgresql" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//cloud/azure/postgresql?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -27,7 +27,7 @@ Creates DataDog monitors with the following checks: | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| | cpu\_usage\_enabled | Flag to enable PostgreSQL status monitor | string | `"true"` | no | -| cpu\_usage\_extra\_tags | Extra tags for PostgreSQL status monitor | list | `[]` | no | +| cpu\_usage\_extra\_tags | Extra tags for PostgreSQL status monitor | list(string) | `[]` | no | | cpu\_usage\_message | Custom message for PostgreSQL CPU monitor | string | `""` | no | | cpu\_usage\_threshold\_critical | PostgreSQL CPU usage in percent (critical threshold) | string | `"90"` | no | | cpu\_usage\_threshold\_warning | PostgreSQL CPU usage in percent (warning threshold) | string | `"80"` | no | @@ -38,21 +38,21 @@ Creates DataDog monitors with the following checks: | filter\_tags\_custom | Tags used for custom filtering when filter_tags_use_defaults is false | string | `"*"` | no | | filter\_tags\_use\_defaults | Use default filter tags convention | string | `"true"` | no | | free\_storage\_enabled | Flag to enable PostgreSQL status monitor | string | `"true"` | no | -| free\_storage\_extra\_tags | Extra tags for PostgreSQL status monitor | list | `[]` | no | +| free\_storage\_extra\_tags | Extra tags for PostgreSQL status monitor | list(string) | `[]` | no | | free\_storage\_message | Custom message for PostgreSQL Free Storage monitor | string | `""` | no | | free\_storage\_threshold\_critical | PostgreSQL Free Storage remaining in percent (critical threshold) | string | `"10"` | no | | free\_storage\_threshold\_warning | PostgreSQL Free Storage remaining in percent (warning threshold) | string | `"20"` | no | | free\_storage\_time\_aggregator | Monitor aggregator for PostgreSQL Free Storage [available values: min, max or avg] | string | `"min"` | no | | free\_storage\_timeframe | 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`] | string | `"last_15m"` | no | | io\_consumption\_enabled | Flag to enable PostgreSQL status monitor | string | `"true"` | no | -| io\_consumption\_extra\_tags | Extra tags for PostgreSQL status monitor | list | `[]` | no | +| io\_consumption\_extra\_tags | Extra tags for PostgreSQL status monitor | list(string) | `[]` | no | | io\_consumption\_message | Custom message for PostgreSQL IO consumption monitor | string | `""` | no | | io\_consumption\_threshold\_critical | PostgreSQL IO consumption in percent (critical threshold) | string | `"90"` | no | | io\_consumption\_threshold\_warning | PostgreSQL IO consumption in percent (warning threshold) | string | `"80"` | no | | io\_consumption\_time\_aggregator | Monitor aggregator for PostgreSQL IO consumption [available values: min, max or avg] | string | `"min"` | no | | io\_consumption\_timeframe | 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`] | string | `"last_15m"` | no | | memory\_usage\_enabled | Flag to enable PostgreSQL status monitor | string | `"true"` | no | -| memory\_usage\_extra\_tags | Extra tags for PostgreSQL status monitor | list | `[]` | no | +| memory\_usage\_extra\_tags | Extra tags for PostgreSQL status monitor | list(string) | `[]` | no | | memory\_usage\_message | Custom message for PostgreSQL memory monitor | string | `""` | no | | memory\_usage\_threshold\_critical | PostgreSQL memory usage in percent (critical threshold) | string | `"90"` | no | | memory\_usage\_threshold\_warning | PostgreSQL memory usage in percent (warning threshold) | string | `"80"` | no | @@ -61,7 +61,7 @@ Creates DataDog monitors with the following checks: | message | Message sent when an alert is triggered | string | n/a | yes | | new\_host\_delay | Delay in seconds before monitor new resource | string | `"300"` | no | | no\_connection\_enabled | Flag to enable PostgreSQL status monitor | string | `"true"` | no | -| no\_connection\_extra\_tags | Extra tags for PostgreSQL status monitor | list | `[]` | no | +| no\_connection\_extra\_tags | Extra tags for PostgreSQL status monitor | list(string) | `[]` | no | | no\_connection\_message | Custom message for PostgreSQL no connection monitor | string | `""` | no | | no\_connection\_time\_aggregator | Monitor aggregator for PostgreSQL no connection [available values: min, max or avg] | string | `"min"` | no | | no\_connection\_timeframe | 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`] | string | `"last_5m"` | no | 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..97fe59e 100644 --- a/cloud/azure/postgresql/monitors-postegresql.tf +++ b/cloud/azure/postgresql/monitors-postegresql.tf @@ -1,149 +1,145 @@ 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 } + 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:azure", "resource:postgresql", "team:claranet", "created-by:terraform", "${var.cpu_usage_extra_tags}"] + tags = concat(["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}" + 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)}" + 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 } + 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:azure", "resource:postgresql", "team:claranet", "created-by:terraform", "${var.io_consumption_extra_tags}"] + tags = concat(["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 } + 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:azure", "resource:postgresql", "team:claranet", "created-by:terraform", "${var.memory_usage_extra_tags}"] + tags = concat(["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/redis/README.md b/cloud/azure/redis/README.md index a19fabe..b8b8ef9 100644 --- a/cloud/azure/redis/README.md +++ b/cloud/azure/redis/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-cloud-azure-redis" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//cloud/azure/redis?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -28,7 +28,7 @@ Creates DataDog monitors with the following checks: | environment | Architecture environment | string | n/a | yes | | evaluation\_delay | Delay in seconds for the metric evaluation | string | `"900"` | no | | evictedkeys\_limit\_enabled | Flag to enable Redis evicted keys monitor | string | `"true"` | no | -| evictedkeys\_limit\_extra\_tags | Extra tags for Redis evicted keys monitor | list | `[]` | no | +| evictedkeys\_limit\_extra\_tags | Extra tags for Redis evicted keys monitor | list(string) | `[]` | no | | evictedkeys\_limit\_message | Custom message for Redis evicted keys monitor | string | `""` | no | | evictedkeys\_limit\_threshold\_critical | Evicted keys limit (critical threshold) | string | `"100"` | no | | evictedkeys\_limit\_threshold\_warning | Evicted keys limit (warning threshold) | string | `"0"` | no | @@ -40,7 +40,7 @@ Creates DataDog monitors with the following checks: | message | Message sent when a Redis monitor is triggered | string | n/a | yes | | new\_host\_delay | Delay in seconds before monitor new resource | string | `"300"` | no | | percent\_processor\_time\_enabled | Flag to enable Redis processor monitor | string | `"true"` | no | -| percent\_processor\_time\_extra\_tags | Extra tags for Redis processor monitor | list | `[]` | no | +| percent\_processor\_time\_extra\_tags | Extra tags for Redis processor monitor | list(string) | `[]` | no | | percent\_processor\_time\_message | Custom message for Redis processor monitor | string | `""` | no | | percent\_processor\_time\_threshold\_critical | Processor time percent (critical threshold) | string | `"80"` | no | | percent\_processor\_time\_threshold\_warning | Processor time percent (warning threshold) | string | `"60"` | no | @@ -48,14 +48,14 @@ Creates DataDog monitors with the following checks: | percent\_processor\_time\_timeframe | Monitor timeframe for Redis processor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_5m"` | no | | prefix\_slug | Prefix string to prepend between brackets on every monitors names | string | `""` | no | | server\_load\_rate\_enabled | Flag to enable Redis server load monitor | string | `"true"` | no | -| server\_load\_rate\_extra\_tags | Extra tags for Redis server load monitor | list | `[]` | no | +| server\_load\_rate\_extra\_tags | Extra tags for Redis server load monitor | list(string) | `[]` | no | | server\_load\_rate\_message | Custom message for Redis server load monitor | string | `""` | no | | server\_load\_rate\_threshold\_critical | Server CPU load rate (critical threshold) | string | `"90"` | no | | server\_load\_rate\_threshold\_warning | Server CPU load rate (warning threshold) | string | `"70"` | no | | server\_load\_rate\_time\_aggregator | Monitor aggregator for Redis server load [available values: min, max or avg] | string | `"min"` | no | | server\_load\_rate\_timeframe | 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`] | string | `"last_5m"` | no | | status\_enabled | Flag to enable Redis status monitor | string | `"true"` | no | -| status\_extra\_tags | Extra tags for Redis status monitor | list | `[]` | no | +| status\_extra\_tags | Extra tags for Redis status monitor | list(string) | `[]` | no | | status\_message | Custom message for Redis status monitor | string | `""` | no | | status\_time\_aggregator | Monitor aggregator for Redis status [available values: min, max or avg] | string | `"max"` | no | | status\_timeframe | Monitor timeframe for Redis status [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_5m"` | no | 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..d353b62 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 } + 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:azure", "resource:redis", "team:claranet", "created-by:terraform", "${var.evictedkeys_limit_extra_tags}"] + tags = concat(["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}" + 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)}" + 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 } + 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:azure", "resource:redis", "team:claranet", "created-by:terraform", "${var.percent_processor_time_extra_tags}"] + tags = concat(["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}" + 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)}" + 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 } + 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:azure", "resource:redis", "team:claranet", "created-by:terraform", "${var.server_load_rate_extra_tags}"] + tags = concat(["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/serverfarms/README.md b/cloud/azure/serverfarms/README.md index 0f68f6f..15a4e7c 100644 --- a/cloud/azure/serverfarms/README.md +++ b/cloud/azure/serverfarms/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-cloud-azure-serverfarms" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//cloud/azure/serverfarms?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -25,7 +25,7 @@ Creates DataDog monitors with the following checks: | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| | cpu\_percentage\_enabled | Flag to enable the serverfarms cpu_percentage monitor | string | `"true"` | no | -| cpu\_percentage\_extra\_tags | Extra tags for serverfarms cpu_percentage monitor | list | `[]` | no | +| cpu\_percentage\_extra\_tags | Extra tags for serverfarms cpu_percentage monitor | list(string) | `[]` | no | | cpu\_percentage\_message | Custom message for serverfarm cpu_percentage monitor | string | `""` | no | | cpu\_percentage\_threshold\_critical | CPU percentage (critical threshold) | string | `"95"` | no | | cpu\_percentage\_threshold\_warning | CPU percentage (warning threshold) | string | `"90"` | no | @@ -36,7 +36,7 @@ Creates DataDog monitors with the following checks: | filter\_tags\_custom | Tags used for custom filtering when filter_tags_use_defaults is false | string | `"*"` | no | | filter\_tags\_use\_defaults | Use default filter tags convention | string | `"true"` | no | | memory\_percentage\_enabled | Flag to enable the serverfarms memory_percentage monitor | string | `"true"` | no | -| memory\_percentage\_extra\_tags | Extra tags for serverfarms memory_percentage monitor | list | `[]` | no | +| memory\_percentage\_extra\_tags | Extra tags for serverfarms memory_percentage monitor | list(string) | `[]` | no | | memory\_percentage\_message | Custom message for serverfarm memory_percentage monitor | string | `""` | no | | memory\_percentage\_threshold\_critical | Memory percentage (critical threshold) | string | `"95"` | no | | memory\_percentage\_threshold\_warning | Memory percentage (warning threshold) | string | `"90"` | no | @@ -46,7 +46,7 @@ Creates DataDog monitors with the following checks: | new\_host\_delay | Delay in seconds before monitor new resource | string | `"300"` | no | | prefix\_slug | Prefix string to prepend between brackets on every monitors names | string | `""` | no | | status\_enabled | Flag to enable the serverfarms status monitor | string | `"true"` | no | -| status\_extra\_tags | Extra tags for serverfarms status monitor | list | `[]` | no | +| status\_extra\_tags | Extra tags for serverfarms status monitor | list(string) | `[]` | no | | status\_message | Custom message for serverfarm status monitor | string | `""` | no | | status\_time\_aggregator | Monitor aggregator for serverfarms status [available values: min, max or avg] | string | `"min"` | no | | status\_timeframe | Monitor timeframe for serverfarms status [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_5m"` | no | 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..493f2a9 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 } + 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:azure", "resource:serverfarms", "team:claranet", "created-by:terraform", "${var.cpu_percentage_extra_tags}"] + tags = concat(["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}" + 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)}" + 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}" + thresholds = { + warning = var.memory_percentage_threshold_warning + critical = var.memory_percentage_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:azure", "resource:serverfarms", "team:claranet", "created-by:terraform", "${var.memory_percentage_extra_tags}"] + tags = concat(["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/servicebus/README.md b/cloud/azure/servicebus/README.md index 7e754f0..9021cc2 100644 --- a/cloud/azure/servicebus/README.md +++ b/cloud/azure/servicebus/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-cloud-azure-servicebus" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//cloud/azure/servicebus?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -32,23 +32,26 @@ Creates DataDog monitors with the following checks: | filter\_tags\_use\_defaults | Use default filter tags convention | string | `"true"` | no | | message | Message sent when an alert is triggered | string | n/a | yes | | new\_host\_delay | Delay in seconds before monitor new resource | string | `"300"` | no | -| no\_active\_connections\_enabled | Flag to enable Service Bus status monitor | string | `"true"` | no | -| no\_active\_connections\_message | Custom message for Service Bus status monitor | string | `""` | no | -| no\_active\_connections\_time\_aggregator | Monitor aggregator for Service Bus status [available values: min, max or avg] | string | `"max"` | no | -| no\_active\_connections\_timeframe | 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`] | string | `"last_5m"` | no | +| no\_active\_connections\_enabled | Flag to enable Service Bus no active connections monitor | string | `"true"` | no | +| no\_active\_connections\_extra\_tags | Extra tags for Service Bus no active connections monitor | list(string) | `[]` | no | +| no\_active\_connections\_message | Custom message for Service Bus no active connections monitor | string | `""` | no | +| no\_active\_connections\_time\_aggregator | Monitor aggregator for Service Bus no active connections [available values: min, max or avg] | string | `"max"` | no | +| no\_active\_connections\_timeframe | Monitor timeframe for Service Bus no active connections [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_5m"` | no | | prefix\_slug | Prefix string to prepend between brackets on every monitors names | string | `""` | no | | server\_errors\_enabled | Flag to enable Service Bus server errors monitor | string | `"true"` | no | +| server\_errors\_extra\_tags | Extra tags for Service Bus server errors monitor | list(string) | `[]` | no | | server\_errors\_message | Custom message for Service Bus server errors monitor | string | `""` | no | | server\_errors\_threshold\_critical | Critical threshold for Service Bus server errors monitor | string | `"90"` | no | | server\_errors\_threshold\_warning | Warning threshold for Service Bus server errors monitor | string | `"50"` | no | | server\_errors\_time\_aggregator | Monitor aggregator for Service Bus server errors [available values: min, max or avg] | string | `"min"` | no | | server\_errors\_timeframe | 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`] | string | `"last_5m"` | no | | status\_enabled | Flag to enable Service Bus status monitor | string | `"true"` | no | -| status\_extra\_tags | Extra tags for Service Bus status monitor | list | `[]` | no | +| status\_extra\_tags | Extra tags for Service Bus status monitor | list(string) | `[]` | no | | status\_message | Custom message for Service Bus status monitor | string | `""` | no | | status\_time\_aggregator | Monitor aggregator for Service Bus status [available values: min, max or avg] | string | `"max"` | no | | status\_timeframe | 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`] | string | `"last_5m"` | no | | user\_errors\_enabled | Flag to enable Service Bus user errors monitor | string | `"true"` | no | +| user\_errors\_extra\_tags | Extra tags for Service Bus user errors monitor | list(string) | `[]` | no | | user\_errors\_message | Custom message for Service Bus user errors monitor | string | `""` | no | | user\_errors\_threshold\_critical | Critical threshold for Service Bus user errors monitor | string | `"90"` | no | | user\_errors\_threshold\_warning | Warning threshold for Service Bus user errors monitor | string | `"50"` | no | diff --git a/cloud/azure/servicebus/inputs.tf b/cloud/azure/servicebus/inputs.tf index 6b69823..2f5202c 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" } @@ -70,50 +70,62 @@ variable "status_timeframe" { } variable "no_active_connections_enabled" { - description = "Flag to enable Service Bus status monitor" - type = "string" + description = "Flag to enable Service Bus no active connections monitor" + type = string default = "true" } +variable "no_active_connections_extra_tags" { + description = "Extra tags for Service Bus no active connections monitor" + type = list(string) + default = [] +} + variable "no_active_connections_message" { - description = "Custom message for Service Bus status monitor" - type = "string" + description = "Custom message for Service Bus no active connections monitor" + type = string default = "" } variable "no_active_connections_time_aggregator" { - description = "Monitor aggregator for Service Bus status [available values: min, max or avg]" - type = "string" + description = "Monitor aggregator for Service Bus no active connections [available values: min, max or avg]" + 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" + description = "Monitor timeframe for Service Bus no active connections [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" + 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_extra_tags" { + description = "Extra tags for Service Bus server errors monitor" + type = list(string) + default = [] +} + 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 +141,31 @@ 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_extra_tags" { + description = "Extra tags for Service Bus user errors monitor" + type = list(string) + default = [] +} + 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 +178,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..31e810c 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 } + 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}", "resource:servicebus", "team:azure", "provider:azure"] + tags = concat(["env:${var.environment}", "type:cloud", "provider:azure", "resource:servicebus", "team:claranet", "created-by:terraform"], var.user_errors_extra_tags) } 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)}" + message = coalesce(var.server_errors_message, var.message) + type = "query alert" - 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 } + 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}", "resource:servicebus", "team:azure", "provider:azure"] + tags = concat(["env:${var.environment}", "type:cloud", "provider:azure", "resource:servicebus", "team:claranet", "created-by:terraform"], var.server_errors_extra_tags) } + 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/sql-database/README.md b/cloud/azure/sql-database/README.md index ff2a933..585628f 100644 --- a/cloud/azure/sql-database/README.md +++ b/cloud/azure/sql-database/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-cloud-azure-sql-database" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//cloud/azure/sql-database?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -27,26 +27,26 @@ Creates DataDog monitors with the following checks: | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| | cpu\_enabled | Flag to enable SQL CPU monitor | string | `"true"` | no | -| cpu\_extra\_tags | Extra tags for SQL CPU monitor | list | `[]` | no | +| cpu\_extra\_tags | Extra tags for SQL CPU monitor | list(string) | `[]` | no | | cpu\_message | Custom message for SQL CPU monitor | string | `""` | no | | cpu\_threshold\_critical | CPU usage in percent (critical threshold) | string | `"90"` | no | | cpu\_threshold\_warning | CPU usage in percent (warning threshold) | string | `"80"` | no | | cpu\_time\_aggregator | Monitor aggregator for SQL CPU [available values: min, max or avg] | string | `"min"` | no | | cpu\_timeframe | Monitor timeframe for SQL CPU [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_15m"` | no | | deadlock\_enabled | Flag to enable SQL Deadlock monitor | string | `"true"` | no | -| deadlock\_extra\_tags | Extra tags for SQL Deadlock monitor | list | `[]` | no | +| deadlock\_extra\_tags | Extra tags for SQL Deadlock monitor | list(string) | `[]` | no | | deadlock\_message | Custom message for SQL Deadlock monitor | string | `""` | no | | deadlock\_threshold\_critical | Amount of Deadlocks (critical threshold) | string | `"1"` | no | | deadlock\_timeframe | Monitor timeframe for SQL Deadlock [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_5m"` | no | | diskspace\_enabled | Flag to enable SQL disk space monitor | string | `"true"` | no | -| diskspace\_extra\_tags | Extra tags for SQL disk space monitor | list | `[]` | no | +| diskspace\_extra\_tags | Extra tags for SQL disk space monitor | list(string) | `[]` | no | | diskspace\_message | Custom message for SQL disk space monitor | string | `""` | no | | diskspace\_threshold\_critical | Disk space used in percent (critical threshold) | string | `"90"` | no | | diskspace\_threshold\_warning | Disk space used in percent (warning threshold) | string | `"80"` | no | | diskspace\_time\_aggregator | Monitor aggregator for SQL disk space [available values: min, max or avg] | string | `"max"` | no | | diskspace\_timeframe | 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`] | string | `"last_15m"` | no | | dtu\_enabled | Flag to enable SQL DTU monitor | string | `"true"` | no | -| dtu\_extra\_tags | Extra tags for SQL DTU monitor | list | `[]` | no | +| dtu\_extra\_tags | Extra tags for SQL DTU monitor | list(string) | `[]` | no | | dtu\_message | Custom message for SQL DTU monitor | string | `""` | no | | dtu\_threshold\_critical | Amount of DTU used (critical threshold) | string | `"90"` | no | | dtu\_threshold\_warning | Amount of DTU used (warning threshold) | string | `"85"` | no | @@ -61,7 +61,7 @@ Creates DataDog monitors with the following checks: | new\_host\_delay | Delay in seconds before monitor new resource | string | `"300"` | no | | prefix\_slug | Prefix string to prepend between brackets on every monitors names | string | `""` | no | | status\_enabled | Flag to enable Redis status monitor | string | `"true"` | no | -| status\_extra\_tags | Extra tags for Redis status monitor | list | `[]` | no | +| status\_extra\_tags | Extra tags for Redis status monitor | list(string) | `[]` | no | | status\_message | Custom message for Redis status monitor | string | `""` | no | | status\_time\_aggregator | Monitor aggregator for Redis status [available values: min, max or avg] | string | `"max"` | no | | status\_timeframe | Monitor timeframe for Redis status [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_5m"` | no | 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..36e1d51 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 } + new_host_delay = var.new_host_delay + evaluation_delay = var.evaluation_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 = concat(["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}" + 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)}" + message = coalesce(var.diskspace_message, var.message) + type = "query alert" - 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 } + 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:azure", "resource:sql-database", "team:claranet", "created-by:terraform", "${var.diskspace_extra_tags}"] + tags = concat(["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}" + 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)}" + message = coalesce(var.dtu_message, var.message) + type = "query alert" - 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 } + 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:azure", "resource:sql-database", "team:claranet", "created-by:terraform", "${var.dtu_extra_tags}"] + tags = concat(["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)}" - - type = "query alert" + 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 } + 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 = 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:sql-database", "team:claranet", "created-by:terraform", "${var.deadlock_extra_tags}"] + tags = concat(["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-elasticpool/README.md b/cloud/azure/sql-elasticpool/README.md index c51b049..7e510d8 100644 --- a/cloud/azure/sql-elasticpool/README.md +++ b/cloud/azure/sql-elasticpool/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-cloud-azure-sql-elasticpool" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//cloud/azure/sql-elasticpool?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -25,21 +25,21 @@ Creates DataDog monitors with the following checks: | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| | cpu\_enabled | Flag to enable SQL Elastic Pool CPU monitor | string | `"true"` | no | -| cpu\_extra\_tags | Extra tags for SQL Elastic Pool CPU monitor | list | `[]` | no | +| cpu\_extra\_tags | Extra tags for SQL Elastic Pool CPU monitor | list(string) | `[]` | no | | cpu\_message | Custom message for SQL Elastic Pool CPU monitor | string | `""` | no | | cpu\_threshold\_critical | CPU usage in percent (critical threshold) | string | `"90"` | no | | cpu\_threshold\_warning | CPU usage in percent (warning threshold) | string | `"80"` | no | | cpu\_time\_aggregator | Monitor aggregator for SQL Elastic Pool CPU [available values: min, max or avg] | string | `"min"` | no | | cpu\_timeframe | 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`] | string | `"last_15m"` | no | | diskspace\_enabled | Flag to enable SQL Elastic Pool disk space monitor | string | `"true"` | no | -| diskspace\_extra\_tags | Extra tags for SQL Elastic Pool disk space monitor | list | `[]` | no | +| diskspace\_extra\_tags | Extra tags for SQL Elastic Pool disk space monitor | list(string) | `[]` | no | | diskspace\_message | Custom message for SQL Elastic Pool disk space monitor | string | `""` | no | | diskspace\_threshold\_critical | Disk space used in percent (critical threshold) | string | `"90"` | no | | diskspace\_threshold\_warning | Disk space used in percent (warning threshold) | string | `"80"` | no | | diskspace\_time\_aggregator | Monitor aggregator for SQL Elastic Pool disk space [available values: min, max or avg] | string | `"max"` | no | | diskspace\_timeframe | 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`] | string | `"last_15m"` | no | | dtu\_enabled | Flag to enable SQL Elastic Pool DTU monitor | string | `"true"` | no | -| dtu\_extra\_tags | Extra tags for SQL Elastic Pool DTU monitor | list | `[]` | no | +| dtu\_extra\_tags | Extra tags for SQL Elastic Pool DTU monitor | list(string) | `[]` | no | | dtu\_message | Custom message for SQL Elastic Pool DTU monitor | string | `""` | no | | dtu\_threshold\_critical | Amount of DTU used (critical threshold) | string | `"90"` | no | | dtu\_threshold\_warning | Amount of DTU used (warning threshold) | string | `"85"` | no | 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..72e0f55 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 } + evaluation_delay = var.evaluation_delay + 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:azure", "resource:sql-elasticpool", "team:claranet", "created-by:terraform", "${var.cpu_extra_tags}"] + tags = concat(["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}" + 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" + 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 } + 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:azure", "resource:sql-elasticpool", "team:claranet", "created-by:terraform", "${var.diskspace_extra_tags}"] + tags = concat(["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}" + 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)}" + message = coalesce(var.dtu_message, var.message) + type = "query alert" - 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 } + 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:azure", "resource:sql-elasticpool", "team:claranet", "created-by:terraform", "${var.dtu_extra_tags}"] + tags = concat(["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/storage/README.md b/cloud/azure/storage/README.md index 279dcfb..3a3993f 100644 --- a/cloud/azure/storage/README.md +++ b/cloud/azure/storage/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-cloud-azure-storage" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//cloud/azure/storage?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -31,21 +31,21 @@ Creates DataDog monitors with the following checks: | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| | authorization\_error\_requests\_enabled | Flag to enable Storage authorization errors monitor | string | `"true"` | no | -| authorization\_error\_requests\_extra\_tags | Extra tags for Storage authorization errors monitor | list | `[]` | no | +| authorization\_error\_requests\_extra\_tags | Extra tags for Storage authorization errors monitor | list(string) | `[]` | no | | authorization\_error\_requests\_message | Custom message for Storage authorization errors monitor | string | `""` | no | | authorization\_error\_requests\_threshold\_critical | Maximum acceptable percent of authorization error requests for a storage | string | `"90"` | no | | authorization\_error\_requests\_threshold\_warning | Warning regarding acceptable percent of authorization error requests for a storage | string | `"50"` | no | | authorization\_error\_requests\_time\_aggregator | Monitor aggregator for Storage authorization errors [available values: min, max or avg] | string | `"min"` | no | | authorization\_error\_requests\_timeframe | 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`] | string | `"last_5m"` | no | | availability\_enabled | Flag to enable Storage availability monitor | string | `"true"` | no | -| availability\_extra\_tags | Extra tags for Storage availability monitor | list | `[]` | no | +| availability\_extra\_tags | Extra tags for Storage availability monitor | list(string) | `[]` | no | | availability\_message | Custom message for Storage availability monitor | string | `""` | no | | availability\_threshold\_critical | Minimum acceptable percent of availability for a storage | string | `"50"` | no | | availability\_threshold\_warning | Warning regarding acceptable percent of availability for a storage | string | `"90"` | no | | availability\_time\_aggregator | Monitor aggregator for Storage availability [available values: min, max or avg] | string | `"max"` | no | | availability\_timeframe | Monitor timeframe for Storage availability [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_5m"` | no | | client\_other\_error\_requests\_enabled | Flag to enable Storage other errors monitor | string | `"true"` | no | -| client\_other\_error\_requests\_extra\_tags | Extra tags for Storage other errors monitor | list | `[]` | no | +| client\_other\_error\_requests\_extra\_tags | Extra tags for Storage other errors monitor | list(string) | `[]` | no | | client\_other\_error\_requests\_message | Custom message for Storage other errors monitor | string | `""` | no | | client\_other\_error\_requests\_threshold\_critical | Maximum acceptable percent of client other error requests for a storage | string | `"90"` | no | | client\_other\_error\_requests\_threshold\_warning | Warning regarding acceptable percent of client other error requests for a storage | string | `"50"` | no | @@ -57,7 +57,7 @@ Creates DataDog monitors with the following checks: | filter\_tags\_custom\_excluded | Tags excluded for custom filtering when filter_tags_use_defaults is false | string | `""` | no | | filter\_tags\_use\_defaults | Use default filter tags convention | string | `"true"` | no | | latency\_enabled | Flag to enable Storage latency monitor | string | `"true"` | no | -| latency\_extra\_tags | Extra tags for Storage latency monitor | list | `[]` | no | +| latency\_extra\_tags | Extra tags for Storage latency monitor | list(string) | `[]` | no | | latency\_message | Custom message for Storage latency monitor | string | `""` | no | | latency\_threshold\_critical | Maximum acceptable end to end latency (ms) for a storage | string | `"2000"` | no | | latency\_threshold\_warning | Warning regarding acceptable end to end latency (ms) for a storage | string | `"1000"` | no | @@ -65,7 +65,7 @@ Creates DataDog monitors with the following checks: | latency\_timeframe | Monitor timeframe for Storage latency [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_5m"` | no | | message | Message sent when a Redis monitor is triggered | string | n/a | yes | | network\_error\_requests\_enabled | Flag to enable Storage network errors monitor | string | `"true"` | no | -| network\_error\_requests\_extra\_tags | Extra tags for Storage network errors monitor | list | `[]` | no | +| network\_error\_requests\_extra\_tags | Extra tags for Storage network errors monitor | list(string) | `[]` | no | | network\_error\_requests\_message | Custom message for Storage network errors monitor | string | `""` | no | | network\_error\_requests\_threshold\_critical | Maximum acceptable percent of network error requests for a storage | string | `"90"` | no | | network\_error\_requests\_threshold\_warning | Warning regarding acceptable percent of network error requests for a storage | string | `"50"` | no | @@ -74,28 +74,28 @@ Creates DataDog monitors with the following checks: | new\_host\_delay | Delay in seconds before monitor new resource | string | `"300"` | no | | prefix\_slug | Prefix string to prepend between brackets on every monitors names | string | `""` | no | | server\_other\_error\_requests\_enabled | Flag to enable Storage server other errors monitor | string | `"true"` | no | -| server\_other\_error\_requests\_extra\_tags | Extra tags for Storage server other errors monitor | list | `[]` | no | +| server\_other\_error\_requests\_extra\_tags | Extra tags for Storage server other errors monitor | list(string) | `[]` | no | | server\_other\_error\_requests\_message | Custom message for Storage server other errors monitor | string | `""` | no | | server\_other\_error\_requests\_threshold\_critical | Maximum acceptable percent of server other error requests for a storage | string | `"90"` | no | | server\_other\_error\_requests\_threshold\_warning | Warning regarding acceptable percent of server other error requests for a storage | string | `"50"` | no | | server\_other\_error\_requests\_time\_aggregator | Monitor aggregator for Storage other errors [available values: min, max or avg] | string | `"min"` | no | | server\_other\_error\_requests\_timeframe | 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`] | string | `"last_5m"` | no | | successful\_requests\_enabled | Flag to enable Storage sucessful requests monitor | string | `"true"` | no | -| successful\_requests\_extra\_tags | Extra tags for Storage sucessful requests monitor | list | `[]` | no | +| successful\_requests\_extra\_tags | Extra tags for Storage sucessful requests monitor | list(string) | `[]` | no | | successful\_requests\_message | Custom message for Storage sucessful requests monitor | string | `""` | no | | successful\_requests\_threshold\_critical | Minimum acceptable percent of successful requests for a storage | string | `"10"` | no | | successful\_requests\_threshold\_warning | Warning regarding acceptable percent of successful requests for a storage | string | `"30"` | no | | successful\_requests\_time\_aggregator | Monitor aggregator for Storage sucessful requests [available values: min, max or avg] | string | `"max"` | no | | successful\_requests\_timeframe | 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`] | string | `"last_5m"` | no | | throttling\_error\_requests\_enabled | Flag to enable Storage throttling error monitor | string | `"true"` | no | -| throttling\_error\_requests\_extra\_tags | Extra tags for Storage throttling error monitor | list | `[]` | no | +| throttling\_error\_requests\_extra\_tags | Extra tags for Storage throttling error monitor | list(string) | `[]` | no | | throttling\_error\_requests\_message | Custom message for Storage throttling error monitor | string | `""` | no | | throttling\_error\_requests\_threshold\_critical | Maximum acceptable percent of throttling error requests for a storage | string | `"90"` | no | | throttling\_error\_requests\_threshold\_warning | Warning regarding acceptable percent of throttling error requests for a storage | string | `"50"` | no | | throttling\_error\_requests\_time\_aggregator | Monitor aggregator for Storage throttling errors [available values: min, max or avg] | string | `"min"` | no | | throttling\_error\_requests\_timeframe | 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`] | string | `"last_5m"` | no | | timeout\_error\_requests\_enabled | Flag to enable Storage timeout monitor | string | `"true"` | no | -| timeout\_error\_requests\_extra\_tags | Extra tags for Storage timeout monitor | list | `[]` | no | +| timeout\_error\_requests\_extra\_tags | Extra tags for Storage timeout monitor | list(string) | `[]` | no | | timeout\_error\_requests\_message | Custom message for Storage timeout monitor | string | `""` | no | | timeout\_error\_requests\_threshold\_critical | Maximum acceptable percent of timeout error requests for a storage | string | `"90"` | no | | timeout\_error\_requests\_threshold\_warning | Warning regarding acceptable percent of timeout error requests for a storage | string | `"50"` | no | 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..8b9f3f6 100644 --- a/cloud/azure/storage/monitors-azure-storage.tf +++ b/cloud/azure/storage/monitors-azure-storage.tf @@ -1,269 +1,270 @@ 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" + new_host_delay = var.new_host_delay + evaluation_delay = var.evaluation_delay 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 = concat(["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}" + 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)}" + 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" + new_host_delay = var.new_host_delay + evaluation_delay = var.evaluation_delay 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.timeout_error_requests_extra_tags}"] + tags = concat(["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" + new_host_delay = var.new_host_delay + evaluation_delay = var.evaluation_delay 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.network_error_requests_extra_tags}"] + tags = concat(["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}" + 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)}" + 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" + new_host_delay = var.new_host_delay + evaluation_delay = var.evaluation_delay 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 = concat(["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}" + 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)}" + 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" + new_host_delay = var.new_host_delay + evaluation_delay = var.evaluation_delay 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 = concat(["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}" + 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)}" + 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" + new_host_delay = var.new_host_delay + evaluation_delay = var.evaluation_delay 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.client_other_error_requests_extra_tags}"] + tags = concat(["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" + new_host_delay = var.new_host_delay + evaluation_delay = var.evaluation_delay 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.authorization_error_requests_extra_tags}"] + tags = concat(["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/stream-analytics/README.md b/cloud/azure/stream-analytics/README.md index 8ac4b81..c447a24 100644 --- a/cloud/azure/stream-analytics/README.md +++ b/cloud/azure/stream-analytics/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-cloud-azure-stream-analytics" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//cloud/azure/stream-analytics?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -27,7 +27,7 @@ Creates DataDog monitors with the following checks: | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| | conversion\_errors\_enabled | Flag to enable Stream Analytics conversion errors monitor | string | `"true"` | no | -| conversion\_errors\_extra\_tags | Extra tags for Stream Analytics conversion errors monitor | list | `[]` | no | +| conversion\_errors\_extra\_tags | Extra tags for Stream Analytics conversion errors monitor | list(string) | `[]` | no | | conversion\_errors\_message | Custom message for Stream Analytics conversion errors monitor | string | `""` | no | | conversion\_errors\_threshold\_critical | Conversion errors limit (critical threshold) | string | `"10"` | no | | conversion\_errors\_threshold\_warning | Conversion errors limit (warning threshold) | string | `"0"` | no | @@ -36,7 +36,7 @@ Creates DataDog monitors with the following checks: | environment | Architecture environment | string | n/a | yes | | evaluation\_delay | Delay in seconds for the metric evaluation | string | `"900"` | no | | failed\_function\_requests\_enabled | Flag to enable Stream Analytics failed requests monitor | string | `"true"` | no | -| failed\_function\_requests\_extra\_tags | Extra tags for Stream Analytics failed requests monitor | list | `[]` | no | +| failed\_function\_requests\_extra\_tags | Extra tags for Stream Analytics failed requests monitor | list(string) | `[]` | no | | failed\_function\_requests\_message | Custom message for Stream Analytics failed requests monitor | string | `""` | no | | failed\_function\_requests\_threshold\_critical | Failed Function Request rate limit (critical threshold) | string | `"10"` | no | | failed\_function\_requests\_threshold\_warning | Failed Function Request rate limit (warning threshold) | string | `"0"` | no | @@ -49,19 +49,19 @@ Creates DataDog monitors with the following checks: | new\_host\_delay | Delay in seconds before monitor new resource | string | `"300"` | no | | prefix\_slug | Prefix string to prepend between brackets on every monitors names | string | `""` | no | | runtime\_errors\_enabled | Flag to enable Stream Analytics runtime errors monitor | string | `"true"` | no | -| runtime\_errors\_extra\_tags | Extra tags for Stream Analytics runtime errors monitor | list | `[]` | no | +| runtime\_errors\_extra\_tags | Extra tags for Stream Analytics runtime errors monitor | list(string) | `[]` | no | | runtime\_errors\_message | Custom message for Stream Analytics runtime errors monitor | string | `""` | no | | runtime\_errors\_threshold\_critical | Runtime errors limit (critical threshold) | string | `"10"` | no | | runtime\_errors\_threshold\_warning | Runtime errors limit (warning threshold) | string | `"0"` | no | | runtime\_errors\_time\_aggregator | Monitor aggregator for Stream Analytics runtime errors [available values: min, max or avg] | string | `"min"` | no | | runtime\_errors\_timeframe | 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`] | string | `"last_5m"` | no | | status\_enabled | Flag to enable Stream Analytics status monitor | string | `"true"` | no | -| status\_extra\_tags | Extra tags for Stream Analytics status monitor | list | `[]` | no | +| status\_extra\_tags | Extra tags for Stream Analytics status monitor | list(string) | `[]` | no | | status\_message | Custom message for Stream Analytics status monitor | string | `""` | no | | status\_time\_aggregator | Monitor aggregator for Stream Analytics status [available values: min, max or avg] | string | `"max"` | no | | status\_timeframe | 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`] | string | `"last_5m"` | no | | su\_utilization\_enabled | Flag to enable Stream Analytics utilization monitor | string | `"true"` | no | -| su\_utilization\_extra\_tags | Extra tags for Stream Analytics utilization monitor | list | `[]` | no | +| su\_utilization\_extra\_tags | Extra tags for Stream Analytics utilization monitor | list(string) | `[]` | no | | su\_utilization\_message | Custom message for Stream Analytics utilization monitor | string | `""` | no | | su\_utilization\_threshold\_critical | Streaming Unit utilization rate limit (critical threshold) | string | `"80"` | no | | su\_utilization\_threshold\_warning | Streaming Unit utilization rate limit (warning threshold) | string | `"60"` | no | 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..7095349 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 - - type = "query alert" +EOQ + 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}" - 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 = concat(["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}" + 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)}" + 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 + } + evaluation_delay = var.evaluation_delay + 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 = concat(["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}" + 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)}" + 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 + } + 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 = 1 include_tags = true locked = false require_full_window = false - 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 = concat(["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" + thresholds = { + warning = var.runtime_errors_threshold_warning + critical = var.runtime_errors_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 = 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}" - } - - tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:stream-analytics", "team:claranet", "created-by:terraform", "${var.runtime_errors_extra_tags}"] + tags = concat(["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/virtual-machine/README.md b/cloud/azure/virtual-machine/README.md index a4b4a6e..1980300 100644 --- a/cloud/azure/virtual-machine/README.md +++ b/cloud/azure/virtual-machine/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-cloud-azure-virtual-machine" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//cloud/azure/virtual-machine?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -25,14 +25,14 @@ Creates DataDog monitors with the following checks: | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| | cpu\_remaining\_rate\_enabled | Flag to enable Virtual Machine CPU remaining monitor | string | `"true"` | no | -| cpu\_remaining\_rate\_extra\_tags | Extra tags for Virtual Machine CPU remaining monitor | list | `[]` | no | +| cpu\_remaining\_rate\_extra\_tags | Extra tags for Virtual Machine CPU remaining monitor | list(string) | `[]` | no | | cpu\_remaining\_rate\_message | Custom message for Virtual Machine CPU remaining monitor | string | `""` | no | | cpu\_remaining\_rate\_threshold\_critical | Virtual Machine CPU rate limit (critical threshold) | string | `"15"` | no | | cpu\_remaining\_rate\_threshold\_warning | Virtual Machine CPU rate limit (warning threshold) | string | `"30"` | no | | cpu\_remaining\_rate\_time\_aggregator | Monitor aggregator for Virtual Machine CPU remaining [available values: min, max, sum or avg] | string | `"min"` | no | | cpu\_remaining\_rate\_timeframe | 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`] | string | `"last_5m"` | no | | cpu\_usage\_enabled | Flag to enable Virtual Machine status monitor | string | `"true"` | no | -| cpu\_usage\_extra\_tags | Extra tags for Virtual Machine status monitor | list | `[]` | no | +| cpu\_usage\_extra\_tags | Extra tags for Virtual Machine status monitor | list(string) | `[]` | no | | cpu\_usage\_message | Custom message for Virtual Machine CPU monitor | string | `""` | no | | cpu\_usage\_threshold\_critical | Virtual Machine CPU usage in percent (critical threshold) | string | `"90"` | no | | cpu\_usage\_threshold\_warning | Virtual Machine CPU usage in percent (warning threshold) | string | `"80"` | no | @@ -47,7 +47,7 @@ Creates DataDog monitors with the following checks: | new\_host\_delay | Delay in seconds before monitor new resource | string | `"300"` | no | | prefix\_slug | Prefix string to prepend between brackets on every monitors names | string | `""` | no | | status\_enabled | Flag to enable Virtual Machine status monitor | string | `"true"` | no | -| status\_extra\_tags | Extra tags for Virtual Machine status monitor | list | `[]` | no | +| status\_extra\_tags | Extra tags for Virtual Machine status monitor | list(string) | `[]` | no | | status\_message | Custom message for Virtual Machine status monitor | string | `""` | no | | status\_time\_aggregator | Monitor aggregator for Virtual Machine status [available values: min, max or avg] | string | `"max"` | no | | status\_timeframe | 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`] | string | `"last_5m"` | no | 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..f7f7e12 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 } + 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:azure", "resource:virtualmachine", "team:claranet", "created-by:terraform", "${var.cpu_usage_extra_tags}"] + tags = concat(["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}" + 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)}" + 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 } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay include_tags = true notify_no_data = false require_full_window = false @@ -26,32 +28,31 @@ resource "datadog_monitor" "concurrent_queries" { timeout_h = 0 locked = false - 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 = concat(["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}" + 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" + 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 } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay include_tags = true notify_no_data = false require_full_window = false @@ -60,32 +61,31 @@ resource "datadog_monitor" "execution_time" { timeout_h = 0 locked = false - 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 = concat(["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}" + 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)}" + message = coalesce(var.scanned_bytes_message, var.message) + type = "query alert" - 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 } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay include_tags = true notify_no_data = false require_full_window = false @@ -94,32 +94,31 @@ resource "datadog_monitor" "scanned_bytes" { timeout_h = 0 locked = false - 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 = concat(["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}" + 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)}" + message = coalesce(var.scanned_bytes_billed_message, var.message) + type = "query alert" - 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 } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay include_tags = true notify_no_data = false require_full_window = false @@ -128,32 +127,31 @@ resource "datadog_monitor" "scanned_bytes_billed" { timeout_h = 0 locked = false - 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 = concat(["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)}" - - type = "metric alert" + 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}" + 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 @@ -196,32 +193,31 @@ resource "datadog_monitor" "stored_bytes" { timeout_h = 0 locked = false - 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}"] + tags = concat(["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}" + 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)}" + 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 } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay include_tags = true notify_no_data = false require_full_window = false @@ -230,32 +226,31 @@ resource "datadog_monitor" "table_count" { timeout_h = 0 locked = false - 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 = concat(["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}" + 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)}" + message = coalesce(var.uploaded_bytes_message, var.message) + type = "query alert" - 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 } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay include_tags = true notify_no_data = false require_full_window = false @@ -264,32 +259,31 @@ resource "datadog_monitor" "uploaded_bytes" { timeout_h = 0 locked = false - 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 = concat(["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)}" - - type = "query alert" + 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 } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay include_tags = true notify_no_data = false require_full_window = false @@ -298,8 +292,6 @@ resource "datadog_monitor" "uploaded_bytes_billed" { timeout_h = 0 locked = false - 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 = concat(["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/cloud-sql/common/README.md b/cloud/gcp/cloud-sql/common/README.md index eaff149..96fec35 100644 --- a/cloud/gcp/cloud-sql/common/README.md +++ b/cloud/gcp/cloud-sql/common/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-cloud-gcp-cloud-sql-common" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//cloud/gcp/cloud-sql/common?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -28,18 +28,18 @@ Creates DataDog monitors with the following checks: | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| | cpu\_utilization\_enabled | Flag to enable GCP Cloud SQL CPU Utilization monitor | string | `"true"` | no | -| cpu\_utilization\_extra\_tags | Extra tags for GCP Cloud SQL CPU Utilization monitor | list | `[]` | no | +| cpu\_utilization\_extra\_tags | Extra tags for GCP Cloud SQL CPU Utilization monitor | list(string) | `[]` | no | | cpu\_utilization\_message | Custom message for the CPU Utilization monitor | string | `""` | no | | cpu\_utilization\_threshold\_critical | CPU Utilization in percentage (critical threshold) | string | `"90"` | no | | cpu\_utilization\_threshold\_warning | CPU Utilization in percentage (warning threshold) | string | `"80"` | no | | cpu\_utilization\_time\_aggregator | Time aggregator for the CPU Utilization monitor | string | `"avg"` | no | | cpu\_utilization\_timeframe | Timeframe for the CPU Utilization monitor | string | `"last_15m"` | no | | disk\_utilization\_enabled | Flag to enable GCP Cloud SQL Disk Utilization monitor | string | `"true"` | no | -| disk\_utilization\_extra\_tags | Extra tags for GCP Cloud SQL CPU Utilization monitor | list | `[]` | no | +| disk\_utilization\_extra\_tags | Extra tags for GCP Cloud SQL CPU Utilization monitor | list(string) | `[]` | no | | disk\_utilization\_forecast\_algorithm | Algorithm for the Disk Utilization Forecast monitor | string | `"linear"` | no | | disk\_utilization\_forecast\_deviations | Deviations for the Disk Utilization Forecast monitor | string | `"1"` | no | | disk\_utilization\_forecast\_enabled | Flag to enable GCP Cloud SQL Disk Utilization Forecast monitor | string | `"true"` | no | -| disk\_utilization\_forecast\_extra\_tags | Extra tags for GCP Cloud SQL Disk Utilization Forecast monitor | list | `[]` | no | +| disk\_utilization\_forecast\_extra\_tags | Extra tags for GCP Cloud SQL Disk Utilization Forecast monitor | list(string) | `[]` | no | | disk\_utilization\_forecast\_interval | Interval for the Disk Utilization Forecast monitor | string | `"60m"` | no | | disk\_utilization\_forecast\_linear\_history | History for the Disk Utilization Forecast monitor | string | `"3d"` | no | | disk\_utilization\_forecast\_linear\_model | Model for the Disk Utilization Forecast monitor | string | `"default"` | no | @@ -57,18 +57,18 @@ Creates DataDog monitors with the following checks: | environment | Architecture environment | string | n/a | yes | | evaluation\_delay | Delay in seconds for the metric evaluation | string | `"900"` | no | | failover\_unavailable\_enabled | Flag to enable GCP Cloud SQL Failover Unavailable monitor | string | `"true"` | no | -| failover\_unavailable\_extra\_tags | Extra tags for GCP Cloud SQL Failover Unavailable monitor | list | `[]` | no | +| failover\_unavailable\_extra\_tags | Extra tags for GCP Cloud SQL Failover Unavailable monitor | list(string) | `[]` | no | | failover\_unavailable\_message | Custom message for the Failover Unavailable monitor | string | `""` | no | | failover\_unavailable\_threshold\_critical | Failover Unavailable critical threshold | string | `"0"` | no | | failover\_unavailable\_time\_aggregator | Time aggreggator for the Failover Unavailable monitor | string | `"max"` | no | | failover\_unavailable\_timeframe | Timeframe for the Failover Unavailable monitor | string | `"last_10m"` | no | | filter\_tags | Tags used for filtering | string | `"*"` | no | | memory\_utilization\_enabled | Flag to enable GCP Cloud SQL Memory Utilization monitor | string | `"true"` | no | -| memory\_utilization\_extra\_tags | Extra tags for GCP Cloud SQL Memory Utilization monitor | list | `[]` | no | +| memory\_utilization\_extra\_tags | Extra tags for GCP Cloud SQL Memory Utilization monitor | list(string) | `[]` | no | | memory\_utilization\_forecast\_algorithm | Algorithm for the Memory Utilization Forecast monitor | string | `"linear"` | no | | memory\_utilization\_forecast\_deviations | Deviations for the Memory Utilization Forecast monitor | string | `"1"` | no | | memory\_utilization\_forecast\_enabled | Flag to enable GCP Cloud SQL Memory Utilization Forecast monitor | string | `"true"` | no | -| memory\_utilization\_forecast\_extra\_tags | Extra tags for GCP Cloud SQL Memory Utilization Forecast monitor | list | `[]` | no | +| memory\_utilization\_forecast\_extra\_tags | Extra tags for GCP Cloud SQL Memory Utilization Forecast monitor | list(string) | `[]` | no | | memory\_utilization\_forecast\_interval | Interval for the Memory Utilization Forecast monitor | string | `"30m"` | no | | memory\_utilization\_forecast\_linear\_history | History for the Memory Utilization Forecast monitor | string | `"12h"` | no | | memory\_utilization\_forecast\_linear\_model | Model for the Memory Utilization Forecast monitor | string | `"default"` | no | 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..e351769 100644 --- a/cloud/gcp/cloud-sql/common/monitors-cloud-sql-common.tf +++ b/cloud/gcp/cloud-sql/common/monitors-cloud-sql-common.tf @@ -2,24 +2,24 @@ # 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)}" - - type = "query alert" + 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 } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay notify_audit = false locked = false timeout_h = 0 @@ -28,34 +28,31 @@ resource "datadog_monitor" "cpu_utilization" { 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:cloud-sql", "team:claranet", "created-by:terraform", "${var.cpu_utilization_extra_tags}"] + tags = concat(["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}" + 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" + 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 } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay notify_audit = false locked = false timeout_h = 0 @@ -64,40 +61,45 @@ resource "datadog_monitor" "disk_utilization" { notify_no_data = true renotify_interval = 0 - 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 = concat(["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" - 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 } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay notify_audit = false locked = false timeout_h = 0 @@ -106,34 +108,31 @@ 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}" - - tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:cloud-sql", "team:claranet", "created-by:terraform", "${var.disk_utilization_forecast_extra_tags}"] + tags = concat(["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)}" - - type = "query alert" + 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 } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay notify_audit = false locked = false timeout_h = 0 @@ -142,40 +141,45 @@ resource "datadog_monitor" "memory_utilization" { 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:cloud-sql", "team:claranet", "created-by:terraform", "${var.memory_utilization_extra_tags}"] + tags = concat(["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)}" - - type = "query alert" + 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 } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay notify_audit = false locked = false timeout_h = 0 @@ -184,33 +188,31 @@ resource "datadog_monitor" "memory_utilization_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:cloud", "provider:gcp", "resource:cloud-sql", "team:claranet", "created-by:terraform", "${var.memory_utilization_forecast_extra_tags}"] + tags = concat(["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}" + 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)}" + 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 } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay notify_audit = false locked = false timeout_h = 0 @@ -28,8 +28,6 @@ resource "datadog_monitor" "replication_lag" { notify_no_data = true renotify_interval = 0 - 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 = concat(["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/gce/instance/README.md b/cloud/gcp/gce/instance/README.md index e11abb2..619649a 100644 --- a/cloud/gcp/gce/instance/README.md +++ b/cloud/gcp/gce/instance/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-cloud-gcp-gce-instance" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//cloud/gcp/gce/instance?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -25,14 +25,14 @@ Creates DataDog monitors with the following checks: | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| | cpu\_utilization\_enabled | Flag to enable CPU Utilization monitor | string | `"true"` | no | -| cpu\_utilization\_extra\_tags | Extra tags for CPU Utilization monitor | list | `[]` | no | +| cpu\_utilization\_extra\_tags | Extra tags for CPU Utilization monitor | list(string) | `[]` | no | | cpu\_utilization\_message | Custom message for the CPU Utilization monitor | string | `""` | no | | cpu\_utilization\_threshold\_critical | CPU Utilization in percentage (critical threshold) | string | `"90"` | no | | cpu\_utilization\_threshold\_warning | CPU Utilization in percentage (warning threshold) | string | `"80"` | no | | cpu\_utilization\_time\_aggregator | Time aggregator for the CPU Utilization monitor | string | `"avg"` | no | | cpu\_utilization\_timeframe | Timeframe for the CPU Utilization monitor | string | `"last_15m"` | no | | disk\_throttled\_bps\_enabled | Flag to enable Disk Throttled Bps monitor | string | `"true"` | no | -| disk\_throttled\_bps\_extra\_tags | Extra tags for Disk Throttled Bps monitor | list | `[]` | no | +| disk\_throttled\_bps\_extra\_tags | Extra tags for Disk Throttled Bps monitor | list(string) | `[]` | no | | disk\_throttled\_bps\_message | Custom message for the Disk Throttled Bps monitor | string | `""` | no | | disk\_throttled\_bps\_notify\_no\_data | Flag to enable notification for no data on Disk Throttled Bps monitor | string | `"false"` | no | | disk\_throttled\_bps\_threshold\_critical | Disk Throttled Bps in percentage (critical threshold) | string | `"50"` | no | @@ -40,7 +40,7 @@ Creates DataDog monitors with the following checks: | disk\_throttled\_bps\_time\_aggregator | Time aggregator for the Disk Throttled Bps monitor | string | `"min"` | no | | disk\_throttled\_bps\_timeframe | Timeframe for the Disk Throttled Bps monitor | string | `"last_15m"` | no | | disk\_throttled\_ops\_enabled | Flag to enable Disk Throttled OPS monitor | string | `"true"` | no | -| disk\_throttled\_ops\_extra\_tags | Extra tags for Disk Throttled OPS monitor | list | `[]` | no | +| disk\_throttled\_ops\_extra\_tags | Extra tags for Disk Throttled OPS monitor | list(string) | `[]` | no | | disk\_throttled\_ops\_message | Custom message for the Disk Throttled OPS monitor | string | `""` | no | | disk\_throttled\_ops\_notify\_no\_data | Flag to enable notification for no data on Disk Throttled OPS monitor | string | `"false"` | no | | disk\_throttled\_ops\_threshold\_critical | Disk Throttled OPS in percentage (critical threshold) | string | `"50"` | no | 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..c2ed5cc 100644 --- a/cloud/gcp/gce/instance/monitors-gce-instance.tf +++ b/cloud/gcp/gce/instance/monitors-gce-instance.tf @@ -2,23 +2,24 @@ # 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)}" - - type = "query alert" + 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 } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay notify_audit = false locked = false timeout_h = 0 @@ -27,21 +28,17 @@ resource "datadog_monitor" "cpu_utilization" { notify_no_data = true 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.cpu_utilization_extra_tags}"] + tags = concat(["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}" + 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" + 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 } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay 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}" + 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}" - - tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:gce-instance", "team:claranet", "created-by:terraform", "${var.disk_throttled_bps_extra_tags}"] + tags = concat(["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}" + 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)}" + message = coalesce(var.disk_throttled_ops_message, var.message) + type = "query alert" - 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}" + thresholds = { + warning = var.disk_throttled_ops_threshold_warning + critical = var.disk_throttled_ops_threshold_critical } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay + notify_no_data = var.disk_throttled_ops_notify_no_data 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}"] + tags = concat(["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/lb/README.md b/cloud/gcp/lb/README.md index b5351ed..0501fd2 100644 --- a/cloud/gcp/lb/README.md +++ b/cloud/gcp/lb/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-cloud-gcp-lb" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//cloud/gcp/lb?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -27,14 +27,14 @@ Creates DataDog monitors with the following checks: | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| | backend\_latency\_bucket\_enabled | Flag to enable GCP LB Backend Latency monitor | string | `"true"` | no | -| backend\_latency\_bucket\_extra\_tags | Extra tags for GCP LB Backend Latency monitor | list | `[]` | no | +| backend\_latency\_bucket\_extra\_tags | Extra tags for GCP LB Backend Latency monitor | list(string) | `[]` | no | | backend\_latency\_bucket\_message | Custom message for the GCP LB Backend Latency monitor | string | `""` | no | | backend\_latency\_bucket\_threshold\_critical | Latency in milliseconds (critical threshold) | string | `"8000"` | no | | backend\_latency\_bucket\_threshold\_warning | Latency in milliseconds (warning threshold) | string | `"4000"` | no | | backend\_latency\_bucket\_time\_aggregator | Timeframe for the GCP LB Backend Latency monitor | string | `"min"` | no | | backend\_latency\_bucket\_timeframe | Timeframe for the GCP LB Backend Latency monitor | string | `"last_10m"` | no | | backend\_latency\_service\_enabled | Flag to enable GCP LB Backend Latency monitor | string | `"true"` | no | -| backend\_latency\_service\_extra\_tags | Extra tags for GCP LB Backend Latency monitor | list | `[]` | no | +| backend\_latency\_service\_extra\_tags | Extra tags for GCP LB Backend Latency monitor | list(string) | `[]` | no | | backend\_latency\_service\_message | Custom message for the GCP LB Backend Latency monitor | string | `""` | no | | backend\_latency\_service\_threshold\_critical | Latency in milliseconds (critical threshold) | string | `"1500"` | no | | backend\_latency\_service\_threshold\_warning | Latency in milliseconds (warning threshold) | string | `"1000"` | no | @@ -43,7 +43,7 @@ Creates DataDog monitors with the following checks: | environment | Architecture environment | string | n/a | yes | | error\_rate\_4xx\_artificial\_request | Divisor Delta for the GCP LB 4XX Errors monitor | string | `"5"` | no | | error\_rate\_4xx\_enabled | Flag to enable GCP LB 4XX Errors monitor | string | `"true"` | no | -| error\_rate\_4xx\_extra\_tags | Extra tags for GCP LB 4XX Errors monitor | list | `[]` | no | +| error\_rate\_4xx\_extra\_tags | Extra tags for GCP LB 4XX Errors monitor | list(string) | `[]` | no | | error\_rate\_4xx\_message | Custom message for the GCP LB 4XX Errors monitor | string | `""` | no | | error\_rate\_4xx\_threshold\_critical | Rate error in percentage (critical threshold) | string | `"60"` | no | | error\_rate\_4xx\_threshold\_warning | Rate error in percentage (warning threshold) | string | `"50"` | no | @@ -51,7 +51,7 @@ Creates DataDog monitors with the following checks: | error\_rate\_4xx\_timeframe | Timeframe for the GCP LB 4XX Errors monitor | string | `"last_5m"` | no | | error\_rate\_5xx\_artificial\_request | Divisor Delta for the GCP LB 5XX Errors monitor | string | `"5"` | no | | error\_rate\_5xx\_enabled | Flag to enable GCP LB 5XX Errors monitor | string | `"true"` | no | -| error\_rate\_5xx\_extra\_tags | Extra tags for GCP LB 5XX Errors monitor | list | `[]` | no | +| error\_rate\_5xx\_extra\_tags | Extra tags for GCP LB 5XX Errors monitor | list(string) | `[]` | no | | error\_rate\_5xx\_message | Custom message for the GCP LB 5XX Errors monitor | string | `""` | no | | error\_rate\_5xx\_threshold\_critical | Rate error in percentage (critical threshold) | string | `"40"` | no | | error\_rate\_5xx\_threshold\_warning | Rate error in percentage (warning threshold) | string | `"30"` | no | @@ -63,7 +63,7 @@ Creates DataDog monitors with the following checks: | new\_host\_delay | Delay in seconds for the new host evaluation | string | `"300"` | no | | prefix\_slug | Prefix string to prepend between brackets on every monitors names | string | `""` | no | | request\_count\_enabled | Flag to enable GCP LB Request Count monitor | string | `"true"` | no | -| request\_count\_extra\_tags | Extra tags for GCP LB Request Count monitor | list | `[]` | no | +| request\_count\_extra\_tags | Extra tags for GCP LB Request Count monitor | list(string) | `[]` | no | | request\_count\_message | Custom message for the GCP LB Request Count monitor | string | `""` | no | | request\_count\_threshold\_critical | Desviation in percentage (critical threshold) | string | `"500"` | no | | request\_count\_threshold\_warning | Desviation in percentage (warning threshold) | string | `"250"` | no | 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..e193b78 100644 --- a/cloud/gcp/lb/monitors-lb.tf +++ b/cloud/gcp/lb/monitors-lb.tf @@ -2,24 +2,25 @@ # 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)}" - - type = "query alert" + 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 } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay notify_audit = false locked = false timeout_h = 0 @@ -28,34 +29,32 @@ resource "datadog_monitor" "error_rate_4xx" { 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:lb", "team:claranet", "created-by:terraform", "${var.error_rate_4xx_extra_tags}"] + tags = concat(["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}" + 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" + 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 } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay notify_audit = false locked = false timeout_h = 0 @@ -64,33 +63,31 @@ resource "datadog_monitor" "error_rate_5xx" { 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:lb", "team:claranet", "created-by:terraform", "${var.error_rate_5xx_extra_tags}"] + tags = concat(["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}" + 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)}" + message = coalesce(var.backend_latency_service_message, var.message) + type = "query alert" - 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 } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay notify_audit = false locked = false timeout_h = 0 @@ -99,33 +96,31 @@ resource "datadog_monitor" "backend_latency_service" { 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:lb", "team:claranet", "created-by:terraform", "${var.backend_latency_service_extra_tags}"] + tags = concat(["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}" + 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)}" + message = coalesce(var.backend_latency_bucket_message, var.message) + type = "query alert" - 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 } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay notify_audit = false locked = false timeout_h = 0 @@ -134,33 +129,31 @@ 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}" - - tags = ["env:${var.environment}", "type:cloud", "provider:gcp", "resource:lb", "team:claranet", "created-by:terraform", "${var.backend_latency_bucket_extra_tags}"] + tags = concat(["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)}" - - type = "query alert" + 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 } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay notify_audit = false locked = false timeout_h = 0 @@ -169,8 +162,6 @@ resource "datadog_monitor" "request_count" { 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:lb", "team:claranet", "created-by:terraform", "${var.request_count_extra_tags}"] + tags = concat(["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/pubsub/README.md b/cloud/gcp/pubsub/README.md index a7a04c0..a896b88 100644 --- a/cloud/gcp/pubsub/README.md +++ b/cloud/gcp/pubsub/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-cloud-gcp-pubsub" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//cloud/gcp/pubsub?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -30,13 +30,13 @@ Creates DataDog monitors with the following checks: | new\_host\_delay | Delay in seconds for the new host evaluation | string | `"300"` | no | | prefix\_slug | Prefix string to prepend between brackets on every monitors names | string | `""` | no | | sending\_operations\_count\_enabled | Flag to enable GCP Pub/Sub Unavailable Sending Operations Count monitor | string | `"true"` | no | -| sending\_operations\_count\_extra\_tags | Extra tags for GCP Pub/Sub Sending Operations Count monitor | list | `[]` | no | +| sending\_operations\_count\_extra\_tags | Extra tags for GCP Pub/Sub Sending Operations Count monitor | list(string) | `[]` | no | | sending\_operations\_count\_message | Custom message for the GCP Pub/Sub Sending Operations Count monitor | string | `""` | no | | sending\_operations\_count\_threshold\_critical | Critical threshold for the number of sending operations. | string | `"0"` | no | | sending\_operations\_count\_time\_aggregator | Timeframe for the GCP Pub/Sub Sending Operations Count monitor | string | `"sum"` | no | | sending\_operations\_count\_timeframe | Timeframe for the GCP Pub/Sub Sending Operations Count monitor | string | `"last_30m"` | no | | unavailable\_sending\_operations\_count\_enabled | Flag to enable GCP Pub/Sub Unavailable Sending Operations Count monitor | string | `"true"` | no | -| unavailable\_sending\_operations\_count\_extra\_tags | Extra tags for GCP Pub/Sub Unavailable Sending Operations Count monitor | list | `[]` | no | +| unavailable\_sending\_operations\_count\_extra\_tags | Extra tags for GCP Pub/Sub Unavailable Sending Operations Count monitor | list(string) | `[]` | no | | unavailable\_sending\_operations\_count\_message | Custom message for the GCP Pub/Sub Unavailable Sending Operations Count monitor | string | `""` | no | | unavailable\_sending\_operations\_count\_threshold\_critical | Critical threshold for the number of unavailable sending operations | string | `"4"` | no | | unavailable\_sending\_operations\_count\_threshold\_warning | Warning threshold for the number of unavailable sending operations | string | `"2"` | no | 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..7584fb5 100644 --- a/cloud/gcp/pubsub/monitors-pubsub.tf +++ b/cloud/gcp/pubsub/monitors-pubsub.tf @@ -2,22 +2,23 @@ # 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)}" - - type = "query alert" + 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}" + thresholds = { + warning = var.unavailable_sending_operations_count_threshold_warning + critical = var.unavailable_sending_operations_count_threshold_critical } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay notify_audit = false locked = false timeout_h = 0 @@ -61,8 +60,6 @@ resource "datadog_monitor" "unavailable_sending_operations_count" { 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}"] + tags = concat(["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/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..20803ce 100644 --- a/common/alerting-message/main.tf +++ b/common/alerting-message/main.tf @@ -10,11 +10,12 @@ $${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/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/database/elasticsearch/README.md b/database/elasticsearch/README.md index 9c8ce1a..e92f8ee 100644 --- a/database/elasticsearch/README.md +++ b/database/elasticsearch/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-database-elasticsearch" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//database/elasticsearch?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -44,28 +44,28 @@ Creates DataDog monitors with the following checks: | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| | cluster\_initializing\_shards\_enabled | Flag to enable Cluster Status monitor | string | `"true"` | no | -| cluster\_initializing\_shards\_extra\_tags | Extra tags for Cluster Status monitor | list | `[]` | no | +| cluster\_initializing\_shards\_extra\_tags | Extra tags for Cluster Status monitor | list(string) | `[]` | no | | cluster\_initializing\_shards\_message | Custom message for the Cluster Status monitor | string | `""` | no | | cluster\_initializing\_shards\_threshold\_critical | Cluster Status critical threshold | string | `"2"` | no | | cluster\_initializing\_shards\_threshold\_warning | Cluster Status warning threshold | string | `"1"` | no | | cluster\_initializing\_shards\_time\_aggregator | Time aggregator for the Cluster Status monitor | string | `"avg"` | no | | cluster\_initializing\_shards\_timeframe | Timeframe for the Cluster Status monitor | string | `"last_5m"` | no | | cluster\_relocating\_shards\_enabled | Flag to enable Cluster Status monitor | string | `"true"` | no | -| cluster\_relocating\_shards\_extra\_tags | Extra tags for Cluster Status monitor | list | `[]` | no | +| cluster\_relocating\_shards\_extra\_tags | Extra tags for Cluster Status monitor | list(string) | `[]` | no | | cluster\_relocating\_shards\_message | Custom message for the Cluster Status monitor | string | `""` | no | | cluster\_relocating\_shards\_threshold\_critical | Cluster Status critical threshold | string | `"2"` | no | | cluster\_relocating\_shards\_threshold\_warning | Cluster Status warning threshold | string | `"1"` | no | | cluster\_relocating\_shards\_time\_aggregator | Time aggregator for the Cluster Status monitor | string | `"avg"` | no | | cluster\_relocating\_shards\_timeframe | Timeframe for the Cluster Status monitor | string | `"last_5m"` | no | | cluster\_status\_not\_green\_enabled | Flag to enable Cluster Status monitor | string | `"true"` | no | -| cluster\_status\_not\_green\_extra\_tags | Extra tags for Cluster Status monitor | list | `[]` | no | +| cluster\_status\_not\_green\_extra\_tags | Extra tags for Cluster Status monitor | list(string) | `[]` | no | | cluster\_status\_not\_green\_message | Custom message for the Cluster Status monitor | string | `""` | no | | cluster\_status\_not\_green\_threshold\_critical | Cluster Status critical threshold | string | `"0"` | no | | cluster\_status\_not\_green\_threshold\_warning | Cluster Status warning threshold | string | `"1"` | no | | cluster\_status\_not\_green\_time\_aggregator | Time aggregator for the Cluster Status monitor | string | `"avg"` | no | | cluster\_status\_not\_green\_timeframe | Timeframe for the Cluster Status monitor | string | `"last_5m"` | no | | cluster\_unassigned\_shards\_enabled | Flag to enable Cluster Status monitor | string | `"true"` | no | -| cluster\_unassigned\_shards\_extra\_tags | Extra tags for Cluster Status monitor | list | `[]` | no | +| cluster\_unassigned\_shards\_extra\_tags | Extra tags for Cluster Status monitor | list(string) | `[]` | no | | cluster\_unassigned\_shards\_message | Custom message for the Cluster Status monitor | string | `""` | no | | cluster\_unassigned\_shards\_threshold\_critical | Cluster Status critical threshold | string | `"2"` | no | | cluster\_unassigned\_shards\_threshold\_warning | Cluster Status warning threshold | string | `"1"` | no | @@ -74,7 +74,7 @@ Creates DataDog monitors with the following checks: | environment | Architecture environment | string | n/a | yes | | evaluation\_delay | Delay in seconds for the metric evaluation | string | `"15"` | no | | fetch\_change\_enabled | Flag to enable Cluster Status monitor | string | `"true"` | no | -| fetch\_change\_extra\_tags | Extra tags for Cluster Status monitor | list | `[]` | no | +| fetch\_change\_extra\_tags | Extra tags for Cluster Status monitor | list(string) | `[]` | no | | fetch\_change\_message | Custom message for the Cluster Status monitor | string | `""` | no | | fetch\_change\_threshold\_critical | Cluster Status critical threshold | string | `"100"` | no | | fetch\_change\_threshold\_warning | Cluster Status warning threshold | string | `"75"` | no | @@ -82,14 +82,14 @@ Creates DataDog monitors with the following checks: | fetch\_change\_timeframe | Timeframe for the Cluster Status monitor | string | `"last_10m"` | no | | fetch\_change\_timeshift | Timeshift for the Cluster Status monitor | string | `"last_10m"` | no | | fetch\_latency\_enabled | Flag to enable Cluster Status monitor | string | `"true"` | no | -| fetch\_latency\_extra\_tags | Extra tags for Cluster Status monitor | list | `[]` | no | +| fetch\_latency\_extra\_tags | Extra tags for Cluster Status monitor | list(string) | `[]` | no | | fetch\_latency\_message | Custom message for the Cluster Status monitor | string | `""` | no | | fetch\_latency\_threshold\_critical | Cluster Status critical threshold | string | `"4"` | no | | fetch\_latency\_threshold\_warning | Cluster Status warning threshold | string | `"2"` | no | | fetch\_latency\_time\_aggregator | Time aggregator for the Cluster Status monitor | string | `"avg"` | no | | fetch\_latency\_timeframe | Timeframe for the Cluster Status monitor | string | `"last_10m"` | no | | field\_data\_evictions\_change\_enabled | Flag to enable Cluster Status monitor | string | `"true"` | no | -| field\_data\_evictions\_change\_extra\_tags | Extra tags for Cluster Status monitor | list | `[]` | no | +| field\_data\_evictions\_change\_extra\_tags | Extra tags for Cluster Status monitor | list(string) | `[]` | no | | field\_data\_evictions\_change\_message | Custom message for the Cluster Status monitor | string | `""` | no | | field\_data\_evictions\_change\_threshold\_critical | Cluster Status critical threshold | string | `"120"` | no | | field\_data\_evictions\_change\_threshold\_warning | Cluster Status warning threshold | string | `"60"` | no | @@ -100,7 +100,7 @@ Creates DataDog monitors with the following checks: | filter\_tags\_custom\_excluded | Tags excluded for custom filtering when filter_tags_use_defaults is false | string | `""` | no | | filter\_tags\_use\_defaults | Use default filter tags convention | string | `"true"` | no | | flush\_latency\_enabled | Flag to enable Cluster Status monitor | string | `"true"` | no | -| flush\_latency\_extra\_tags | Extra tags for Cluster Status monitor | list | `[]` | no | +| flush\_latency\_extra\_tags | Extra tags for Cluster Status monitor | list(string) | `[]` | no | | flush\_latency\_message | Custom message for the Cluster Status monitor | string | `""` | no | | flush\_latency\_threshold\_critical | Cluster Status critical threshold | string | `"100"` | no | | flush\_latency\_threshold\_warning | Cluster Status warning threshold | string | `"50"` | no | @@ -112,7 +112,7 @@ Creates DataDog monitors with the following checks: | http\_connections\_anomaly\_deviations | Deviations to detect the anomaly | string | `"2"` | no | | http\_connections\_anomaly\_direction | Direction of the anomaly. It can be both, below or above. | string | `"above"` | no | | http\_connections\_anomaly\_enabled | Flag to enable Cluster Status monitor | string | `"true"` | no | -| http\_connections\_anomaly\_extra\_tags | Extra tags for Cluster Status monitor | list | `[]` | no | +| http\_connections\_anomaly\_extra\_tags | Extra tags for Cluster Status monitor | list(string) | `[]` | no | | http\_connections\_anomaly\_interval | Interval. | string | `"60"` | no | | http\_connections\_anomaly\_message | Custom message for the Cluster Status monitor | string | `""` | no | | http\_connections\_anomaly\_seasonality | Seasonality of the algorithm | string | `"hourly"` | no | @@ -121,42 +121,42 @@ Creates DataDog monitors with the following checks: | http\_connections\_anomaly\_time\_aggregator | Time aggregator for the Cluster Status monitor | string | `"avg"` | no | | http\_connections\_anomaly\_timeframe | Timeframe for the Cluster Status monitor | string | `"last_4h"` | no | | indexing\_latency\_enabled | Flag to enable Cluster Status monitor | string | `"true"` | no | -| indexing\_latency\_extra\_tags | Extra tags for Cluster Status monitor | list | `[]` | no | +| indexing\_latency\_extra\_tags | Extra tags for Cluster Status monitor | list(string) | `[]` | no | | indexing\_latency\_message | Custom message for the Cluster Status monitor | string | `""` | no | | indexing\_latency\_threshold\_critical | Cluster Status critical threshold | string | `"15"` | no | | indexing\_latency\_threshold\_warning | Cluster Status warning threshold | string | `"10"` | no | | indexing\_latency\_time\_aggregator | Time aggregator for the Cluster Status monitor | string | `"avg"` | no | | indexing\_latency\_timeframe | Timeframe for the Cluster Status monitor | string | `"last_10m"` | no | | jvm\_gc\_old\_collection\_latency\_enabled | Flag to enable Cluster Status monitor | string | `"true"` | no | -| jvm\_gc\_old\_collection\_latency\_extra\_tags | Extra tags for Cluster Status monitor | list | `[]` | no | +| jvm\_gc\_old\_collection\_latency\_extra\_tags | Extra tags for Cluster Status monitor | list(string) | `[]` | no | | jvm\_gc\_old\_collection\_latency\_message | Custom message for the Cluster Status monitor | string | `""` | no | | jvm\_gc\_old\_collection\_latency\_threshold\_critical | Cluster Status critical threshold | string | `"200"` | no | | jvm\_gc\_old\_collection\_latency\_threshold\_warning | Cluster Status warning threshold | string | `"160"` | no | | jvm\_gc\_old\_collection\_latency\_time\_aggregator | Time aggregator for the Cluster Status monitor | string | `"avg"` | no | | jvm\_gc\_old\_collection\_latency\_timeframe | Timeframe for the Cluster Status monitor | string | `"last_10m"` | no | | jvm\_gc\_young\_collection\_latency\_enabled | Flag to enable Cluster Status monitor | string | `"true"` | no | -| jvm\_gc\_young\_collection\_latency\_extra\_tags | Extra tags for Cluster Status monitor | list | `[]` | no | +| jvm\_gc\_young\_collection\_latency\_extra\_tags | Extra tags for Cluster Status monitor | list(string) | `[]` | no | | jvm\_gc\_young\_collection\_latency\_message | Custom message for the Cluster Status monitor | string | `""` | no | | jvm\_gc\_young\_collection\_latency\_threshold\_critical | Cluster Status critical threshold | string | `"25"` | no | | jvm\_gc\_young\_collection\_latency\_threshold\_warning | Cluster Status warning threshold | string | `"20"` | no | | jvm\_gc\_young\_collection\_latency\_time\_aggregator | Time aggregator for the Cluster Status monitor | string | `"avg"` | no | | jvm\_gc\_young\_collection\_latency\_timeframe | Timeframe for the Cluster Status monitor | string | `"last_10m"` | no | | jvm\_heap\_memory\_usage\_enabled | Flag to enable Cluster Status monitor | string | `"true"` | no | -| jvm\_heap\_memory\_usage\_extra\_tags | Extra tags for Cluster Status monitor | list | `[]` | no | +| jvm\_heap\_memory\_usage\_extra\_tags | Extra tags for Cluster Status monitor | list(string) | `[]` | no | | jvm\_heap\_memory\_usage\_message | Custom message for the Cluster Status monitor | string | `""` | no | | jvm\_heap\_memory\_usage\_threshold\_critical | Cluster Status critical threshold | string | `"90"` | no | | jvm\_heap\_memory\_usage\_threshold\_warning | Cluster Status warning threshold | string | `"80"` | no | | jvm\_heap\_memory\_usage\_time\_aggregator | Time aggregator for the Cluster Status monitor | string | `"avg"` | no | | jvm\_heap\_memory\_usage\_timeframe | Timeframe for the Cluster Status monitor | string | `"last_5m"` | no | | jvm\_memory\_old\_usage\_enabled | Flag to enable Cluster Status monitor | string | `"true"` | no | -| jvm\_memory\_old\_usage\_extra\_tags | Extra tags for Cluster Status monitor | list | `[]` | no | +| jvm\_memory\_old\_usage\_extra\_tags | Extra tags for Cluster Status monitor | list(string) | `[]` | no | | jvm\_memory\_old\_usage\_message | Custom message for the Cluster Status monitor | string | `""` | no | | jvm\_memory\_old\_usage\_threshold\_critical | Cluster Status critical threshold | string | `"90"` | no | | jvm\_memory\_old\_usage\_threshold\_warning | Cluster Status warning threshold | string | `"80"` | no | | jvm\_memory\_old\_usage\_time\_aggregator | Time aggregator for the Cluster Status monitor | string | `"avg"` | no | | jvm\_memory\_old\_usage\_timeframe | Timeframe for the Cluster Status monitor | string | `"last_10m"` | no | | jvm\_memory\_young\_usage\_enabled | Flag to enable Cluster Status monitor | string | `"true"` | no | -| jvm\_memory\_young\_usage\_extra\_tags | Extra tags for Cluster Status monitor | list | `[]` | no | +| jvm\_memory\_young\_usage\_extra\_tags | Extra tags for Cluster Status monitor | list(string) | `[]` | no | | jvm\_memory\_young\_usage\_message | Custom message for the Cluster Status monitor | string | `""` | no | | jvm\_memory\_young\_usage\_threshold\_critical | Cluster Status critical threshold | string | `"90"` | no | | jvm\_memory\_young\_usage\_threshold\_warning | Cluster Status warning threshold | string | `"80"` | no | @@ -165,20 +165,20 @@ Creates DataDog monitors with the following checks: | message | Message sent when a monitor is triggered | string | n/a | yes | | new\_host\_delay | Delay in seconds before begin to monitor new host | string | `"300"` | no | | node\_free\_space\_enabled | Flag to enable Cluster Status monitor | string | `"true"` | no | -| node\_free\_space\_extra\_tags | Extra tags for Cluster Status monitor | list | `[]` | no | +| node\_free\_space\_extra\_tags | Extra tags for Cluster Status monitor | list(string) | `[]` | no | | node\_free\_space\_message | Custom message for the Cluster Status monitor | string | `""` | no | | node\_free\_space\_threshold\_critical | Cluster Status critical threshold | string | `"10"` | no | | node\_free\_space\_threshold\_warning | Cluster Status warning threshold | string | `"20"` | no | | node\_free\_space\_time\_aggregator | Time aggregator for the Cluster Status monitor | string | `"sum"` | no | | node\_free\_space\_timeframe | Timeframe for the Cluster Status monitor | string | `"last_5m"` | no | | not\_responding\_enabled | Flag to enable Elasticsearch does not respond monitor | string | `"true"` | no | -| not\_responding\_extra\_tags | Extra tags for Elasticsearch does not respond monitor | list | `[]` | no | +| not\_responding\_extra\_tags | Extra tags for Elasticsearch does not respond monitor | list(string) | `[]` | no | | not\_responding\_message | Custom message for Elasticsearch does not respond monitor | string | `""` | no | | not\_responding\_no\_data\_timeframe | Elasticsearch not responding monitor no data timeframe | string | `"10"` | no | | not\_responding\_threshold\_warning | Elasticsearch not responding limit (warning threshold) | string | `"3"` | no | | prefix\_slug | Prefix string to prepend between brackets on every monitors names | string | `""` | no | | query\_cache\_evictions\_change\_enabled | Flag to enable Cluster Status monitor | string | `"true"` | no | -| query\_cache\_evictions\_change\_extra\_tags | Extra tags for Cluster Status monitor | list | `[]` | no | +| query\_cache\_evictions\_change\_extra\_tags | Extra tags for Cluster Status monitor | list(string) | `[]` | no | | query\_cache\_evictions\_change\_message | Custom message for the Cluster Status monitor | string | `""` | no | | query\_cache\_evictions\_change\_threshold\_critical | Cluster Status critical threshold | string | `"120"` | no | | query\_cache\_evictions\_change\_threshold\_warning | Cluster Status warning threshold | string | `"60"` | no | @@ -186,7 +186,7 @@ Creates DataDog monitors with the following checks: | query\_cache\_evictions\_change\_timeframe | Timeframe for the Cluster Status monitor | string | `"last_15m"` | no | | query\_cache\_evictions\_change\_timeshift | Timeframe for the Cluster Status monitor | string | `"last_15m"` | no | | request\_cache\_evictions\_change\_enabled | Flag to enable Cluster Status monitor | string | `"true"` | no | -| request\_cache\_evictions\_change\_extra\_tags | Extra tags for Cluster Status monitor | list | `[]` | no | +| request\_cache\_evictions\_change\_extra\_tags | Extra tags for Cluster Status monitor | list(string) | `[]` | no | | request\_cache\_evictions\_change\_message | Custom message for the Cluster Status monitor | string | `""` | no | | request\_cache\_evictions\_change\_threshold\_critical | Cluster Status critical threshold | string | `"120"` | no | | request\_cache\_evictions\_change\_threshold\_warning | Cluster Status warning threshold | string | `"60"` | no | @@ -194,7 +194,7 @@ Creates DataDog monitors with the following checks: | request\_cache\_evictions\_change\_timeframe | Timeframe for the Cluster Status monitor | string | `"last_15m"` | no | | request\_cache\_evictions\_change\_timeshift | Timeshift for the Cluster Status monitor | string | `"last_15m"` | no | | search\_query\_change\_enabled | Flag to enable Cluster Status monitor | string | `"true"` | no | -| search\_query\_change\_extra\_tags | Extra tags for Cluster Status monitor | list | `[]` | no | +| search\_query\_change\_extra\_tags | Extra tags for Cluster Status monitor | list(string) | `[]` | no | | search\_query\_change\_message | Custom message for the Cluster Status monitor | string | `""` | no | | search\_query\_change\_threshold\_critical | Cluster Status critical threshold | string | `"100"` | no | | search\_query\_change\_threshold\_warning | Cluster Status warning threshold | string | `"75"` | no | @@ -202,14 +202,14 @@ Creates DataDog monitors with the following checks: | search\_query\_change\_timeframe | Timeframe for the Cluster Status monitor | string | `"last_10m"` | no | | search\_query\_change\_timeshift | Timeshift for the Cluster Status monitor | string | `"last_10m"` | no | | search\_query\_latency\_enabled | Flag to enable Cluster Status monitor | string | `"true"` | no | -| search\_query\_latency\_extra\_tags | Extra tags for Cluster Status monitor | list | `[]` | no | +| search\_query\_latency\_extra\_tags | Extra tags for Cluster Status monitor | list(string) | `[]` | no | | search\_query\_latency\_message | Custom message for the Cluster Status monitor | string | `""` | no | | search\_query\_latency\_threshold\_critical | Cluster Status critical threshold | string | `"1"` | no | | search\_query\_latency\_threshold\_warning | Cluster Status warning threshold | string | `"0.5"` | no | | search\_query\_latency\_time\_aggregator | Time aggregator for the Cluster Status monitor | string | `"avg"` | no | | search\_query\_latency\_timeframe | Timeframe for the Cluster Status monitor | string | `"last_10m"` | no | | task\_time\_in\_queue\_change\_enabled | Flag to enable Cluster Status monitor | string | `"true"` | no | -| task\_time\_in\_queue\_change\_extra\_tags | Extra tags for Cluster Status monitor | list | `[]` | no | +| task\_time\_in\_queue\_change\_extra\_tags | Extra tags for Cluster Status monitor | list(string) | `[]` | no | | task\_time\_in\_queue\_change\_message | Custom message for the Cluster Status monitor | string | `""` | no | | task\_time\_in\_queue\_change\_threshold\_critical | Cluster Status critical threshold | string | `"200"` | no | | task\_time\_in\_queue\_change\_threshold\_warning | Cluster Status warning threshold | string | `"100"` | no | 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..d5bd81c 100644 --- a/database/elasticsearch/monitors-elasticsearch.tf +++ b/database/elasticsearch/monitors-elasticsearch.tf @@ -2,22 +2,22 @@ # 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 } + 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 = concat(["env:${var.environment}", "type:database", "provider:elasticsearch", "resource:elasticsearch", "team:claranet", "created-by:terraform"], var.cluster_initializing_shards_extra_tags) } # # Cluster Relocating Shards # resource "datadog_monitor" "cluster_relocating_shards" { - count = "${var.cluster_relocating_shards_enabled == "true" ? 1 : 0}" + 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)}" + 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 = concat(["env:${var.environment}", "type:database", "provider:elasticsearch", "resource:elasticsearch", "team:claranet", "created-by:terraform"], 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)}" - - type = "metric alert" + 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 } + 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_unassigned_shards_extra_tags}", - ] + tags = concat(["env:${var.environment}", "type:database", "provider:elasticsearch", "resource:elasticsearch", "team:claranet", "created-by:terraform"], 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}" + 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)}" + message = coalesce(var.node_free_space_message, var.message) type = "query alert" @@ -217,323 +171,251 @@ 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 } + 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 = concat(["env:${var.environment}", "type:database", "provider:elasticsearch", "resource:elasticsearch", "team:claranet", "created-by:terraform"], 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}" + 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)}" + 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 } + 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 = concat(["env:${var.environment}", "type:database", "provider:elasticsearch", "resource:elasticsearch", "team:claranet", "created-by:terraform"], 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}" + 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)}" + 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 = concat(["env:${var.environment}", "type:database", "provider:elasticsearch", "resource:elasticsearch", "team:claranet", "created-by:terraform"], 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)}" - - type = "query alert" + 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 } + 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_old_usage_extra_tags}", - ] + tags = concat(["env:${var.environment}", "type:database", "provider:elasticsearch", "resource:elasticsearch", "team:claranet", "created-by:terraform"], 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}" + 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" + 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 } + 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 = concat(["env:${var.environment}", "type:database", "provider:elasticsearch", "resource:elasticsearch", "team:claranet", "created-by:terraform"], 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}" + 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)}" + 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 } + 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 = concat(["env:${var.environment}", "type:database", "provider:elasticsearch", "resource:elasticsearch", "team:claranet", "created-by:terraform"], var.jvm_gc_young_collection_latency_extra_tags) } # # Indexing Latency # resource "datadog_monitor" "indexing_latency" { - count = "${var.indexing_latency_enabled == "true" ? 1 : 0}" + 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" + message = coalesce(var.indexing_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 - 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 = concat(["env:${var.environment}", "type:database", "provider:elasticsearch", "resource:elasticsearch", "team:claranet", "created-by:terraform"], 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)}" - - type = "query alert" + 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 query = < ${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 } + 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.flush_latency_extra_tags}", - ] + tags = concat(["env:${var.environment}", "type:database", "provider:elasticsearch", "resource:elasticsearch", "team:claranet", "created-by:terraform"], var.flush_latency_extra_tags) } # # Open HTTP Connections Anomaly # resource "datadog_monitor" "http_connections_anomaly" { - count = "${var.http_connections_anomaly_enabled == "true" ? 1 : 0}" + 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" + 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 } + threshold_windows = { + trigger_window = var.http_connections_anomaly_alert_window + recovery_window = var.http_connections_anomaly_alert_window + } + + 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 = concat(["env:${var.environment}", "type:database", "provider:elasticsearch", "resource:elasticsearch", "team:claranet", "created-by:terraform"], var.http_connections_anomaly_extra_tags) } # # Query Latency # resource "datadog_monitor" "search_query_latency" { - count = "${var.search_query_latency_enabled == "true" ? 1 : 0}" + 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" + message = coalesce(var.search_query_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 - 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 } + 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 = concat(["env:${var.environment}", "type:database", "provider:elasticsearch", "resource:elasticsearch", "team:claranet", "created-by:terraform"], var.search_query_latency_extra_tags) } # # Fetch Latency # resource "datadog_monitor" "fetch_latency" { - count = "${var.fetch_latency_enabled == "true" ? 1 : 0}" + 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" + message = coalesce(var.fetch_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 - 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 = concat(["env:${var.environment}", "type:database", "provider:elasticsearch", "resource:elasticsearch", "team:claranet", "created-by:terraform"], 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)}" - - type = "query alert" + 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 } + 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_change_extra_tags}", - ] + tags = concat(["env:${var.environment}", "type:database", "provider:elasticsearch", "resource:elasticsearch", "team:claranet", "created-by:terraform"], var.search_query_change_extra_tags) } # # Fetch Change # resource "datadog_monitor" "fetch_change" { - count = "${var.fetch_change_enabled == "true" ? 1 : 0}" + 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" + 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 } + 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 = concat(["env:${var.environment}", "type:database", "provider:elasticsearch", "resource:elasticsearch", "team:claranet", "created-by:terraform"], 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}" + 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" + message = coalesce(var.field_data_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 - 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 } + 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 = concat(["env:${var.environment}", "type:database", "provider:elasticsearch", "resource:elasticsearch", "team:claranet", "created-by:terraform"], 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}" + 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" + message = coalesce(var.query_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 - 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 = concat(["env:${var.environment}", "type:database", "provider:elasticsearch", "resource:elasticsearch", "team:claranet", "created-by:terraform"], 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)}" - - type = "query alert" + 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 query = < ${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 } + 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.request_cache_evictions_change_extra_tags}", - ] + tags = concat(["env:${var.environment}", "type:database", "provider:elasticsearch", "resource:elasticsearch", "team:claranet", "created-by:terraform"], 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}" + 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" + 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}" + 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 - 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}", - ] + tags = concat(["env:${var.environment}", "type:database", "provider:elasticsearch", "resource:elasticsearch", "team:claranet", "created-by:terraform"], 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/mongodb/README.md b/database/mongodb/README.md index 0fb9c78..0fd1cae 100644 --- a/database/mongodb/README.md +++ b/database/mongodb/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-database-mongodb" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//database/mongodb?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -36,17 +36,17 @@ Creates DataDog monitors with the following checks: | mongodb\_lag\_warning | Warn replication lag in s | string | `"2"` | no | | mongodb\_primary\_aggregator | Monitor aggregator for MongoDB primary state [available values: min, max] | string | `"max"` | no | | mongodb\_primary\_enabled | Flag to enable MongoDB primary state monitor | string | `"true"` | no | -| mongodb\_primary\_extra\_tags | Extra tags for MongoDB primary state monitor | list | `[]` | no | +| mongodb\_primary\_extra\_tags | Extra tags for MongoDB primary state monitor | list(string) | `[]` | no | | mongodb\_primary\_message | Custom message for MongoDB primary monitor | string | `""` | no | | mongodb\_primary\_timeframe | 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`] | string | `"last_1m"` | no | | mongodb\_replication\_aggregator | Monitor aggregator for MongoDB replication lag [available values: min, max, sum or avg] | string | `"avg"` | no | | mongodb\_replication\_enabled | Flag to enable MongoDB replication lag monitor | string | `"true"` | no | -| mongodb\_replication\_extra\_tags | Extra tags for MongoDB replication lag monitor | list | `[]` | no | +| mongodb\_replication\_extra\_tags | Extra tags for MongoDB replication lag monitor | list(string) | `[]` | no | | mongodb\_replication\_message | Custom message for MongoDB replication monitor | string | `""` | no | | mongodb\_replication\_timeframe | 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`] | string | `"last_1m"` | no | | mongodb\_secondary\_aggregator | Monitor aggregator for MongoDB secondary state [available values: min, max] | string | `"max"` | no | | mongodb\_secondary\_enabled | Flag to enable MongoDB secondary state monitor | string | `"true"` | no | -| mongodb\_secondary\_extra\_tags | Extra tags for MongoDB secondary state monitor | list | `[]` | no | +| mongodb\_secondary\_extra\_tags | Extra tags for MongoDB secondary state monitor | list(string) | `[]` | no | | mongodb\_secondary\_message | Custom message for MongoDB secondary monitor | string | `""` | no | | mongodb\_secondary\_timeframe | 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`] | string | `"last_5m"` | no | | mongodb\_server\_count\_aggregator | Monitor aggregator for MongoDB server count [available values: min, max] | string | `"min"` | no | 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..2c92c67 100644 --- a/database/mongodb/monitors-mongo.tf +++ b/database/mongodb/monitors-mongo.tf @@ -1,113 +1,109 @@ 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 - - type = "metric alert" - +EOQ + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay notify_no_data = true renotify_interval = 0 - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.new_host_delay}" notify_audit = false timeout_h = 0 include_tags = true require_full_window = true - tags = ["env:${var.environment}", "type:database", "provider:mongo", "resource:mongodb", "team:claranet", "created-by:terraform", "${var.mongodb_primary_extra_tags}"] + tags = concat(["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}" + 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)}" + message = coalesce(var.mongodb_secondary_message, var.message) + type = "query alert" query = < 1 - EOQ +EOQ - thresholds { + 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 - 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 = concat(["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}" + 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)}" + message = coalesce(var.mongodb_server_count_message, var.message) + type = "metric alert" - query = < 99 - EOQ +EOQ - thresholds { + thresholds = { critical = 99 - warning = "${var.mongodb_desired_servers_count}" + 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 - 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 = concat(["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}" + 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)}" + 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 = concat(["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/mysql/README.md b/database/mysql/README.md index f8cc345..122f1ce 100644 --- a/database/mysql/README.md +++ b/database/mysql/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-database-mysql" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//database/mysql?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -36,33 +36,33 @@ Creates DataDog monitors with the following checks: | filter\_tags\_use\_defaults | Use default filter tags convention | string | `"true"` | no | | message | Message sent when an alert is triggered | string | n/a | yes | | mysql\_aborted\_enabled | Flag to enable MySQL aborted connects monitor | string | `"true"` | no | -| mysql\_aborted\_extra\_tags | Extra tags for MySQL aborted connects monitor | list | `[]` | no | +| mysql\_aborted\_extra\_tags | Extra tags for MySQL aborted connects monitor | list(string) | `[]` | no | | mysql\_aborted\_message | Custom message for MySQL aborted connects monitor | string | `""` | no | | mysql\_aborted\_threshold\_critical | Maximum critical acceptable percent of aborted connects | string | `"10"` | no | | mysql\_aborted\_threshold\_warning | Maximum warning acceptable percent of aborted connects | string | `"5"` | no | | mysql\_aborted\_time\_aggregator | Monitor time aggregator for MySQL aborted connects monitor [available values: min, max or avg] | string | `"avg"` | no | | mysql\_aborted\_timeframe | 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`] | string | `"last_10m"` | no | | mysql\_availability\_enabled | Flag to enable Mysql availability monitor | string | `"true"` | no | -| mysql\_availability\_extra\_tags | Extra tags for Mysql availability monitor | list | `[]` | no | +| mysql\_availability\_extra\_tags | Extra tags for Mysql availability monitor | list(string) | `[]` | no | | mysql\_availability\_message | Custom message for Mysql availability monitor | string | `""` | no | | mysql\_availability\_no\_data\_timeframe | Mysql availability monitor no data timeframe | string | `"10"` | no | | mysql\_availability\_threshold\_warning | Mysql availability monitor (warning threshold) | string | `"3"` | no | | mysql\_connection\_enabled | Flag to enable MySQL connection monitor | string | `"true"` | no | -| mysql\_connection\_extra\_tags | Extra tags for MySQL connection monitor | list | `[]` | no | +| mysql\_connection\_extra\_tags | Extra tags for MySQL connection monitor | list(string) | `[]` | no | | mysql\_connection\_message | Custom message for MySQL connection monitor | string | `""` | no | | mysql\_connection\_threshold\_critical | Maximum critical acceptable percent of connections | string | `"80"` | no | | mysql\_connection\_threshold\_warning | Maximum warning acceptable percent of connections | string | `"70"` | no | | mysql\_connection\_time\_aggregator | Monitor time aggregator for MySQL connection monitor [available values: min, max or avg] | string | `"avg"` | no | | mysql\_connection\_timeframe | 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`] | string | `"last_10m"` | no | | mysql\_pool\_efficiency\_enabled | Flag to enable MySQL innodb buffer pool efficiency monitor | string | `"true"` | no | -| mysql\_pool\_efficiency\_extra\_tags | Extra tags for MySQL innodb buffer pool efficiency monitor | list | `[]` | no | +| mysql\_pool\_efficiency\_extra\_tags | Extra tags for MySQL innodb buffer pool efficiency monitor | list(string) | `[]` | no | | mysql\_pool\_efficiency\_message | Custom message for MySQL innodb buffer pool efficiency monitor | string | `""` | no | | mysql\_pool\_efficiency\_threshold\_critical | Maximum critical acceptable percent of innodb buffer pool efficiency | string | `"30"` | no | | mysql\_pool\_efficiency\_threshold\_warning | Maximum warning acceptable percent of innodb buffer pool efficiency | string | `"20"` | no | | mysql\_pool\_efficiency\_time\_aggregator | Monitor time aggregator for MySQL innodb buffer pool efficiency monitor [available values: min, max or avg] | string | `"min"` | no | | mysql\_pool\_efficiency\_timeframe | 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`] | string | `"last_1h"` | no | | mysql\_pool\_utilization\_enabled | Flag to enable MySQL innodb buffer pool utilization monitor | string | `"true"` | no | -| mysql\_pool\_utilization\_extra\_tags | Extra tags for MySQL innodb buffer pool utilization monitor | list | `[]` | no | +| mysql\_pool\_utilization\_extra\_tags | Extra tags for MySQL innodb buffer pool utilization monitor | list(string) | `[]` | no | | mysql\_pool\_utilization\_message | Custom message for MySQL innodb buffer pool utilization monitor | string | `""` | no | | mysql\_pool\_utilization\_threshold\_critical | Maximum critical acceptable percent of innodb buffer pool utilization | string | `"95"` | no | | mysql\_pool\_utilization\_threshold\_warning | Maximum warning acceptable percent of innodb buffer pool utilization | string | `"80"` | no | @@ -74,7 +74,7 @@ Creates DataDog monitors with the following checks: | mysql\_questions\_deviations | Deviations to detect the anomaly | string | `"5"` | no | | mysql\_questions\_direction | Direction of the anomaly. It can be both, below or above. | string | `"both"` | no | | mysql\_questions\_enabled | Flag to enable mysql queries monitor | string | `"true"` | no | -| mysql\_questions\_extra\_tags | Extra tags for MySQL queries monitor | list | `[]` | no | +| mysql\_questions\_extra\_tags | Extra tags for MySQL queries monitor | list(string) | `[]` | no | | mysql\_questions\_interval | Interval. | string | `"60"` | no | | mysql\_questions\_message | Custom message for MySQL queries monitor | string | `""` | no | | mysql\_questions\_seasonality | Seasonality of the algorithm | string | `"daily"` | no | @@ -82,7 +82,7 @@ Creates DataDog monitors with the following checks: | mysql\_questions\_time\_aggregator | Monitor time aggregator for MySQL queries monitor [available values: min, max or avg] | string | `"avg"` | no | | mysql\_questions\_timeframe | 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`] | string | `"last_4h"` | no | | mysql\_slow\_enabled | Flag to enable MySQL slow queries monitor | string | `"true"` | no | -| mysql\_slow\_extra\_tags | Extra tags for MySQL slow queries monitor | list | `[]` | no | +| mysql\_slow\_extra\_tags | Extra tags for MySQL slow queries monitor | list(string) | `[]` | no | | mysql\_slow\_message | Custom message for MySQL slow queries monitor | string | `""` | no | | mysql\_slow\_threshold\_critical | Maximum critical acceptable percent of slow queries | string | `"20"` | no | | mysql\_slow\_threshold\_warning | Maximum warning acceptable percent of slow queries | string | `"5"` | no | @@ -94,7 +94,7 @@ Creates DataDog monitors with the following checks: | mysql\_threads\_deviations | Deviations to detect the anomaly | string | `"2"` | no | | mysql\_threads\_direction | Direction of the anomaly. It can be both, below or above. | string | `"above"` | no | | mysql\_threads\_enabled | Flag to enable mysql threads monitor | string | `"true"` | no | -| mysql\_threads\_extra\_tags | Extra tags for MySQL threads monitor | list | `[]` | no | +| mysql\_threads\_extra\_tags | Extra tags for MySQL threads monitor | list(string) | `[]` | no | | mysql\_threads\_interval | Interval. | string | `"60"` | no | | mysql\_threads\_message | Custom message for MySQL threads monitor | string | `""` | no | | mysql\_threads\_seasonality | Seasonality of the algorithm | string | `"daily"` | no | 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..34d5697 100644 --- a/database/mysql/monitors-mysql.tf +++ b/database/mysql/monitors-mysql.tf @@ -1,22 +1,21 @@ 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)}" - - type = "service check" + 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 - tags = ["env:${var.environment}", "type:database", "provider:mysql", "resource:mysql", "team:claranet", "created-by:terraform", "${var.mysql_connection_extra_tags}"] + tags = concat(["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}" + 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)}" + 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 - tags = ["env:${var.environment}", "type:database", "provider:mysql", "resource:mysql", "team:claranet", "created-by:terraform", "${var.mysql_aborted_extra_tags}"] + tags = concat(["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}" + 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)}" + 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 = concat(["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 } + 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_pool_efficiency_extra_tags}"] + tags = concat(["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}" + 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)}" + 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 - tags = ["env:${var.environment}", "type:database", "provider:mysql", "resource:mysql", "team:claranet", "created-by:terraform", "${var.mysql_pool_utilization_extra_tags}"] + tags = concat(["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}" + 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)}" + 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}" + thresholds = { + critical = var.mysql_threads_threshold_critical critical_recovery = 0 } + threshold_windows = { + trigger_window = var.mysql_threads_alert_window + recovery_window = var.mysql_threads_alert_window + } + + 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_threads_extra_tags}"] + tags = concat(["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}" + 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)}" + 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 } + threshold_windows = { + trigger_window = var.mysql_questions_alert_window + recovery_window = var.mysql_questions_alert_window + } + + 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 = concat(["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/postgresql/README.md b/database/postgresql/README.md index 3e64833..784e152 100644 --- a/database/postgresql/README.md +++ b/database/postgresql/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-database-postgresql" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//database/postgresql?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -32,19 +32,19 @@ Creates DataDog monitors with the following checks: | message | Message sent when an alert is triggered | string | n/a | yes | | new\_host\_delay | Delay in seconds for the metric evaluation | string | `"300"` | no | | postgresql\_availability\_enabled | Flag to enable PostgreSQL availability monitor | string | `"true"` | no | -| postgresql\_availability\_extra\_tags | Extra tags for PostgreSQL availability monitor | list | `[]` | no | +| postgresql\_availability\_extra\_tags | Extra tags for PostgreSQL availability monitor | list(string) | `[]` | no | | postgresql\_availability\_message | Custom message for PostgreSQL availability monitor | string | `""` | no | | postgresql\_availability\_no\_data\_timeframe | PostgreSQL availability monitor no data timeframe | string | `"10"` | no | | postgresql\_availability\_threshold\_warning | PostgreSQL availability monitor (warning threshold) | string | `"3"` | no | | postgresql\_connection\_enabled | Flag to enable PostgreSQL connection monitor | string | `"true"` | no | -| postgresql\_connection\_extra\_tags | Extra tags for PostgreSQL connection connects monitor | list | `[]` | no | +| postgresql\_connection\_extra\_tags | Extra tags for PostgreSQL connection connects monitor | list(string) | `[]` | no | | postgresql\_connection\_message | Custom message for PostgreSQL connection monitor | string | `""` | no | | postgresql\_connection\_threshold\_critical | Maximum critical acceptable percent of connections | string | `"80"` | no | | postgresql\_connection\_threshold\_warning | Maximum warning acceptable percent of connections | string | `"70"` | no | | postgresql\_connection\_time\_aggregator | Monitor time aggregator for PostgreSQL connection monitor [available values: min, max or avg] | string | `"avg"` | no | | postgresql\_connection\_timeframe | 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`] | string | `"last_15m"` | no | | postgresql\_lock\_enabled | Flag to enable PostgreSQL lock monitor | string | `"true"` | no | -| postgresql\_lock\_extra\_tags | Extra tags for PostgreSQL lock connects monitor | list | `[]` | no | +| postgresql\_lock\_extra\_tags | Extra tags for PostgreSQL lock connects monitor | list(string) | `[]` | no | | postgresql\_lock\_message | Custom message for PostgreSQL lock monitor | string | `""` | no | | postgresql\_lock\_threshold\_critical | Maximum critical acceptable number of locks | string | `"99"` | no | | postgresql\_lock\_threshold\_warning | Maximum warning acceptable number of locks | string | `"70"` | no | 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..f0f91b3 100644 --- a/database/postgresql/monitors-postgresql.tf +++ b/database/postgresql/monitors-postgresql.tf @@ -1,22 +1,21 @@ 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)}" - - type = "service check" + 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 - tags = ["env:${var.environment}", "type:database", "provider:postgres", "resource:postgresql", "team:claranet", "created-by:terraform", "${var.postgresql_connection_extra_tags}"] + tags = concat(["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}" + 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)}" + 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}" + 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}"] + tags = concat(["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/redis/README.md b/database/redis/README.md index 713b84b..ecfdbb7 100644 --- a/database/redis/README.md +++ b/database/redis/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-database-redis" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//database/redis?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -32,7 +32,7 @@ Creates DataDog monitors with the following checks: | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| | blocked\_clients\_enabled | Flag to enable Redis Blocked clients monitor | string | `"true"` | no | -| blocked\_clients\_extra\_tags | Extra tags for Redis Blocked clients monitor | list | `[]` | no | +| blocked\_clients\_extra\_tags | Extra tags for Redis Blocked clients monitor | list(string) | `[]` | no | | blocked\_clients\_message | Custom message for Redis Blocked clients monitor | string | `""` | no | | blocked\_clients\_threshold\_critical | Blocked clients rate (critical threshold) | string | `"30"` | no | | blocked\_clients\_threshold\_warning | Blocked clients rate (warning threshold) | string | `"10"` | no | @@ -41,14 +41,14 @@ Creates DataDog monitors with the following checks: | environment | Architecture environment | string | n/a | yes | | evaluation\_delay | Delay in seconds for the metric evaluation | string | `"15"` | no | | evictedkeys\_change\_enabled | Flag to enable Redis evicted keys monitor | string | `"true"` | no | -| evictedkeys\_change\_extra\_tags | Extra tags for Redis evicted keys monitor | list | `[]` | no | +| evictedkeys\_change\_extra\_tags | Extra tags for Redis evicted keys monitor | list(string) | `[]` | no | | evictedkeys\_change\_message | Custom message for Redis evicted keys monitor | string | `""` | no | | evictedkeys\_change\_threshold\_critical | Evicted keys change (critical threshold) | string | `"100"` | no | | evictedkeys\_change\_threshold\_warning | Evicted keys change (warning threshold) | string | `"20"` | no | | evictedkeys\_change\_time\_aggregator | Monitor aggregator for Redis evicted keys [available values: min, max or avg] | string | `"avg"` | no | | evictedkeys\_change\_timeframe | 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`] | string | `"last_5m"` | no | | expirations\_rate\_enabled | Flag to enable Redis keys expirations monitor | string | `"true"` | no | -| expirations\_rate\_extra\_tags | Extra tags for Redis keys expirations monitor | list | `[]` | no | +| expirations\_rate\_extra\_tags | Extra tags for Redis keys expirations monitor | list(string) | `[]` | no | | expirations\_rate\_message | Custom message for Redis keys expirations monitor | string | `""` | no | | expirations\_rate\_threshold\_critical | Expirations percent (critical threshold) | string | `"80"` | no | | expirations\_rate\_threshold\_warning | Expirations percent (warning threshold) | string | `"60"` | no | @@ -58,35 +58,35 @@ Creates DataDog monitors with the following checks: | filter\_tags\_custom\_excluded | Tags excluded for custom filtering when filter_tags_use_defaults is false | string | `""` | no | | filter\_tags\_use\_defaults | Use default filter tags convention | string | `"true"` | no | | hitrate\_enabled | Flag to enable Redis hitrate monitor | string | `"true"` | no | -| hitrate\_extra\_tags | Extra tags for Redis hitrate monitor | list | `[]` | no | +| hitrate\_extra\_tags | Extra tags for Redis hitrate monitor | list(string) | `[]` | no | | hitrate\_message | Custom message for Redis hitrate monitor | string | `""` | no | | hitrate\_threshold\_critical | hitrate limit (critical threshold) | string | `"10"` | no | | hitrate\_threshold\_warning | hitrate limit (warning threshold) | string | `"30"` | no | | hitrate\_time\_aggregator | Monitor aggregator for Redis hitrate [available values: min, max or avg] | string | `"max"` | no | | hitrate\_timeframe | Monitor timeframe for Redis hitrate [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_5m"` | no | | keyspace\_enabled | Flag to enable Redis keyspace monitor | string | `"true"` | no | -| keyspace\_extra\_tags | Extra tags for Redis keyspace monitor | list | `[]` | no | +| keyspace\_extra\_tags | Extra tags for Redis keyspace monitor | list(string) | `[]` | no | | keyspace\_message | Custom message for Redis keyspace monitor | string | `""` | no | | keyspace\_threshold\_critical | Keyspace no changement (critical threshold) | string | `"0"` | no | | keyspace\_threshold\_warning | Keyspace no changement (warning threshold) | string | `"1"` | no | | keyspace\_time\_aggregator | Monitor aggregator for Redis keyspace [available values: min, max or avg] | string | `"min"` | no | | keyspace\_timeframe | Monitor timeframe for Redis keyspace [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_5m"` | no | | latency\_enabled | Flag to enable Redis latency monitor | string | `"true"` | no | -| latency\_extra\_tags | Extra tags for Redis latency monitor | list | `[]` | no | +| latency\_extra\_tags | Extra tags for Redis latency monitor | list(string) | `[]` | no | | latency\_message | Custom message for Redis latency monitor | string | `""` | no | | latency\_threshold\_critical | latency limit (critical threshold) | string | `"100"` | no | | latency\_threshold\_warning | latency limit (warning threshold) | string | `"50"` | no | | latency\_time\_aggregator | Monitor aggregator for Redis latency [available values: min, max or avg] | string | `"min"` | no | | latency\_timeframe | Monitor timeframe for Redis latency [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_5m"` | no | | mem\_frag\_enabled | Flag to enable Redis memory RAM fragmentation monitor | string | `"true"` | no | -| mem\_frag\_extra\_tags | Extra tags for Redis memory RAM fragmentation monitor | list | `[]` | no | +| mem\_frag\_extra\_tags | Extra tags for Redis memory RAM fragmentation monitor | list(string) | `[]` | no | | mem\_frag\_message | Custom message for Redis memory RAM fragmentation monitor | string | `""` | no | | mem\_frag\_threshold\_critical | memory RAM fragmentation limit (critical threshold) | string | `"150"` | no | | mem\_frag\_threshold\_warning | memory RAM fragmentation limit (warning threshold) | string | `"130"` | no | | mem\_frag\_time\_aggregator | Monitor aggregator for Redis memory RAM fragmentation [available values: min, max or avg] | string | `"min"` | no | | mem\_frag\_timeframe | 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`] | string | `"last_5m"` | no | | mem\_used\_enabled | Flag to enable Redis RAM memory used monitor | string | `"true"` | no | -| mem\_used\_extra\_tags | Extra tags for Redis RAM memory used monitor | list | `[]` | no | +| mem\_used\_extra\_tags | Extra tags for Redis RAM memory used monitor | list(string) | `[]` | no | | mem\_used\_message | Custom message for Redis RAM memory used monitor | string | `""` | no | | mem\_used\_threshold\_critical | RAM memory used limit (critical threshold) | string | `"95"` | no | | mem\_used\_threshold\_warning | RAM memory used limit (warning threshold) | string | `"85"` | no | @@ -95,13 +95,13 @@ Creates DataDog monitors with the following checks: | message | Message sent when a Redis monitor is triggered | string | n/a | yes | | new\_host\_delay | Delay in seconds for the metric evaluation | string | `"300"` | no | | not\_responding\_enabled | Flag to enable Redis does not respond monitor | string | `"true"` | no | -| not\_responding\_extra\_tags | Extra tags for Redis does not respond monitor | list | `[]` | no | +| not\_responding\_extra\_tags | Extra tags for Redis does not respond monitor | list(string) | `[]` | no | | not\_responding\_message | Custom message for Redis does not respond monitor | string | `""` | no | | not\_responding\_no\_data\_timeframe | Redis does not respond monitor no data timeframe | string | `"10"` | no | | not\_responding\_threshold\_warning | Redis does not respond monitor (warning threshold) | string | `"3"` | no | | prefix\_slug | Prefix string to prepend between brackets on every monitors names | string | `""` | no | | rejected\_con\_enabled | Flag to enable Redis rejected connections errors monitor | string | `"true"` | no | -| rejected\_con\_extra\_tags | Extra tags for Redis rejected connections errors monitor | list | `[]` | no | +| rejected\_con\_extra\_tags | Extra tags for Redis rejected connections errors monitor | list(string) | `[]` | no | | rejected\_con\_message | Custom message for Redis rejected connections errors monitor | string | `""` | no | | rejected\_con\_threshold\_critical | rejected connections errors limit (critical threshold) | string | `"50"` | no | | rejected\_con\_threshold\_warning | rejected connections errors limit (warning threshold) | string | `"10"` | no | 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..6352db8 100644 --- a/database/redis/monitors-redis.tf +++ b/database/redis/monitors-redis.tf @@ -2,23 +2,23 @@ # 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)}" - - type = "service check" + 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 - 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 = concat(["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}" + 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)}" + 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 - 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 = concat(["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}" + 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)}" + 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 = concat(["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 - 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 = concat(["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}" + 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)}" + 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 - 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 = concat(["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}" + 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)}" + 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 = concat(["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 } + 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.latency_extra_tags}"] + tags = concat(["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}" + 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)}" + 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}" + thresholds = { + critical = var.nginx_dropped_threshold_critical } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay 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}"] + tags = concat(["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/php-fpm/README.md b/middleware/php-fpm/README.md index 45d1082..f0d05a0 100644 --- a/middleware/php-fpm/README.md +++ b/middleware/php-fpm/README.md @@ -6,8 +6,8 @@ module "datadog-monitors-middleware-php-fpm" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//middleware/php-fpm?ref={revision}" - environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message } ``` @@ -31,14 +31,14 @@ Creates DataDog monitors with the following checks: | message | Message sent when an alert is triggered | string | n/a | yes | | new\_host\_delay | Delay in seconds before monitor new resource | string | `"300"` | no | | php\_fpm\_busy\_enabled | Flag to enable PHP FPM busy worker monitor | string | `"true"` | no | -| php\_fpm\_busy\_extra\_tags | Extra tags for PHP FPM busy worker monitor | list | `[]` | no | +| php\_fpm\_busy\_extra\_tags | Extra tags for PHP FPM busy worker monitor | list(string) | `[]` | no | | php\_fpm\_busy\_message | Custom message for PHP FPM busy worker monitor | string | `""` | no | | php\_fpm\_busy\_threshold\_critical | php fpm busy critical threshold | string | `"90"` | no | | php\_fpm\_busy\_threshold\_warning | php fpm busy warning threshold | string | `"80"` | no | | php\_fpm\_busy\_time\_aggregator | Monitor aggregator for PHP FPM busy worker [available values: min, max or avg] | string | `"avg"` | no | | php\_fpm\_busy\_timeframe | 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`] | string | `"last_10m"` | no | | php\_fpm\_connect\_enabled | Flag to enable PHP FPM status monitor | string | `"true"` | no | -| php\_fpm\_connect\_extra\_tags | Extra tags for PHP FPM status monitor | list | `[]` | no | +| php\_fpm\_connect\_extra\_tags | Extra tags for PHP FPM status monitor | list(string) | `[]` | no | | php\_fpm\_connect\_message | Custom message for PHP FPM status monitor | string | `""` | no | | php\_fpm\_connect\_no\_data\_timeframe | PHP FPM status monitor no data timeframe | string | `"10"` | no | | php\_fpm\_connect\_threshold\_warning | PHP FPM status monitor (warning threshold) | string | `"3"` | no | 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..11e6323 100644 --- a/middleware/php-fpm/monitors-fpm.tf +++ b/middleware/php-fpm/monitors-fpm.tf @@ -1,22 +1,21 @@ 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)}" - - type = "service check" + 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}" + 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 - 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}"] + tags = concat(["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/scripts/01_update_output.sh b/scripts/01_update_output.sh index f11cbd2..eb0167f 100755 --- a/scripts/01_update_output.sh +++ b/scripts/01_update_output.sh @@ -5,7 +5,7 @@ source "$(dirname $0)/utils.sh" goto_root # loop over every monitors set -for path in $(find "$(get_scope $1)" -path ./incubator -prune -o -name 'monitors-*.tf' -print | sort -fdbi); do +for path in $(find "$(get_scope $1)" -name 'monitors-*.tf' -print | sort -fdbi); do cd $(dirname $path) # empty outputs > outputs.tf @@ -15,7 +15,7 @@ for path in $(find "$(get_scope $1)" -path ./incubator -prune -o -name 'monitors cat >> outputs.tf <> README.md # loop over all ready monitors sets on the repo -for path in $(find -mindepth 1 \( -path './incubator' -o -path './scripts' -o -path './testing' -o -path '*/\.*' \) -prune -o -type d -print | sort -fdbi); do +for path in $(find -mindepth 1 -type d ! -path '*/.*' ! -path './scripts*' -print | sort -fdbi); do # split path in directories directories=($(list_dirs $path)) # loop over directories in path @@ -32,7 +36,7 @@ done PATTERN_DOC="Related documentation" # loop over every monitors set readme -for path in $(find "$(get_scope $1)" -path ./incubator -prune -o -name 'monitors-*.tf' -print | sort -fdbi); do +for path in $(find "$(get_scope $1)" -name 'monitors-*.tf' -print | sort -fdbi); do cd $(dirname $path) EXIST=0 if [ -f README.md ]; then @@ -58,8 +62,8 @@ for path in $(find "$(get_scope $1)" -path ./incubator -prune -o -name 'monitors module "datadog-monitors-${module_dash}" { source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//${module_slash}?ref={revision}" - environment = "\${var.environment}" - message = "\${module.datadog-message-alerting.alerting-message}" + environment = var.environment + message = module.datadog-message-alerting.alerting-message EOF # if README already exist @@ -91,8 +95,12 @@ EOF done IFS=$SAVEIFS echo >> README.md + # hack for terraform-docs with terraform 0.12 / HCL2 support + tmp_tf=$(mktemp -d) + awk -f ${TERRAFORM_AWK} ./*.tf > ${tmp_tf}/main.tf # auto generate terraform docs (inputs and outputs) - terraform-docs --with-aggregate-type-defaults md table ./ >> README.md + terraform-docs --with-aggregate-type-defaults md table ${tmp_tf}/ >> README.md + rm -fr ${tmp_tf} # if README does not exist if [[ $EXIST -eq 0 ]]; then # Simply add empty documentation section diff --git a/scripts/03_update_module.sh b/scripts/03_update_module.sh index 4458c20..6941230 100755 --- a/scripts/03_update_module.sh +++ b/scripts/03_update_module.sh @@ -7,7 +7,7 @@ goto_root root=$(basename ${PWD}) # loop over every monitors set -for path in $(find "$(get_scope $1)" -path ./incubator -prune -o -name 'monitors-*.tf' -print | sort -fdbi); do +for path in $(find "$(get_scope $1)" -name 'monitors-*.tf' -print | sort -fdbi); do cd $(dirname $path) # get name of the monitors set directory resource="$(basename $(dirname $path))" @@ -27,10 +27,10 @@ for path in $(find "$(get_scope $1)" -path ./incubator -prune -o -name 'monitors module "filter-tags" { source = "${relative}common/filter-tags" - environment = "\${var.environment}" + environment = var.environment resource = "$resource" - 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 } EOF fi diff --git a/scripts/90_best_practices.sh b/scripts/90_best_practices.sh index 12be77b..a44afb5 100755 --- a/scripts/90_best_practices.sh +++ b/scripts/90_best_practices.sh @@ -5,7 +5,7 @@ source "$(dirname $0)/utils.sh" goto_root # loop over every monitors set -for path in $(find "$(get_scope $1)" -path ./incubator -prune -o -name 'monitors-*.tf' -print | sort -fdbi); do +for path in $(find "$(get_scope $1)" -name 'monitors-*.tf' -print | sort -fdbi); do # check if there is more than 1 notify_no_data parameter set to true per set of monitors if [[ $(grep -c notify_no_data.*true $path) -gt 1 ]]; then echo "More than one notify_no_data set to true on $path" diff --git a/scripts/99_terraform.sh b/scripts/99_terraform.sh index eb54644..786abf7 100755 --- a/scripts/99_terraform.sh +++ b/scripts/99_terraform.sh @@ -4,10 +4,38 @@ set -xueo pipefail source "$(dirname $0)/utils.sh" goto_root -for path in $(find "$(get_scope $1)" -path ./testing -prune -o -path ./incubator -prune -o -name 'inputs.tf' -print); do +for path in $(find "$(get_scope $1)" -name 'inputs.tf' -print); do dir=$(dirname ${path}) - terraform init ${dir} >> /dev/null 2>&1 - terraform validate -check-variables=false ${dir} -done + cat < ${dir}/tmp.tf +provider "datadog" { + version = "2.0.2" -terraform fmt + api_key = var.datadog_api_key + app_key = var.datadog_app_key +} + +variable "datadog_api_key" { + type = string + default = "xxx" +} + +variable "datadog_app_key" { + type = string + default = "yyy" +} + +EOF + if [ -f ${dir}/test.tf.ci ]; then + cat ${dir}/test.tf.ci >> ${dir}/tmp.tf + fi + terraform init ${dir} + terraform validate ${dir} + rm -f ${dir}/tmp.tf + # hack to work around bug https://github.com/hashicorp/terraform/issues/21434 + # TODO when fixed, remove this bloc and add "terraform fmt -recursive" to the end of this file + for file in $(grep ' = < ${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 } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay 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-check", "resource:generic", "team:claranet", "created-by:terraform", "${var.cpu_extra_tags}"] + tags = concat(["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}" + 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)}" + 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 - 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 = concat(["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}" + 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)}" + 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 - 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 = concat(["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,64 +125,59 @@ 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 = concat(["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 } + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay 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_inodes_extra_tags}"] + tags = concat(["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}" + 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}" + message = var.memory_message + type = "query alert" query = <