MON-32 - Monitors Updated

This commit is contained in:
Alexandre Gaillet 2018-05-16 18:09:17 +02:00 committed by Quentin Manfroi
parent cf66c5c7f3
commit c36f206950
6 changed files with 128 additions and 54 deletions

View File

@ -18,6 +18,7 @@ Purpose
------- -------
Creates DataDog monitors with the following checks : Creates DataDog monitors with the following checks :
* Get Hit
* CPU High * CPU High
* Swap * Swap
@ -36,6 +37,12 @@ Inputs
| 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_hits_aggregator | Monitor aggregator for Elasticache memcached get hits [available values: min, max, sum or avg] | string | `min` | no |
| get_hits_message | Custom message for Elasticache memcached get hits monitor | string | `` | no |
| get_hits_silenced | Groups to mute for Elasticache memcached get hits monitor | map | `<map>` | no |
| get_hits_threshold_critical | Elasticache memcached get hits critical threshold in percentage | string | `10` | no |
| get_hits_threshold_warning | Elasticache memcached get hits warning threshold in percentage | string | `20` | no |
| get_hits_timeframe | Monitor timeframe for Elasticache memcached get hits [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_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_message | Custom message for Elasticache memcached swap monitor | string | `` | no |

View File

@ -25,6 +25,39 @@ variable "filter_tags_custom" {
} }
# Memcached specific # Memcached specific
variable "get_hits_silenced" {
description = "Groups to mute for Elasticache memcached get hits monitor"
type = "map"
default = {}
}
variable "get_hits_message" {
description = "Custom message for Elasticache memcached get hits monitor"
type = "string"
default = ""
}
variable "get_hits_aggregator" {
description = "Monitor aggregator for Elasticache memcached get hits [available values: min, max, sum or avg]"
type = "string"
default = "min"
}
variable "get_hits_timeframe" {
description = "Monitor timeframe for Elasticache memcached get hits [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
default = "last_15m"
}
variable "get_hits_threshold_warning" {
description = "Elasticache memcached get hits warning threshold in percentage"
default = 20
}
variable "get_hits_threshold_critical" {
description = "Elasticache memcached get hits critical threshold in percentage"
default = 10
}
variable "cpu_high_silenced" { variable "cpu_high_silenced" {
description = "Groups to mute for Elasticache memcached cpu high monitor" description = "Groups to mute for Elasticache memcached cpu high monitor"
type = "map" type = "map"

View File

@ -15,6 +15,40 @@ module "datadog-monitors-aws-elasticcache-common" {
resource = "memcached" resource = "memcached"
} }
resource "datadog_monitor" "memcached_get_hits" {
name = "[${var.environment}] Elasticache memcached get hits {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"
message = "${coalesce(var.get_hits_message, var.message)}"
type = "metric alert"
query = <<EOF
${var.get_hits_aggregator}(${var.get_hits_timeframe}): (
${var.get_hits_aggregator}:aws.elasticache.get_hits{${data.template_file.filter.rendered}} by {region,cluster} /
(${var.get_hits_aggregator}:aws.elasticache.get_hits{${data.template_file.filter.rendered}} by {region,cluster} +
${var.get_hits_aggregator}:aws.elasticache.get_misses{${data.template_file.filter.rendered}} by {region,cluster})
) < ${var.get_hits_threshold_critical}
EOF
thresholds {
warning = "${var.get_hits_threshold_warning}"
critical = "${var.get_hits_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_hits_silenced}"
tags = ["env:${var.environment}", "resource:memcached", "team:aws", "provider:aws"]
}
resource "datadog_monitor" "memcached_cpu_high" { resource "datadog_monitor" "memcached_cpu_high" {
name = "[${var.environment}] Elasticache memcached CPU {{#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.cpu_high_message, var.message)}" message = "${coalesce(var.cpu_high_message, var.message)}"

View File

@ -28,28 +28,28 @@ Inputs
| Name | Description | Type | Default | Required | | Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:| |------|-------------|:----:|:-----:|:-----:|
| cache_hit_aggregator | Monitor aggregator for Elasticache Redis cache miss [available values: min, max, sum or avg] | string | `min` | no | | cache_hits_aggregator | Monitor aggregator for Elasticache redis cache hits [available values: min, max, sum or avg] | string | `min` | no |
| cache_hit_message | Custom message for Elasticache Redis cache miss monitor | string | `` | no | | cache_hits_message | Custom message for Elasticache redis cache hits monitor | string | `` | no |
| cache_hit_silenced | Groups to mute for Elasticache Redis cache miss monitor | map | `<map>` | no | | cache_hits_silenced | Groups to mute for Elasticache redis cache hits monitor | map | `<map>` | no |
| cache_hit_threshold_critical | Elasticache Redis cache miss critical threshold in percentage | string | `10` | no | | cache_hits_threshold_critical | Elasticache redis cache hits critical threshold in percentage | string | `10` | no |
| cache_hit_threshold_warning | Elasticache Redis cache miss warning threshold in percentage | string | `20` | no | | cache_hits_threshold_warning | Elasticache redis cache hits warning threshold in percentage | string | `20` | no |
| cache_hit_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 | | cache_hits_timeframe | Monitor timeframe for Elasticache redis cache hits [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_15m` | no |
| cpu_high_aggregator | Monitor aggregator for Elasticache Redis cpu high [available values: min, max, sum or avg] | string | `min` | no | | cpu_high_aggregator | Monitor aggregator for Elasticache redis cpu high [available values: min, max, sum or avg] | string | `min` | no |
| cpu_high_message | Custom message for Elasticache Redis cpu high monitor | string | `` | no | | cpu_high_message | Custom message for Elasticache redis cpu high monitor | string | `` | no |
| cpu_high_silenced | Groups to mute for Elasticache Redis cpu high monitor | map | `<map>` | no | | cpu_high_silenced | Groups to mute for Elasticache redis cpu high monitor | map | `<map>` | no |
| cpu_high_threshold_critical | Elasticache Redis cpu high critical threshold in percentage | string | `90` | no | | cpu_high_threshold_critical | Elasticache redis cpu high critical threshold in percentage | string | `90` | no |
| cpu_high_threshold_warning | Elasticache Redis cpu high warning threshold in percentage | string | `75` | no | | cpu_high_threshold_warning | Elasticache redis cpu high warning threshold in percentage | string | `75` | no |
| cpu_high_timeframe | Monitor timeframe for Elasticache Redis 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 | | cpu_high_timeframe | Monitor timeframe for Elasticache redis 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 |
| message | Message sent when an alert is triggered | string | - | yes | | message | Message sent when an alert is triggered | string | - | yes |
| redis_size | Size of the Elasticache Redis instance | string | - | yes | | redis_size | Size of the Elasticache redis instance | string | - | yes |
| swap_aggregator | Monitor aggregator for Elasticache Redis swap [available values: min, max, sum or avg] | string | `min` | no | | swap_aggregator | Monitor aggregator for Elasticache redis swap [available values: min, max, sum or avg] | string | `min` | no |
| swap_message | Custom message for Elasticache Redis swap monitor | string | `` | no | | swap_message | Custom message for Elasticache redis swap monitor | string | `` | no |
| swap_silenced | Groups to mute for Elasticache Redis swap monitor | map | `<map>` | no | | swap_silenced | Groups to mute for Elasticache redis swap monitor | map | `<map>` | no |
| swap_timeframe | Monitor timeframe for Elasticache Redis swap [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_15m` | no | | swap_timeframe | Monitor timeframe for Elasticache redis swap [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_15m` | no |
Related documentation Related documentation
--------------------- ---------------------

View File

@ -24,97 +24,97 @@ variable "filter_tags_custom" {
default = "*" default = "*"
} }
# Redis specific # redis specific
variable "redis_size" { variable "redis_size" {
description = "Size of the Elasticache Redis instance" description = "Size of the Elasticache redis instance"
type = "string" type = "string"
} }
variable "cache_hit_silenced" { variable "cache_hits_silenced" {
description = "Groups to mute for Elasticache Redis cache miss monitor" description = "Groups to mute for Elasticache redis cache hits monitor"
type = "map" type = "map"
default = {} default = {}
} }
variable "cache_hit_message" { variable "cache_hits_message" {
description = "Custom message for Elasticache Redis cache miss monitor" description = "Custom message for Elasticache redis cache hits monitor"
type = "string" type = "string"
default = "" default = ""
} }
variable "cache_hit_aggregator" { variable "cache_hits_aggregator" {
description = "Monitor aggregator for Elasticache Redis cache miss [available values: min, max, sum or avg]" description = "Monitor aggregator for Elasticache redis cache hits [available values: min, max, sum or avg]"
type = "string" type = "string"
default = "min" default = "min"
} }
variable "cache_hit_timeframe" { variable "cache_hits_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`]" description = "Monitor timeframe for Elasticache redis cache hits [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 "cache_hit_threshold_warning" { variable "cache_hits_threshold_warning" {
description = "Elasticache Redis cache miss warning threshold in percentage" description = "Elasticache redis cache hits warning threshold in percentage"
default = 20 default = 20
} }
variable "cache_hit_threshold_critical" { variable "cache_hits_threshold_critical" {
description = "Elasticache Redis cache miss critical threshold in percentage" description = "Elasticache redis cache hits critical threshold in percentage"
default = 10 default = 10
} }
variable "cpu_high_silenced" { variable "cpu_high_silenced" {
description = "Groups to mute for Elasticache Redis cpu high monitor" description = "Groups to mute for Elasticache redis cpu high monitor"
type = "map" type = "map"
default = {} default = {}
} }
variable "cpu_high_message" { variable "cpu_high_message" {
description = "Custom message for Elasticache Redis cpu high monitor" description = "Custom message for Elasticache redis cpu high monitor"
type = "string" type = "string"
default = "" default = ""
} }
variable "cpu_high_aggregator" { variable "cpu_high_aggregator" {
description = "Monitor aggregator for Elasticache Redis cpu high [available values: min, max, sum or avg]" description = "Monitor aggregator for Elasticache redis cpu high [available values: min, max, sum or avg]"
type = "string" type = "string"
default = "min" default = "min"
} }
variable "cpu_high_timeframe" { variable "cpu_high_timeframe" {
description = "Monitor timeframe for Elasticache Redis cpu high [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" description = "Monitor timeframe for Elasticache redis 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 "cpu_high_threshold_warning" { variable "cpu_high_threshold_warning" {
description = "Elasticache Redis cpu high warning threshold in percentage" description = "Elasticache redis cpu high warning threshold in percentage"
default = 75 default = 75
} }
variable "cpu_high_threshold_critical" { variable "cpu_high_threshold_critical" {
description = "Elasticache Redis cpu high critical threshold in percentage" description = "Elasticache redis cpu high critical threshold in percentage"
default = 90 default = 90
} }
variable "swap_silenced" { variable "swap_silenced" {
description = "Groups to mute for Elasticache Redis swap monitor" description = "Groups to mute for Elasticache redis swap monitor"
type = "map" type = "map"
default = {} default = {}
} }
variable "swap_message" { variable "swap_message" {
description = "Custom message for Elasticache Redis swap monitor" description = "Custom message for Elasticache redis swap monitor"
type = "string" type = "string"
default = "" default = ""
} }
variable "swap_aggregator" { variable "swap_aggregator" {
description = "Monitor aggregator for Elasticache Redis swap [available values: min, max, sum or avg]" description = "Monitor aggregator for Elasticache redis swap [available values: min, max, sum or avg]"
type = "string" type = "string"
default = "min" default = "min"
} }
variable "swap_timeframe" { variable "swap_timeframe" {
description = "Monitor timeframe for Elasticache Redis swap [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" description = "Monitor timeframe for Elasticache redis swap [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"
} }

View File

@ -15,23 +15,23 @@ module "datadog-monitors-aws-elasticcache-common" {
resource = "redis" resource = "redis"
} }
resource "datadog_monitor" "redis_cache_hit" { resource "datadog_monitor" "redis_cache_hits" {
name = "[${var.environment}] Elasticache redis cache hit {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" name = "[${var.environment}] Elasticache redis cache hits {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"
message = "${coalesce(var.cache_hit_message, var.message)}" message = "${coalesce(var.cache_hits_message, var.message)}"
type = "metric alert" type = "metric alert"
query = <<EOF query = <<EOF
${var.cache_hit_aggregator}(${var.cache_hit_timeframe}): ( ${var.cache_hits_aggregator}(${var.cache_hits_timeframe}): (
${var.cache_hit_aggregator}:aws.elasticache.cache_hits{${data.template_file.filter.rendered}} by {region,cluster} / ${var.cache_hits_aggregator}:aws.elasticache.cache_hits{${data.template_file.filter.rendered}} by {region,cluster} /
(${var.cache_hit_aggregator}:aws.elasticache.cache_hits{${data.template_file.filter.rendered}} by {region,cluster} + (${var.cache_hits_aggregator}:aws.elasticache.cache_hits{${data.template_file.filter.rendered}} by {region,cluster} +
${var.cache_hit_aggregator}:aws.elasticache.cache_misses{${data.template_file.filter.rendered}} by {region,cluster}) ${var.cache_hits_aggregator}:aws.elasticache.cache_misses{${data.template_file.filter.rendered}} by {region,cluster})
) < ${var.cache_hit_threshold_critical} ) < ${var.cache_hits_threshold_critical}
EOF EOF
thresholds { thresholds {
warning = "${var.cache_hit_threshold_warning}" warning = "${var.cache_hits_threshold_warning}"
critical = "${var.cache_hit_threshold_critical}" critical = "${var.cache_hits_threshold_critical}"
} }
notify_no_data = true notify_no_data = true
@ -44,7 +44,7 @@ resource "datadog_monitor" "redis_cache_hit" {
require_full_window = false require_full_window = false
new_host_delay = "${var.delay}" new_host_delay = "${var.delay}"
silenced = "${var.cache_hit_silenced}" silenced = "${var.cache_hits_silenced}"
tags = ["env:${var.environment}", "resource:redis", "team:aws", "provider:aws"] tags = ["env:${var.environment}", "resource:redis", "team:aws", "provider:aws"]
} }