From 753da1173437df811d43b65b651ccb1a98d63122 Mon Sep 17 00:00:00 2001 From: Laurent Piroelle Date: Thu, 23 Nov 2017 17:12:16 +0100 Subject: [PATCH] MON-76 Normalize monitors --- cloud/azure/redis/README.md | 9 +++----- cloud/azure/redis/inputs.tf | 26 ++++++----------------- cloud/azure/redis/monitors-azure-redis.tf | 20 ++++++++--------- 3 files changed, 20 insertions(+), 35 deletions(-) diff --git a/cloud/azure/redis/README.md b/cloud/azure/redis/README.md index 45538d1..4cd7a51 100644 --- a/cloud/azure/redis/README.md +++ b/cloud/azure/redis/README.md @@ -8,9 +8,8 @@ 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}" + message = "${module.datadog-message-alerting.alerting-message}" environment = "${var.environment}" - subscription_id = "${var.subscription_id}" } ``` @@ -32,15 +31,13 @@ Inputs | 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 | -| provider | What is the monitored provider | string | azure | 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 | -| use_filter_tags | Filter the data with service tags if true | string | `true` | no | -| service | What is the monitored service | string | storage | no | -| subscription_id | Azure account id used as filter for monitors | string | - | yes | Related documentation --------------------- diff --git a/cloud/azure/redis/inputs.tf b/cloud/azure/redis/inputs.tf index 7c57d63..49750fa 100644 --- a/cloud/azure/redis/inputs.tf +++ b/cloud/azure/redis/inputs.tf @@ -4,23 +4,6 @@ variable "environment" { type = "string" } -variable "subscription_id" { - description = "Azure account id used as filter for monitors" - type = "string" -} - -variable "provider" { - description = "Cloud provider which the monitor and its based metric depend on" - type = "string" - default = "azure" -} - -variable "service" { - description = "Service monitored by this set of monitors" - type = "string" - default = "storage" -} - # Global DataDog variable "message" { description = "Message sent when a Redis monitor is triggered" @@ -31,11 +14,16 @@ variable "delay" { default = 600 } -variable "use_filter_tags" { - description = "Filter the data with service tags if true" +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)" diff --git a/cloud/azure/redis/monitors-azure-redis.tf b/cloud/azure/redis/monitors-azure-redis.tf index 950e9a1..57b3a6c 100644 --- a/cloud/azure/redis/monitors-azure-redis.tf +++ b/cloud/azure/redis/monitors-azure-redis.tf @@ -2,7 +2,7 @@ data "template_file" "filter" { template = "$${filter}" vars { - filter = "${var.use_filter_tags == "true" ? format("dd_monitoring:enabled,dd_azure_storage:enabled,env:%s", var.environment) : "subscription_id:${var.subscription_id}"}" + filter = "${var.filter_tags_use_defaults == "true" ? format("dd_monitoring:enabled,dd_azure_redis:enabled,env:%s", var.environment) : "${var.filter_tags_custom}"}" } } @@ -14,9 +14,9 @@ resource "datadog_monitor" "status" { avg(last_5m):avg:azure.cache_redis.status{${data.template_file.filter.rendered}} by {name,resource_group} != 1 EOF - type = "query alert" + type = "metric alert" - notify_no_data = false + notify_no_data = true evaluation_delay = "${var.delay}" renotify_interval = 0 notify_audit = false @@ -27,7 +27,7 @@ EOF new_host_delay = "${var.delay}" no_data_timeframe = 20 - tags = ["env:${var.environment}","resource:${var.service}","team:${var.provider}"] + tags = ["env:${var.environment}", "resource:redis", "team:azure", "provider:azure"] } resource "datadog_monitor" "evictedkeys" { @@ -40,7 +40,7 @@ resource "datadog_monitor" "evictedkeys" { ) > ${var.evictedkeys_limit_threshold_critical} EOF - type = "query alert" + type = "metric alert" thresholds { warning = "${var.evictedkeys_limit_threshold_warning}" @@ -58,7 +58,7 @@ EOF new_host_delay = "${var.delay}" no_data_timeframe = 20 - tags = ["env:${var.environment}","resource:${var.service}","team:${var.provider}"] + tags = ["env:${var.environment}", "resource:redis", "team:azure", "provider:azure"] } resource "datadog_monitor" "percent_processor_time" { @@ -71,7 +71,7 @@ resource "datadog_monitor" "percent_processor_time" { ) > ${var.percent_processor_time_threshold_critical} EOF - type = "query alert" + type = "metric alert" thresholds { warning = "${var.percent_processor_time_threshold_warning}" @@ -89,7 +89,7 @@ EOF new_host_delay = "${var.delay}" no_data_timeframe = 20 - tags = ["env:${var.environment}","resource:${var.service}","team:${var.provider}"] + tags = ["env:${var.environment}", "resource:redis", "team:azure", "provider:azure"] } resource "datadog_monitor" "server_load" { @@ -102,7 +102,7 @@ resource "datadog_monitor" "server_load" { ) > ${var.server_load_rate_threshold_critical} EOF - type = "query alert" + type = "metric alert" thresholds { warning = "${var.server_load_rate_threshold_warning}" @@ -120,5 +120,5 @@ EOF new_host_delay = "${var.delay}" no_data_timeframe = 20 - tags = ["env:${var.environment}","resource:${var.service}","team:${var.provider}"] + tags = ["env:${var.environment}", "resource:redis", "team:azure", "provider:azure"] }