[WIP]MON-32 - First try

This commit is contained in:
Alexandre Gaillet 2018-05-03 15:44:55 +02:00 committed by Quentin Manfroi
parent fdc0b08647
commit 76d7087505
7 changed files with 291 additions and 1 deletions

View File

@ -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 | `<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)

View File

@ -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
}

View File

@ -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 = <<EOF
${var.get_requests_miss_aggregator}(${var.get_requests_miss_timeframe}): (
${var.get_requests_miss_aggregator}:aws.elasticache.get_misses{${data.template_file.filter.rendered}} by {region,name} /
(${var.get_requests_miss_aggregator}:aws.elasticache.get_hits{${data.template_file.filter.rendered}} by {region,name} +
${var.get_requests_miss_aggregator}:aws.elasticache.get_misses{${data.template_file.filter.rendered}} by {region,name})
) > ${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"]
}

View File

@ -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}"}"
}
}

View File

@ -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 | `<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)

View File

@ -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
}

View File

@ -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 = <<EOF
${var.cache_miss_aggregator}(${var.cache_miss_timeframe}): (
${var.cache_miss_aggregator}:aws.elasticache.cache_misses{${data.template_file.filter.rendered}} by {region,name} /
(${var.cache_miss_aggregator}:aws.elasticache.cache_hits{${data.template_file.filter.rendered}} by {region,name} +
${var.cache_miss_aggregator}:aws.elasticache.cache_misses{${data.template_file.filter.rendered}} by {region,name})
) > ${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"]
}