MON-32 - Memcached monitors added

This commit is contained in:
Alexandre Gaillet 2018-05-15 18:33:56 +02:00 committed by Quentin Manfroi
parent 9e01024563
commit cf66c5c7f3
4 changed files with 113 additions and 35 deletions

View File

@ -16,9 +16,11 @@ module "datadog-monitors-aws-elasticache" {
``` ```
This module is used by default when you define `memcached` or `redis` monitors
Purpose Purpose
------- -------
Creates DataDog monitors with the following checks : Creates DataDog monitors with the following checks:
* Eviction * Eviction

View File

@ -18,28 +18,39 @@ Purpose
------- -------
Creates DataDog monitors with the following checks : Creates DataDog monitors with the following checks :
* Get requests missed * CPU High
* Swap
Inputs Inputs
------ ------
| Name | Description | Type | Default | Required | | Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:| |------|-------------|:----:|:-----:|:-----:|
| cpu_high_aggregator | Monitor aggregator for Elasticache memcached cpu high [available values: min, max, sum or avg] | string | `min` | no |
| cpu_high_message | Custom message for Elasticache memcached cpu high monitor | string | `` | no |
| cpu_high_silenced | Groups to mute for Elasticache memcached cpu high monitor | map | `<map>` | 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 |
| cpu_high_timeframe | 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`] | string | `last_15m` | no |
| delay | Delay in seconds for the metric evaluation | string | `900` | no | | delay | Delay in seconds for the metric evaluation | string | `900` | no |
| environment | Architecture Environment | string | - | yes | | environment | Architecture Environment | string | - | yes |
| filter_tags_custom | Tags used for custom filtering when filter_tags_use_defaults is false | string | `*` | 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 | | 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 | | message | Message sent when an alert is triggered | string | - | yes |
| swap_aggregator | Monitor aggregator for Elasticache memcached swap [available values: min, max, sum or avg] | string | `min` | no |
| swap_message | Custom message for Elasticache memcached swap monitor | string | `` | no |
| swap_silenced | Groups to mute for Elasticache memcached swap monitor | map | `<map>` | no |
| swap_threshold_critical | Elasticache memcached swap critical threshold in percentage | string | `50` | no |
| swap_threshold_warning | Elasticache memcached swap warning threshold in percentage | string | `0` | no |
| swap_timeframe | Monitor timeframe for Elasticache memcached swap [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_5m` | no |
Related documentation Related documentation
--------------------- ---------------------
DataDog documentation: [https://docs.datadoghq.com/integrations/amazon_elasticache/](https://docs.datadoghq.com/integrations/amazon_elasticache/) DataDog documentation: [https://docs.datadoghq.com/integrations/amazon_elasticache/](https://docs.datadoghq.com/integrations/amazon_elasticache/)
And more here:
* [https://www.datadoghq.com/blog/monitoring-elasticache-performance-metrics-with-redis-or-memcached/](https://www.datadoghq.com/blog/monitoring-elasticache-performance-metrics-with-redis-or-memcached/)
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) 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

@ -25,35 +25,68 @@ variable "filter_tags_custom" {
} }
# Memcached specific # Memcached specific
variable "get_requests_miss_silenced" { variable "cpu_high_silenced" {
description = "Groups to mute for Elasticache Memcached get requests missed monitor" description = "Groups to mute for Elasticache memcached cpu high monitor"
type = "map" type = "map"
default = {} default = {}
} }
variable "get_requests_miss_message" { variable "cpu_high_message" {
description = "Custom message for Elasticache Memcached get requests missed monitor" description = "Custom message for Elasticache memcached cpu high monitor"
type = "string" type = "string"
default = "" default = ""
} }
variable "get_requests_miss_aggregator" { variable "cpu_high_aggregator" {
description = "Monitor aggregator for Elasticache Memcached get requests missed [available values: min, max, sum or avg]" description = "Monitor aggregator for Elasticache memcached cpu high [available values: min, max, sum or avg]"
type = "string" type = "string"
default = "min" default = "min"
} }
variable "get_requests_miss_timeframe" { variable "cpu_high_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`]" 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`]"
default = "last_15m" default = "last_15m"
} }
variable "get_requests_miss_threshold_warning" { variable "cpu_high_threshold_warning" {
description = "Elasticache Memcached get requests missed warning threshold in percentage" description = "Elasticache memcached cpu high warning threshold in percentage"
default = 80 default = 75
} }
variable "get_requests_miss_threshold_critical" { variable "cpu_high_threshold_critical" {
description = "Elasticache Memcached get requests missed critical threshold in percentage" description = "Elasticache memcached cpu high critical threshold in percentage"
default = 95 default = 90
}
variable "swap_silenced" {
description = "Groups to mute for Elasticache memcached swap monitor"
type = "map"
default = {}
}
variable "swap_message" {
description = "Custom message for Elasticache memcached swap monitor"
type = "string"
default = ""
}
variable "swap_aggregator" {
description = "Monitor aggregator for Elasticache memcached swap [available values: min, max, sum or avg]"
type = "string"
default = "min"
}
variable "swap_timeframe" {
description = "Monitor timeframe for Elasticache memcached swap [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
default = "last_5m"
}
variable "swap_threshold_warning" {
description = "Elasticache memcached swap warning threshold in percentage"
default = 0
}
variable "swap_threshold_critical" {
description = "Elasticache memcached swap critical threshold in percentage"
default = 50
} }

View File

@ -6,30 +6,30 @@ data "template_file" "filter" {
} }
} }
module "datadog-monitors-aws-elasticcache" { module "datadog-monitors-aws-elasticcache-common" {
source = "../." source = "../common"
message = "${var.message}" message = "${var.message}"
environment = "${var.environment}" environment = "${var.environment}"
filter_tags = "${data.template_file.filter.rendered}"
resource = "memcached"
} }
resource "datadog_monitor" "memcached_get_miss" { resource "datadog_monitor" "memcached_cpu_high" {
name = "[${var.environment}] Elasticache Memcached get requests missed {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" name = "[${var.environment}] Elasticache memcached CPU {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"
message = "${coalesce(var.get_requests_miss_message, var.message)}" message = "${coalesce(var.cpu_high_message, var.message)}"
type = "metric alert" type = "metric alert"
query = <<EOF query = <<EOF
${var.get_requests_miss_aggregator}(${var.get_requests_miss_timeframe}): ( ${var.cpu_high_aggregator}(${var.cpu_high_timeframe}): (
${var.get_requests_miss_aggregator}:aws.elasticache.get_misses{${data.template_file.filter.rendered}} by {region,name} / ${var.cpu_high_aggregator}:aws.elasticache.cpuutilization{${data.template_file.filter.rendered}} by {region,cluster,node}
(${var.get_requests_miss_aggregator}:aws.elasticache.get_hits{${data.template_file.filter.rendered}} by {region,name} + ) > ${var.cpu_high_threshold_critical}
${var.get_requests_miss_aggregator}:aws.elasticache.get_misses{${data.template_file.filter.rendered}} by {region,name})
) > ${var.get_requests_miss_threshold_critical}
EOF EOF
thresholds { thresholds {
warning = "${var.get_requests_miss_threshold_warning}" warning = "${var.cpu_high_threshold_warning}"
critical = "${var.get_requests_miss_threshold_critical}" critical = "${var.cpu_high_threshold_critical}"
} }
notify_no_data = true notify_no_data = true
@ -42,7 +42,39 @@ resource "datadog_monitor" "memcached_get_miss" {
require_full_window = false require_full_window = false
new_host_delay = "${var.delay}" new_host_delay = "${var.delay}"
silenced = "${var.get_requests_miss_silenced}" silenced = "${var.cpu_high_silenced}"
tags = ["env:${var.environment}", "resource:memcached", "team:aws", "provider:aws"]
}
resource "datadog_monitor" "memcached_swap" {
name = "[${var.environment}] Elasticache memcached swap {{#is_alert}}{{{comparator}}} {{threshold}}MB ({{value}}MB){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}MB ({{value}}MB){{/is_warning}}"
message = "${coalesce(var.swap_message, var.message)}"
type = "metric alert"
query = <<EOF
${var.swap_aggregator}(${var.swap_timeframe}): (
${var.swap_aggregator}:aws.elasticache.swap_usage{${data.template_file.filter.rendered}} by {region,cluster}
) > ${var.swap_threshold_critical}
EOF
thresholds {
warning = "${var.swap_threshold_warning}"
critical = "${var.swap_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 = false
new_host_delay = "${var.delay}"
silenced = "${var.swap_silenced}"
tags = ["env:${var.environment}", "resource:memcached", "team:aws", "provider:aws"] tags = ["env:${var.environment}", "resource:memcached", "team:aws", "provider:aws"]
} }