MON-271: Basic monitors for Redis
This commit is contained in:
parent
6a05c91162
commit
ac4ec07788
@ -100,5 +100,6 @@ The `//` is very important, it's a terraform specific syntax used to separate gi
|
|||||||
- [apache](https://bitbucket.org/morea/terraform.feature.datadog/src/master/middleware/apache/)
|
- [apache](https://bitbucket.org/morea/terraform.feature.datadog/src/master/middleware/apache/)
|
||||||
- [nginx](https://bitbucket.org/morea/terraform.feature.datadog/src/master/middleware/nginx/)
|
- [nginx](https://bitbucket.org/morea/terraform.feature.datadog/src/master/middleware/nginx/)
|
||||||
- [php-fpm](https://bitbucket.org/morea/terraform.feature.datadog/src/master/middleware/php-fpm/)
|
- [php-fpm](https://bitbucket.org/morea/terraform.feature.datadog/src/master/middleware/php-fpm/)
|
||||||
|
- [redis](https://bitbucket.org/morea/terraform.feature.datadog/src/master/middleware/redis/)
|
||||||
- [system](https://bitbucket.org/morea/terraform.feature.datadog/src/master/system/)
|
- [system](https://bitbucket.org/morea/terraform.feature.datadog/src/master/system/)
|
||||||
- [generic](https://bitbucket.org/morea/terraform.feature.datadog/src/master/system/generic/)
|
- [generic](https://bitbucket.org/morea/terraform.feature.datadog/src/master/system/generic/)
|
||||||
|
|||||||
72
middleware/redis/README.md
Normal file
72
middleware/redis/README.md
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
# MIDDLEWARE REDIS DataDog monitors
|
||||||
|
|
||||||
|
## How to use this module
|
||||||
|
|
||||||
|
```
|
||||||
|
module "datadog-monitors-middleware-redis" {
|
||||||
|
source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//middleware/redis?ref={revision}"
|
||||||
|
|
||||||
|
environment = "${var.environment}"
|
||||||
|
message = "${module.datadog-message-alerting.alerting-message}"
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Creates DataDog monitors with the following checks:
|
||||||
|
|
||||||
|
- Redis too many evictedkeys
|
||||||
|
- Redis too many expired keys
|
||||||
|
- Redis too many blocked clients
|
||||||
|
- Redis keyspace seems full
|
||||||
|
|
||||||
|
## Inputs
|
||||||
|
|
||||||
|
| Name | Description | Type | Default | Required |
|
||||||
|
|------|-------------|:----:|:-----:|:-----:|
|
||||||
|
| blocked_clients_message | Custom message for Redis Blocked clients monitor | string | `` | no |
|
||||||
|
| blocked_clients_silenced | Groups to mute for Redis Blocked clients monitor | map | `<map>` | no |
|
||||||
|
| blocked_clients_threshold_critical | Blocked clients rate (critical threshold) | string | `90` | no |
|
||||||
|
| blocked_clients_threshold_warning | Blocked clients rate (warning threshold) | string | `70` | no |
|
||||||
|
| blocked_clients_time_aggregator | Monitor aggregator for Redis Blocked clients [available values: min, max or avg] | string | `min` | no |
|
||||||
|
| blocked_clients_timeframe | Monitor timeframe for Redis Blocked clients [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_5m` | no |
|
||||||
|
| delay | Delay in seconds for the metric evaluation | string | `900` | no |
|
||||||
|
| environment | Architecture environment | string | - | yes |
|
||||||
|
| evictedkeys_limit_message | Custom message for Redis evicted keys monitor | string | `` | no |
|
||||||
|
| evictedkeys_limit_silenced | Groups to mute for Redis evicted keys monitor | map | `<map>` | no |
|
||||||
|
| evictedkeys_limit_threshold_critical | Evicted keys limit (critical threshold) | string | `100` | no |
|
||||||
|
| evictedkeys_limit_threshold_warning | Evicted keys limit (warning threshold) | string | `0` | no |
|
||||||
|
| evictedkeys_limit_time_aggregator | Monitor aggregator for Redis evicted keys [available values: min, max or avg] | string | `avg` | no |
|
||||||
|
| evictedkeys_limit_timeframe | Monitor timeframe for Redis evicted keys [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_5m` | no |
|
||||||
|
| expirations_limit_message | Custom message for Redis keys expirations monitor | string | `` | no |
|
||||||
|
| expirations_limit_threshold_critical | Expirations percent (critical threshold) | string | `80` | no |
|
||||||
|
| expirations_limit_threshold_warning | Expirations percent (warning threshold) | string | `60` | no |
|
||||||
|
| expirations_limit_time_aggregator | Monitor aggregator for Redis keys expirations [available values: min, max or avg] | string | `min` | no |
|
||||||
|
| expirations_limit_timeframe | Monitor timeframe for Redis keys expirations [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_5m` | no |
|
||||||
|
| expirations_silenced | Groups to mute for Redis keys expirations monitor | map | `<map>` | 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 |
|
||||||
|
| keyspace_message | Custom message for Redis keyspace monitor | string | `` | no |
|
||||||
|
| keyspace_silenced | Groups to mute for Redis keyspace monitor | map | `<map>` | no |
|
||||||
|
| keyspace_threshold_critical | Keyspace changement (critical threshold) | string | `90` | no |
|
||||||
|
| keyspace_threshold_warning | Keyspace changement (warning threshold) | string | `70` | no |
|
||||||
|
| keyspace_time_aggregator | Monitor aggregator for Redis keyspace [available values: min, max or avg] | string | `min` | no |
|
||||||
|
| keyspace_timeframe | Monitor timeframe for Redis keyspace [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_5m` | no |
|
||||||
|
| message | Message sent when a Redis monitor is triggered | string | - | yes |
|
||||||
|
| redis_silenced | Groups to mute for Redis monitors | map | `<map>` | no |
|
||||||
|
|
||||||
|
## Outputs
|
||||||
|
|
||||||
|
| Name | Description |
|
||||||
|
|------|-------------|
|
||||||
|
| redis_blocked_clients_id | id for monitor redis_blocked_clients |
|
||||||
|
| redis_evictedkeys_id | id for monitor redis_evictedkeys |
|
||||||
|
| redis_expirations_id | id for monitor redis_expirations |
|
||||||
|
| redis_keyspace_id | id for monitor redis_keyspace |
|
||||||
|
|
||||||
|
## Related documentation
|
||||||
|
|
||||||
|
[Datadog blog: How to monitor Redis](https://www.datadoghq.com/blog/how-to-monitor-redis-performance-metrics/)
|
||||||
|
|
||||||
|
[Datadog Redis integration doc](https://docs.datadoghq.com/integrations/redisdb/)
|
||||||
168
middleware/redis/inputs.tf
Normal file
168
middleware/redis/inputs.tf
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
# Global Terraform
|
||||||
|
variable "environment" {
|
||||||
|
description = "Architecture environment"
|
||||||
|
type = "string"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Global DataDog
|
||||||
|
variable "message" {
|
||||||
|
description = "Message sent when a Redis monitor is triggered"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "delay" {
|
||||||
|
description = "Delay in seconds for the metric evaluation"
|
||||||
|
default = 900
|
||||||
|
}
|
||||||
|
|
||||||
|
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 variables
|
||||||
|
variable "redis_silenced" {
|
||||||
|
description = "Groups to mute for Redis monitors"
|
||||||
|
type = "map"
|
||||||
|
default = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "evictedkeys_limit_silenced" {
|
||||||
|
description = "Groups to mute for Redis evicted keys monitor"
|
||||||
|
type = "map"
|
||||||
|
default = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "evictedkeys_limit_message" {
|
||||||
|
description = "Custom message for Redis evicted keys monitor"
|
||||||
|
type = "string"
|
||||||
|
default = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "evictedkeys_limit_time_aggregator" {
|
||||||
|
description = "Monitor aggregator for Redis evicted keys [available values: min, max or avg]"
|
||||||
|
type = "string"
|
||||||
|
default = "avg"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "evictedkeys_limit_timeframe" {
|
||||||
|
description = "Monitor timeframe for Redis evicted keys [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
|
||||||
|
type = "string"
|
||||||
|
default = "last_5m"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "evictedkeys_limit_threshold_warning" {
|
||||||
|
description = "Evicted keys limit (warning threshold)"
|
||||||
|
default = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "evictedkeys_limit_threshold_critical" {
|
||||||
|
description = "Evicted keys limit (critical threshold)"
|
||||||
|
default = 100
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "expirations_silenced" {
|
||||||
|
description = "Groups to mute for Redis keys expirations monitor"
|
||||||
|
type = "map"
|
||||||
|
default = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "expirations_limit_message" {
|
||||||
|
description = "Custom message for Redis keys expirations monitor"
|
||||||
|
type = "string"
|
||||||
|
default = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "expirations_limit_time_aggregator" {
|
||||||
|
description = "Monitor aggregator for Redis keys expirations [available values: min, max or avg]"
|
||||||
|
type = "string"
|
||||||
|
default = "min"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "expirations_limit_timeframe" {
|
||||||
|
description = "Monitor timeframe for Redis keys expirations [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
|
||||||
|
type = "string"
|
||||||
|
default = "last_5m"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "expirations_limit_threshold_critical" {
|
||||||
|
description = "Expirations percent (critical threshold)"
|
||||||
|
default = 80
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "expirations_limit_threshold_warning" {
|
||||||
|
description = "Expirations percent (warning threshold)"
|
||||||
|
default = 60
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "blocked_clients_silenced" {
|
||||||
|
description = "Groups to mute for Redis Blocked clients monitor"
|
||||||
|
type = "map"
|
||||||
|
default = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "blocked_clients_message" {
|
||||||
|
description = "Custom message for Redis Blocked clients monitor"
|
||||||
|
type = "string"
|
||||||
|
default = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "blocked_clients_time_aggregator" {
|
||||||
|
description = "Monitor aggregator for Redis Blocked clients [available values: min, max or avg]"
|
||||||
|
type = "string"
|
||||||
|
default = "min"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "blocked_clients_timeframe" {
|
||||||
|
description = "Monitor timeframe for Redis Blocked clients [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
|
||||||
|
type = "string"
|
||||||
|
default = "last_5m"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "blocked_clients_threshold_critical" {
|
||||||
|
description = "Blocked clients rate (critical threshold)"
|
||||||
|
default = 90
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "blocked_clients_threshold_warning" {
|
||||||
|
description = "Blocked clients rate (warning threshold)"
|
||||||
|
default = 70
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "keyspace_silenced" {
|
||||||
|
description = "Groups to mute for Redis keyspace monitor"
|
||||||
|
type = "map"
|
||||||
|
default = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "keyspace_message" {
|
||||||
|
description = "Custom message for Redis keyspace monitor"
|
||||||
|
type = "string"
|
||||||
|
default = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "keyspace_time_aggregator" {
|
||||||
|
description = "Monitor aggregator for Redis keyspace [available values: min, max or avg]"
|
||||||
|
type = "string"
|
||||||
|
default = "min"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "keyspace_timeframe" {
|
||||||
|
description = "Monitor timeframe for Redis keyspace [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
|
||||||
|
type = "string"
|
||||||
|
default = "last_5m"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "keyspace_threshold_critical" {
|
||||||
|
description = "Keyspace changement (critical threshold)"
|
||||||
|
default = 90
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "keyspace_threshold_warning" {
|
||||||
|
description = "Keyspace changement (warning threshold)"
|
||||||
|
default = 70
|
||||||
|
}
|
||||||
135
middleware/redis/monitors-redis.tf
Normal file
135
middleware/redis/monitors-redis.tf
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
data "template_file" "filter" {
|
||||||
|
template = "$${filter}"
|
||||||
|
|
||||||
|
vars {
|
||||||
|
filter = "${var.filter_tags_use_defaults == "true" ? format("dd_monitoring:enabled,dd_redis:enabled,db_env:%s", var.environment) : "${var.filter_tags_custom}"}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "datadog_monitor" "redis_evictedkeys" {
|
||||||
|
name = "[${var.environment}] Redis too many evictedkeys {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}"
|
||||||
|
message = "${coalesce(var.evictedkeys_limit_message, var.message)}"
|
||||||
|
|
||||||
|
query = <<EOL
|
||||||
|
${var.evictedkeys_limit_time_aggregator}(${var.evictedkeys_limit_timeframe}): (
|
||||||
|
avg:redis.keys.evicted{${data.template_file.filter.rendered}} by {name,host}
|
||||||
|
) > ${var.evictedkeys_limit_threshold_critical}
|
||||||
|
EOL
|
||||||
|
|
||||||
|
type = "metric alert"
|
||||||
|
|
||||||
|
thresholds {
|
||||||
|
warning = "${var.evictedkeys_limit_threshold_warning}"
|
||||||
|
critical = "${var.evictedkeys_limit_threshold_critical}"
|
||||||
|
}
|
||||||
|
|
||||||
|
silenced = "${var.evictedkeys_limit_silenced}"
|
||||||
|
|
||||||
|
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}"
|
||||||
|
|
||||||
|
tags = ["env:${var.environment}", "resource:redis"]
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "datadog_monitor" "redis_expirations" {
|
||||||
|
name = "[${var.environment}] Redis too many expired keys {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}"
|
||||||
|
message = "${coalesce(var.expirations_limit_message, var.message)}"
|
||||||
|
|
||||||
|
query = <<EOL
|
||||||
|
${var.expirations_limit_time_aggregator}(${var.expirations_limit_timeframe}): (
|
||||||
|
avg:redis.expires.percent{${data.template_file.filter.rendered}} by {name,host}
|
||||||
|
) > ${var.expirations_limit_threshold_critical}
|
||||||
|
EOL
|
||||||
|
|
||||||
|
type = "metric alert"
|
||||||
|
|
||||||
|
thresholds {
|
||||||
|
warning = "${var.expirations_limit_threshold_warning}"
|
||||||
|
critical = "${var.expirations_limit_threshold_critical}"
|
||||||
|
}
|
||||||
|
|
||||||
|
silenced = "${var.expirations_silenced}"
|
||||||
|
|
||||||
|
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}"
|
||||||
|
|
||||||
|
tags = ["env:${var.environment}", "resource:redis"]
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "datadog_monitor" "redis_blocked_clients" {
|
||||||
|
name = "[${var.environment}] Redis too many blocked clients {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}"
|
||||||
|
message = "${coalesce(var.blocked_clients_message, var.message)}"
|
||||||
|
|
||||||
|
query = <<EOL
|
||||||
|
${var.blocked_clients_time_aggregator}(${var.blocked_clients_timeframe}): (
|
||||||
|
avg:redis.clients.blocked{${data.template_file.filter.rendered}} by {name,host}
|
||||||
|
) > ${var.blocked_clients_threshold_critical}
|
||||||
|
EOL
|
||||||
|
|
||||||
|
type = "metric alert"
|
||||||
|
|
||||||
|
thresholds {
|
||||||
|
warning = "${var.blocked_clients_threshold_warning}"
|
||||||
|
critical = "${var.blocked_clients_threshold_critical}"
|
||||||
|
}
|
||||||
|
|
||||||
|
silenced = "${var.blocked_clients_silenced}"
|
||||||
|
|
||||||
|
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}"
|
||||||
|
|
||||||
|
tags = ["env:${var.environment}", "resource:redis"]
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "datadog_monitor" "redis_keyspace" {
|
||||||
|
name = "[${var.environment}] Redis keyspace seems full {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}"
|
||||||
|
message = "${coalesce(var.keyspace_message, var.message)}"
|
||||||
|
|
||||||
|
query = <<EOL
|
||||||
|
${var.keyspace_time_aggregator}(${var.keyspace_timeframe}): (
|
||||||
|
avg:redis.key.length{${data.template_file.filter.rendered}} by {name,host}
|
||||||
|
) > ${var.keyspace_threshold_critical}
|
||||||
|
EOL
|
||||||
|
|
||||||
|
type = "metric alert"
|
||||||
|
|
||||||
|
thresholds {
|
||||||
|
warning = "${var.keyspace_threshold_warning}"
|
||||||
|
critical = "${var.keyspace_threshold_critical}"
|
||||||
|
}
|
||||||
|
|
||||||
|
silenced = "${var.keyspace_silenced}"
|
||||||
|
|
||||||
|
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}"
|
||||||
|
|
||||||
|
tags = ["env:${var.environment}", "resource:redis"]
|
||||||
|
}
|
||||||
19
middleware/redis/outputs.tf
Normal file
19
middleware/redis/outputs.tf
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
output "redis_evictedkeys_id" {
|
||||||
|
description = "id for monitor redis_evictedkeys"
|
||||||
|
value = "${datadog_monitor.redis_evictedkeys.id}"
|
||||||
|
}
|
||||||
|
|
||||||
|
output "redis_expirations_id" {
|
||||||
|
description = "id for monitor redis_expirations"
|
||||||
|
value = "${datadog_monitor.redis_expirations.id}"
|
||||||
|
}
|
||||||
|
|
||||||
|
output "redis_blocked_clients_id" {
|
||||||
|
description = "id for monitor redis_blocked_clients"
|
||||||
|
value = "${datadog_monitor.redis_blocked_clients.id}"
|
||||||
|
}
|
||||||
|
|
||||||
|
output "redis_keyspace_id" {
|
||||||
|
description = "id for monitor redis_keyspace"
|
||||||
|
value = "${datadog_monitor.redis_keyspace.id}"
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user