diff --git a/cloud/aws/elasticache/memcached/README.md b/cloud/aws/elasticache/memcached/README.md new file mode 100644 index 0000000..c73e482 --- /dev/null +++ b/cloud/aws/elasticache/memcached/README.md @@ -0,0 +1,45 @@ +AWS ElasticCache Memcached Service DataDog monitors +=================================================== + +How to use this module +---------------------- + +``` +module "datadog-monitors-aws-elasticcache-redis" { + source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/aws/elasticache/memcached?ref={revision}" + + message = "${module.datadog-message-alerting.alerting-message}" + environment = "${var.environment}" +} + +``` + +Purpose +------- +Creates DataDog monitors with the following checks : + +* Get requests missed + +Inputs +------ + +| Name | Description | Type | Default | Required | +|------|-------------|:----:|:-----:|:-----:| +| delay | Delay in seconds for the metric evaluation | string | `900` | no | +| environment | Architecture Environment | string | - | yes | +| 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 | +| get_requests_miss_aggregator | Monitor aggregator for Elasticache Memcached get requests missed [available values: min, max, sum or avg] | string | `min` | no | +| get_requests_miss_message | Custom message for Elasticache Memcached get requests missed monitor | string | `` | no | +| get_requests_miss_silenced | Groups to mute for Elasticache Memcached get requests missed monitor | map | `` | no | +| get_requests_miss_threshold_critical | Elasticache Memcached get requests missed critical threshold in percentage | string | `95` | no | +| get_requests_miss_threshold_warning | Elasticache Memcached get requests missed warning threshold in percentage | string | `80` | no | +| get_requests_miss_timeframe | Monitor timeframe for Elasticache Memcached get requests missed [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 | - | yes | + +Related documentation +--------------------- + +DataDog documentation: [https://docs.datadoghq.com/integrations/amazon_elasticache/](https://docs.datadoghq.com/integrations/amazon_elasticache/) + +AWS ElasticSearch Service Instance metrics documentation: [https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/elasticache-metricscollected.html](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/elasticache-metricscollected.html) diff --git a/cloud/aws/elasticache/memcached/inputs.tf b/cloud/aws/elasticache/memcached/inputs.tf new file mode 100644 index 0000000..987e401 --- /dev/null +++ b/cloud/aws/elasticache/memcached/inputs.tf @@ -0,0 +1,59 @@ +# Global Terraform +variable "environment" { + description = "Architecture Environment" + type = "string" +} + +# Global DataDog +variable "delay" { + description = "Delay in seconds for the metric evaluation" + default = 900 +} + +variable "message" { + description = "Message sent when an alert is triggered" +} + +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 = "*" +} + +# Memcached specific +variable "get_requests_miss_silenced" { + description = "Groups to mute for Elasticache Memcached get requests missed monitor" + type = "map" + default = {} +} + +variable "get_requests_miss_message" { + description = "Custom message for Elasticache Memcached get requests missed monitor" + type = "string" + default = "" +} + +variable "get_requests_miss_aggregator" { + description = "Monitor aggregator for Elasticache Memcached get requests missed [available values: min, max, sum or avg]" + type = "string" + default = "min" +} + +variable "get_requests_miss_timeframe" { + description = "Monitor timeframe for Elasticache Memcached get requests missed [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" + default = "last_15m" +} + +variable "get_requests_miss_threshold_warning" { + description = "Elasticache Memcached get requests missed warning threshold in percentage" + default = 80 +} + +variable "get_requests_miss_threshold_critical" { + description = "Elasticache Memcached get requests missed critical threshold in percentage" + default = 95 +} diff --git a/cloud/aws/elasticache/memcached/monitors-memcached.tf b/cloud/aws/elasticache/memcached/monitors-memcached.tf new file mode 100644 index 0000000..0418e3f --- /dev/null +++ b/cloud/aws/elasticache/memcached/monitors-memcached.tf @@ -0,0 +1,41 @@ +data "template_file" "filter" { + template = "$${filter}" + + vars { + filter = "${var.filter_tags_use_defaults == "true" ? format("dd_monitoring:enabled,dd_aws_mem:enabled,env:%s", var.environment) : "${var.filter_tags_custom}"}" + } +} + +resource "datadog_monitor" "memcached_get_miss" { + name = "[${var.environment}] Elasticache Memcached get requests missed {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" + message = "${coalesce(var.get_requests_miss_message, var.message)}" + + type = "metric alert" + + query = < ${var.get_requests_miss_threshold_critical} + EOF + + thresholds { + warning = "${var.get_requests_miss_threshold_warning}" + critical = "${var.get_requests_miss_threshold_critical}" + } + + notify_no_data = true + evaluation_delay = "${var.delay}" + renotify_interval = 0 + notify_audit = false + timeout_h = 0 + include_tags = true + locked = false + require_full_window = false + new_host_delay = "${var.delay}" + + silenced = "${var.get_requests_miss_silenced}" + + tags = ["env:${var.environment}", "resource:memcached", "team:aws", "provider:aws"] +} diff --git a/cloud/aws/elasticache/monitors-elasticache.tf b/cloud/aws/elasticache/monitors-elasticache.tf index 0587feb..798c80e 100644 --- a/cloud/aws/elasticache/monitors-elasticache.tf +++ b/cloud/aws/elasticache/monitors-elasticache.tf @@ -2,7 +2,7 @@ data "template_file" "filter" { template = "$${filter}" vars { - filter = "${var.filter_tags_use_defaults == "true" ? format("dd_monitoring:enabled,dd_aws_es:enabled,env:%s", var.environment) : "${var.filter_tags_custom}"}" + filter = "${var.filter_tags_use_defaults == "true" ? format("dd_monitoring:enabled,dd_aws_ec:enabled,env:%s", var.environment) : "${var.filter_tags_custom}"}" } } diff --git a/cloud/aws/elasticache/redis/README.md b/cloud/aws/elasticache/redis/README.md new file mode 100644 index 0000000..dd09c3e --- /dev/null +++ b/cloud/aws/elasticache/redis/README.md @@ -0,0 +1,45 @@ +AWS ElasticCache Redis Service DataDog monitors +=============================================== + +How to use this module +---------------------- + +``` +module "datadog-monitors-aws-elasticcache-redis" { + source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/aws/elasticache/redis?ref={revision}" + + message = "${module.datadog-message-alerting.alerting-message}" + environment = "${var.environment}" +} + +``` + +Purpose +------- +Creates DataDog monitors with the following checks : + +* Cache Miss + +Inputs +------ + +| Name | Description | Type | Default | Required | +|------|-------------|:----:|:-----:|:-----:| +| cache_miss_aggregator | Monitor aggregator for Elasticache Redis cache miss [available values: min, max, sum or avg] | string | `min` | no | +| cache_miss_message | Custom message for Elasticache Redis cache miss monitor | string | `` | no | +| cache_miss_silenced | Groups to mute for Elasticache Redis cache miss monitor | map | `` | no | +| cache_miss_threshold_critical | Elasticache Redis cache miss critical threshold in percentage | string | `95` | no | +| cache_miss_threshold_warning | Elasticache Redis cache miss warning threshold in percentage | string | `80` | no | +| cache_miss_timeframe | Monitor timeframe for Elasticache Redis cache miss [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_15m` | no | +| delay | Delay in seconds for the metric evaluation | string | `900` | no | +| environment | Architecture Environment | string | - | yes | +| 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 an alert is triggered | string | - | yes | + +Related documentation +--------------------- + +DataDog documentation: [https://docs.datadoghq.com/integrations/amazon_elasticache/](https://docs.datadoghq.com/integrations/amazon_elasticache/) + +AWS ElasticSearch Service Instance metrics documentation: [https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/elasticache-metricscollected.html](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/elasticache-metricscollected.html) diff --git a/cloud/aws/elasticache/redis/inputs.tf b/cloud/aws/elasticache/redis/inputs.tf new file mode 100644 index 0000000..4ca8823 --- /dev/null +++ b/cloud/aws/elasticache/redis/inputs.tf @@ -0,0 +1,59 @@ +# Global Terraform +variable "environment" { + description = "Architecture Environment" + type = "string" +} + +# Global DataDog +variable "delay" { + description = "Delay in seconds for the metric evaluation" + default = 900 +} + +variable "message" { + description = "Message sent when an alert is triggered" +} + +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 = "*" +} + +# Redis specific +variable "cache_miss_silenced" { + description = "Groups to mute for Elasticache Redis cache miss monitor" + type = "map" + default = {} +} + +variable "cache_miss_message" { + description = "Custom message for Elasticache Redis cache miss monitor" + type = "string" + default = "" +} + +variable "cache_miss_aggregator" { + description = "Monitor aggregator for Elasticache Redis cache miss [available values: min, max, sum or avg]" + type = "string" + default = "min" +} + +variable "cache_miss_timeframe" { + description = "Monitor timeframe for Elasticache Redis cache miss [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" + default = "last_15m" +} + +variable "cache_miss_threshold_warning" { + description = "Elasticache Redis cache miss warning threshold in percentage" + default = 80 +} + +variable "cache_miss_threshold_critical" { + description = "Elasticache Redis cache miss critical threshold in percentage" + default = 95 +} diff --git a/cloud/aws/elasticache/redis/monitors-redis.tf b/cloud/aws/elasticache/redis/monitors-redis.tf new file mode 100644 index 0000000..8734541 --- /dev/null +++ b/cloud/aws/elasticache/redis/monitors-redis.tf @@ -0,0 +1,41 @@ +data "template_file" "filter" { + template = "$${filter}" + + vars { + filter = "${var.filter_tags_use_defaults == "true" ? format("dd_monitoring:enabled,dd_aws_red:enabled,env:%s", var.environment) : "${var.filter_tags_custom}"}" + } +} + +resource "datadog_monitor" "redis_cache_miss" { + name = "[${var.environment}] Elasticache Redis cache miss {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" + message = "${coalesce(var.cache_miss_message, var.message)}" + + type = "metric alert" + + query = < ${var.cache_miss_threshold_critical} + EOF + + thresholds { + warning = "${var.cache_miss_threshold_warning}" + critical = "${var.cache_miss_threshold_critical}" + } + + notify_no_data = true + evaluation_delay = "${var.delay}" + renotify_interval = 0 + notify_audit = false + timeout_h = 0 + include_tags = true + locked = false + require_full_window = false + new_host_delay = "${var.delay}" + + silenced = "${var.cache_miss_silenced}" + + tags = ["env:${var.environment}", "resource:redis", "team:aws", "provider:aws"] +}