diff --git a/cloud/azure/redis/README.md b/cloud/azure/redis/README.md new file mode 100644 index 0000000..4cd7a51 --- /dev/null +++ b/cloud/azure/redis/README.md @@ -0,0 +1,47 @@ +Azure Redis DataDog monitors +============================ + +How to use this module +---------------------- + +``` +module "datadog-monitors-azure-redis" { + source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/azure/redis?ref={revision}" + + message = "${module.datadog-message-alerting.alerting-message}" + environment = "${var.environment}" +} +``` + +Purpose +------- +Creates a DataDog monitors with the following checks : + +* Service status check +* Evicted keys count check +* Processor time (percent) threshold +* Server CPU load threshold + +Inputs +------ + +| Name | Description | Type | Default | Required | +|------|-------------|:----:|:-----:|:-----:| +| delay | Delay in seconds for the metric evaluation | string | `600` | no | +| environment | Architecture environment | string | - | yes | +| evictedkeys_limit_threshold_critical | Evicted keys limit (critical threshold) | string | `100` | no | +| evictedkeys_limit_threshold_warning | Evicted keys limit (warning threshold) | string | `0` | no | +| 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 | +| message | Message sent when a Redis monitor is triggered | string | - | yes | +| 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 | +| 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 | + +Related documentation +--------------------- + +DataDog documentation: [https://docs.datadoghq.com/integrations/azure_redis_cache/](https://docs.datadoghq.com/integrations/azure_redis_cache/) + +Azure Redis metrics documentation: [https://docs.microsoft.com/en-us/azure/redis-cache/cache-how-to-monitor](https://docs.microsoft.com/en-us/azure/redis-cache/cache-how-to-monitor) diff --git a/cloud/azure/redis/inputs.tf b/cloud/azure/redis/inputs.tf new file mode 100644 index 0000000..49750fa --- /dev/null +++ b/cloud/azure/redis/inputs.tf @@ -0,0 +1,56 @@ +# Global Terraform +variable "environment" { + description = "Architecture environment" + type = "string" +} + +# Global DataDog +variable "message" { + description = "Message sent when a Redis monitor is triggered" +} + +variable "delay" { + description = "Delay in seconds for the metric evaluation" + default = 600 +} + +variable "filter_tags_use_defaults" { + description = "Use default filter tags convention" + default = "true" +} + +variable "filter_tags_custom" { + description = "Tags used for custom filtering when filter_tags_use_defaults is false" + default = "*" +} + +# Azure Redis specific +variable "evictedkeys_limit_threshold_warning" { + description = "Evicted keys limit (warning threshold)" + default = 0 +} + +variable "evictedkeys_limit_threshold_critical" { + description = "Evicted keys limit (critical threshold)" + default = 100 +} + +variable "percent_processor_time_threshold_critical" { + description = "Processor time percent (critical threshold)" + default = 80 +} + +variable "percent_processor_time_threshold_warning" { + description = "Processor time percent (warning threshold)" + default = 60 +} + +variable "server_load_rate_threshold_critical" { + description = "Server CPU load rate (critical threshold)" + default = 90 +} + +variable "server_load_rate_threshold_warning" { + description = "Server CPU load rate (warning threshold)" + default = 70 +} diff --git a/cloud/azure/redis/monitors-azure-redis.tf b/cloud/azure/redis/monitors-azure-redis.tf new file mode 100644 index 0000000..57b3a6c --- /dev/null +++ b/cloud/azure/redis/monitors-azure-redis.tf @@ -0,0 +1,124 @@ +data "template_file" "filter" { + template = "$${filter}" + + vars { + filter = "${var.filter_tags_use_defaults == "true" ? format("dd_monitoring:enabled,dd_azure_redis:enabled,env:%s", var.environment) : "${var.filter_tags_custom}"}" + } +} + +resource "datadog_monitor" "status" { + name = "[${var.environment}] Redis {{name}} is down" + message = "${var.message}" + + query = < ${var.evictedkeys_limit_threshold_critical} +EOF + + type = "metric alert" + + thresholds { + warning = "${var.evictedkeys_limit_threshold_warning}" + critical = "${var.evictedkeys_limit_threshold_critical}" + } + + notify_no_data = false + evaluation_delay = "${var.delay}" + renotify_interval = 0 + notify_audit = false + timeout_h = 0 + include_tags = true + locked = false + require_full_window = true + new_host_delay = "${var.delay}" + no_data_timeframe = 20 + + tags = ["env:${var.environment}", "resource:redis", "team:azure", "provider:azure"] +} + +resource "datadog_monitor" "percent_processor_time" { + name = "[${var.environment}] Redis processor time {{value}}% on {{name}}" + message = "${var.message}" + + query = < ${var.percent_processor_time_threshold_critical} +EOF + + type = "metric alert" + + thresholds { + warning = "${var.percent_processor_time_threshold_warning}" + critical = "${var.percent_processor_time_threshold_critical}" + } + + notify_no_data = false + evaluation_delay = "${var.delay}" + renotify_interval = 0 + notify_audit = false + timeout_h = 0 + include_tags = true + locked = false + require_full_window = true + new_host_delay = "${var.delay}" + no_data_timeframe = 20 + + tags = ["env:${var.environment}", "resource:redis", "team:azure", "provider:azure"] +} + +resource "datadog_monitor" "server_load" { + name = "[${var.environment}] Redis processor server load {{value}}% on {{name}}" + message = "${var.message}" + + query = < ${var.server_load_rate_threshold_critical} +EOF + + type = "metric alert" + + thresholds { + warning = "${var.server_load_rate_threshold_warning}" + critical = "${var.server_load_rate_threshold_critical}" + } + + notify_no_data = false + evaluation_delay = "${var.delay}" + renotify_interval = 0 + notify_audit = false + timeout_h = 0 + include_tags = true + locked = false + require_full_window = true + new_host_delay = "${var.delay}" + no_data_timeframe = 20 + + tags = ["env:${var.environment}", "resource:redis", "team:azure", "provider:azure"] +}