MON-320 greater logic for system monitors

This commit is contained in:
Quentin Manfroi 2019-04-23 12:54:08 +02:00
parent 2df9ff2706
commit da5a3c20b9
4 changed files with 211 additions and 213 deletions

View File

@ -9,7 +9,7 @@ module "datadog-monitors-system-generic" {
environment = "${var.environment}" environment = "${var.environment}"
message = "${module.datadog-message-alerting.alerting-message}" message = "${module.datadog-message-alerting.alerting-message}"
free_memory_message = "${module.datadog-message-alerting.alerting-message-bh-only}" memory_message = "${module.datadog-message-alerting.alerting-message-bh-only}"
} }
``` ```
@ -20,74 +20,74 @@ Creates DataDog monitors with the following checks:
- CPU load 5 ratio - CPU load 5 ratio
- CPU usage - CPU usage
- Disk Space forecast - Disk inodes usage
- Free disk inodes - Disk Space usage forecast
- Free disk space - Disk space usage
- Free memory - Usable Memory
## Inputs ## Inputs
| Name | Description | Type | Default | Required | | Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:| |------|-------------|:----:|:-----:|:-----:|
| cpu\_high\_enabled | Flag to enable CPU high monitor | string | `"true"` | no | | cpu\_enabled | Flag to enable CPU high monitor | string | `"true"` | no |
| cpu\_high\_extra\_tags | Extra tags for CPU high monitor | list | `[]` | no | | cpu\_extra\_tags | Extra tags for CPU high monitor | list | `[]` | no |
| cpu\_high\_message | Custom message for CPU high monitor | string | `""` | no | | cpu\_message | Custom message for CPU high monitor | string | `""` | no |
| cpu\_high\_silenced | Groups to mute for CPU high monitor | map | `{}` | no | | cpu\_silenced | Groups to mute for CPU high monitor | map | `{}` | no |
| cpu\_high\_threshold\_critical | CPU high critical threshold | string | `"90"` | no | | cpu\_threshold\_critical | CPU high critical threshold | string | `"90"` | no |
| cpu\_high\_threshold\_warning | CPU high warning threshold | string | `"85"` | no | | cpu\_threshold\_warning | CPU high warning threshold | string | `"85"` | no |
| cpu\_high\_time\_aggregator | Monitor aggregator for CPU high [available values: min, max or avg] | string | `"min"` | no | | cpu\_time\_aggregator | Monitor aggregator for CPU high [available values: min, max or avg] | string | `"min"` | no |
| cpu\_high\_timeframe | Monitor timeframe for CPU high [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_10m"` | no | | cpu\_timeframe | Monitor timeframe for CPU high [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_10m"` | no |
| cpu\_load\_enabled | Flag to enable CPU load ratio monitor | string | `"true"` | no | | disk\_inodes\_enabled | Flag to enable Free disk inodes monitor | string | `"true"` | no |
| cpu\_load\_extra\_tags | Extra tags for CPU load ratio monitor | list | `[]` | no | | disk\_inodes\_extra\_tags | Extra tags for Free disk inodes monitor | list | `[]` | no |
| cpu\_load\_message | Custom message for CPU load ratio monitor | string | `""` | no | | disk\_inodes\_message | Custom message for Free disk inodes monitor | string | `""` | no |
| cpu\_load\_silenced | Groups to mute for CPU load ratio monitor | map | `{}` | no | | disk\_inodes\_silenced | Groups to mute for Free disk inodes monitor | map | `{}` | no |
| cpu\_load\_threshold\_critical | CPU load ratio critical threshold | string | `"2.5"` | no | | disk\_inodes\_threshold\_critical | Free disk space critical threshold | string | `"95"` | no |
| cpu\_load\_threshold\_warning | CPU load ratio warning threshold | string | `"2"` | no | | disk\_inodes\_threshold\_warning | Free disk space warning threshold | string | `"90"` | no |
| cpu\_load\_time\_aggregator | Monitor aggregator for CPU load ratio [available values: min, max or avg] | string | `"min"` | no | | disk\_inodes\_time\_aggregator | Monitor aggregator for Free disk inodes [available values: min, max or avg] | string | `"min"` | no |
| cpu\_load\_timeframe | Monitor timeframe for CPU load ratio [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_15m"` | no | | disk\_inodes\_timeframe | Monitor timeframe for Free disk inodes [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_5m"` | no |
| disk\_space\_enabled | Flag to enable Free diskspace monitor | string | `"true"` | no |
| disk\_space\_extra\_tags | Extra tags for Free diskspace monitor | list | `[]` | no |
| disk\_space\_forecast\_algorithm | Algorithm for the Free diskspace Forecast monitor [available values: `linear` or `seasonal`] | string | `"linear"` | no |
| disk\_space\_forecast\_deviations | Deviations for the Free diskspace Forecast monitor [available values: `1`, `2`, `3`, `4` or `5`] | string | `"1"` | no |
| disk\_space\_forecast\_enabled | Flag to enable Free diskspace forecast monitor | string | `"true"` | no |
| disk\_space\_forecast\_extra\_tags | Extra tags for Free diskspace forecast monitor | list | `[]` | no |
| disk\_space\_forecast\_interval | Interval for the Free diskspace Forecast monitor [available values: `30m`, `60m` or `120m`] | string | `"60m"` | no |
| disk\_space\_forecast\_linear\_history | History for the Free diskspace Forecast monitor [available values: `12h`, `#d` (1, 2, or 3), `#w` (1, or 2) or `#mo` (1, 2 or 3)] | string | `"1w"` | no |
| disk\_space\_forecast\_linear\_model | Model for the Free diskspace Forecast monitor [available values: `default`, `simple` or `reactive`] | string | `"default"` | no |
| disk\_space\_forecast\_message | Custom message for Free diskspace forecast monitor | string | `""` | no |
| disk\_space\_forecast\_seasonal\_seasonality | Seasonality for the Free diskspace Forecast monitor | string | `"weekly"` | no |
| disk\_space\_forecast\_silenced | Groups to mute for Free diskspace forecast monitor | map | `{}` | no |
| disk\_space\_forecast\_threshold\_critical | Free disk space forecast critical threshold | string | `"80"` | no |
| disk\_space\_forecast\_threshold\_critical\_recovery | Free disk space forecast recovery threshold | string | `"72"` | no |
| disk\_space\_forecast\_time\_aggregator | Monitor aggregator for Free diskspace forecast [available values: min, max or avg] | string | `"max"` | no |
| disk\_space\_forecast\_timeframe | Monitor timeframe for Free diskspace forecast [available values: `next_12h`, `next_#d` (1, 2, or 3), `next_#w` (1 or 2) or `next_#mo` (1, 2 or 3)] | string | `"next_1w"` | no |
| disk\_space\_message | Custom message for Free diskspace monitor | string | `""` | no |
| disk\_space\_silenced | Groups to mute for Free diskspace monitor | map | `{}` | no |
| disk\_space\_threshold\_critical | Free disk space critical threshold | string | `"90"` | no |
| disk\_space\_threshold\_warning | Free disk space warning threshold | string | `"80"` | no |
| disk\_space\_time\_aggregator | Monitor aggregator for Free diskspace [available values: min, max or avg] | string | `"max"` | no |
| disk\_space\_timeframe | Monitor timeframe for Free diskspace [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_5m"` | no |
| environment | Architecture Environment | string | n/a | yes | | environment | Architecture Environment | string | n/a | yes |
| evaluation\_delay | Delay in seconds for the metric evaluation | string | `"15"` | no | | evaluation\_delay | Delay in seconds for the metric evaluation | string | `"15"` | no |
| 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\_custom\_excluded | Tags excluded for custom filtering when filter_tags_use_defaults is false | string | `""` | no | | filter\_tags\_custom\_excluded | Tags excluded 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 |
| free\_disk\_inodes\_enabled | Flag to enable Free disk inodes monitor | string | `"true"` | no | | load\_enabled | Flag to enable CPU load ratio monitor | string | `"true"` | no |
| free\_disk\_inodes\_extra\_tags | Extra tags for Free disk inodes monitor | list | `[]` | no | | load\_extra\_tags | Extra tags for CPU load ratio monitor | list | `[]` | no |
| free\_disk\_inodes\_message | Custom message for Free disk inodes monitor | string | `""` | no | | load\_message | Custom message for CPU load ratio monitor | string | `""` | no |
| free\_disk\_inodes\_silenced | Groups to mute for Free disk inodes monitor | map | `{}` | no | | load\_silenced | Groups to mute for CPU load ratio monitor | map | `{}` | no |
| free\_disk\_inodes\_threshold\_critical | Free disk space critical threshold | string | `"5"` | no | | load\_threshold\_critical | CPU load ratio critical threshold | string | `"2.5"` | no |
| free\_disk\_inodes\_threshold\_warning | Free disk space warning threshold | string | `"10"` | no | | load\_threshold\_warning | CPU load ratio warning threshold | string | `"2"` | no |
| free\_disk\_inodes\_time\_aggregator | Monitor aggregator for Free disk inodes [available values: min, max or avg] | string | `"min"` | no | | load\_time\_aggregator | Monitor aggregator for CPU load ratio [available values: min, max or avg] | string | `"min"` | no |
| free\_disk\_inodes\_timeframe | Monitor timeframe for Free disk inodes [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_5m"` | no | | load\_timeframe | Monitor timeframe for CPU load ratio [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_15m"` | no |
| free\_disk\_space\_enabled | Flag to enable Free diskspace monitor | string | `"true"` | no | | memory\_enabled | Flag to enable Free memory monitor | string | `"true"` | no |
| free\_disk\_space\_extra\_tags | Extra tags for Free diskspace monitor | list | `[]` | no | | memory\_extra\_tags | Extra tags for Free memory monitor | list | `[]` | no |
| free\_disk\_space\_forecast\_algorithm | Algorithm for the Free diskspace Forecast monitor [available values: `linear` or `seasonal`] | string | `"linear"` | no | | memory\_message | Mandatory message for Free memory monitor to avoid NBH alerting by default | string | n/a | yes |
| free\_disk\_space\_forecast\_deviations | Deviations for the Free diskspace Forecast monitor [available values: `1`, `2`, `3`, `4` or `5`] | string | `"1"` | no | | memory\_silenced | Groups to mute for Free memory monitor | map | `{}` | no |
| free\_disk\_space\_forecast\_enabled | Flag to enable Free diskspace forecast monitor | string | `"true"` | no | | memory\_threshold\_critical | Free disk space critical threshold | string | `"5"` | no |
| free\_disk\_space\_forecast\_extra\_tags | Extra tags for Free diskspace forecast monitor | list | `[]` | no | | memory\_threshold\_warning | Free disk space warning threshold | string | `"10"` | no |
| free\_disk\_space\_forecast\_interval | Interval for the Free diskspace Forecast monitor [available values: `30m`, `60m` or `120m`] | string | `"60m"` | no | | memory\_time\_aggregator | Monitor aggregator for Free memory [available values: min, max or avg] | string | `"max"` | no |
| free\_disk\_space\_forecast\_linear\_history | History for the Free diskspace Forecast monitor [available values: `12h`, `#d` (1, 2, or 3), `#w` (1, or 2) or `#mo` (1, 2 or 3)] | string | `"1w"` | no | | memory\_timeframe | Monitor timeframe for Free memory [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_5m"` | no |
| free\_disk\_space\_forecast\_linear\_model | Model for the Free diskspace Forecast monitor [available values: `default`, `simple` or `reactive`] | string | `"default"` | no |
| free\_disk\_space\_forecast\_message | Custom message for Free diskspace forecast monitor | string | `""` | no |
| free\_disk\_space\_forecast\_seasonal\_seasonality | Seasonality for the Free diskspace Forecast monitor | string | `"weekly"` | no |
| free\_disk\_space\_forecast\_silenced | Groups to mute for Free diskspace forecast monitor | map | `{}` | no |
| free\_disk\_space\_forecast\_threshold\_critical | Free disk space forecast critical threshold | string | `"80"` | no |
| free\_disk\_space\_forecast\_threshold\_critical\_recovery | Free disk space forecast recovery threshold | string | `"72"` | no |
| free\_disk\_space\_forecast\_time\_aggregator | Monitor aggregator for Free diskspace forecast [available values: min, max or avg] | string | `"max"` | no |
| free\_disk\_space\_forecast\_timeframe | Monitor timeframe for Free diskspace forecast [available values: `next_12h`, `next_#d` (1, 2, or 3), `next_#w` (1 or 2) or `next_#mo` (1, 2 or 3)] | string | `"next_1w"` | no |
| free\_disk\_space\_message | Custom message for Free diskspace monitor | string | `""` | no |
| free\_disk\_space\_silenced | Groups to mute for Free diskspace monitor | map | `{}` | no |
| free\_disk\_space\_threshold\_critical | Free disk space critical threshold | string | `"10"` | no |
| free\_disk\_space\_threshold\_warning | Free disk space warning threshold | string | `"20"` | no |
| free\_disk\_space\_time\_aggregator | Monitor aggregator for Free diskspace [available values: min, max or avg] | string | `"min"` | no |
| free\_disk\_space\_timeframe | Monitor timeframe for Free diskspace [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_5m"` | no |
| free\_memory\_enabled | Flag to enable Free memory monitor | string | `"true"` | no |
| free\_memory\_extra\_tags | Extra tags for Free memory monitor | list | `[]` | no |
| free\_memory\_message | Mandatory message for Free memory monitor to avoid NBH alerting by default | string | n/a | yes |
| free\_memory\_silenced | Groups to mute for Free memory monitor | map | `{}` | no |
| free\_memory\_threshold\_critical | Free disk space critical threshold | string | `"5"` | no |
| free\_memory\_threshold\_warning | Free disk space warning threshold | string | `"10"` | no |
| free\_memory\_time\_aggregator | Monitor aggregator for Free memory [available values: min, max or avg] | string | `"max"` | no |
| free\_memory\_timeframe | Monitor timeframe for Free memory [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 an alert is triggered | string | n/a | yes | | message | Message sent when an alert is triggered | string | n/a | yes |
| new\_host\_delay | Delay in seconds before monitor new resource | string | `"300"` | no | | new\_host\_delay | Delay in seconds before monitor new resource | string | `"300"` | no |
@ -95,12 +95,12 @@ Creates DataDog monitors with the following checks:
| Name | Description | | Name | Description |
|------|-------------| |------|-------------|
| datadog\_cpu\_too\_high\_id | id for monitor datadog_cpu_too_high | | cpu\_id | id for monitor cpu |
| datadog\_free\_disk\_space\_forecast\_id | id for monitor datadog_free_disk_space_forecast | | disk\_inodes\_id | id for monitor disk_inodes |
| datadog\_free\_disk\_space\_inodes\_too\_low\_id | id for monitor datadog_free_disk_space_inodes_too_low | | disk\_space\_forecast\_id | id for monitor disk_space_forecast |
| datadog\_free\_disk\_space\_too\_low\_id | id for monitor datadog_free_disk_space_too_low | | disk\_space\_id | id for monitor disk_space |
| datadog\_free\_memory\_id | id for monitor datadog_free_memory | | load\_id | id for monitor load |
| datadog\_load\_too\_high\_id | id for monitor datadog_load_too_high | | memory\_id | id for monitor memory |
## Related documentation ## Related documentation

View File

@ -36,313 +36,313 @@ variable "filter_tags_custom_excluded" {
# System generic specific # System generic specific
variable "cpu_high_silenced" { variable "cpu_silenced" {
description = "Groups to mute for CPU high monitor" description = "Groups to mute for CPU high monitor"
type = "map" type = "map"
default = {} default = {}
} }
variable "cpu_high_enabled" { variable "cpu_enabled" {
description = "Flag to enable CPU high monitor" description = "Flag to enable CPU high monitor"
type = "string" type = "string"
default = "true" default = "true"
} }
variable "cpu_high_extra_tags" { variable "cpu_extra_tags" {
description = "Extra tags for CPU high monitor" description = "Extra tags for CPU high monitor"
type = "list" type = "list"
default = [] default = []
} }
variable "cpu_high_message" { variable "cpu_message" {
description = "Custom message for CPU high monitor" description = "Custom message for CPU high monitor"
type = "string" type = "string"
default = "" default = ""
} }
variable "cpu_high_time_aggregator" { variable "cpu_time_aggregator" {
description = "Monitor aggregator for CPU high [available values: min, max or avg]" description = "Monitor aggregator for CPU high [available values: min, max or avg]"
type = "string" type = "string"
default = "min" default = "min"
} }
variable "cpu_high_timeframe" { variable "cpu_timeframe" {
description = "Monitor timeframe for 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 CPU high [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
type = "string" type = "string"
default = "last_10m" default = "last_10m"
} }
variable "cpu_high_threshold_warning" { variable "cpu_threshold_warning" {
description = "CPU high warning threshold" description = "CPU high warning threshold"
default = 85 default = 85
} }
variable "cpu_high_threshold_critical" { variable "cpu_threshold_critical" {
description = "CPU high critical threshold" description = "CPU high critical threshold"
default = 90 default = 90
} }
variable "cpu_load_silenced" { variable "load_silenced" {
description = "Groups to mute for CPU load ratio monitor" description = "Groups to mute for CPU load ratio monitor"
type = "map" type = "map"
default = {} default = {}
} }
variable "cpu_load_enabled" { variable "load_enabled" {
description = "Flag to enable CPU load ratio monitor" description = "Flag to enable CPU load ratio monitor"
type = "string" type = "string"
default = "true" default = "true"
} }
variable "cpu_load_extra_tags" { variable "load_extra_tags" {
description = "Extra tags for CPU load ratio monitor" description = "Extra tags for CPU load ratio monitor"
type = "list" type = "list"
default = [] default = []
} }
variable "cpu_load_message" { variable "load_message" {
description = "Custom message for CPU load ratio monitor" description = "Custom message for CPU load ratio monitor"
type = "string" type = "string"
default = "" default = ""
} }
variable "cpu_load_time_aggregator" { variable "load_time_aggregator" {
description = "Monitor aggregator for CPU load ratio [available values: min, max or avg]" description = "Monitor aggregator for CPU load ratio [available values: min, max or avg]"
type = "string" type = "string"
default = "min" default = "min"
} }
variable "cpu_load_timeframe" { variable "load_timeframe" {
description = "Monitor timeframe for CPU load ratio [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" description = "Monitor timeframe for CPU load ratio [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
type = "string" type = "string"
default = "last_15m" default = "last_15m"
} }
variable "cpu_load_threshold_warning" { variable "load_threshold_warning" {
description = "CPU load ratio warning threshold" description = "CPU load ratio warning threshold"
default = 2 default = 2
} }
variable "cpu_load_threshold_critical" { variable "load_threshold_critical" {
description = "CPU load ratio critical threshold" description = "CPU load ratio critical threshold"
default = 2.5 default = 2.5
} }
variable "free_disk_space_silenced" { variable "disk_space_silenced" {
description = "Groups to mute for Free diskspace monitor" description = "Groups to mute for Free diskspace monitor"
type = "map" type = "map"
default = {} default = {}
} }
variable "free_disk_space_enabled" { variable "disk_space_enabled" {
description = "Flag to enable Free diskspace monitor" description = "Flag to enable Free diskspace monitor"
type = "string" type = "string"
default = "true" default = "true"
} }
variable "free_disk_space_extra_tags" { variable "disk_space_extra_tags" {
description = "Extra tags for Free diskspace monitor" description = "Extra tags for Free diskspace monitor"
type = "list" type = "list"
default = [] default = []
} }
variable "free_disk_space_message" { variable "disk_space_message" {
description = "Custom message for Free diskspace monitor" description = "Custom message for Free diskspace monitor"
type = "string" type = "string"
default = "" default = ""
} }
variable "free_disk_space_time_aggregator" { variable "disk_space_time_aggregator" {
description = "Monitor aggregator for Free diskspace [available values: min, max or avg]" description = "Monitor aggregator for Free diskspace [available values: min, max or avg]"
type = "string" type = "string"
default = "min" default = "max"
} }
variable "free_disk_space_timeframe" { variable "disk_space_timeframe" {
description = "Monitor timeframe for Free diskspace [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" description = "Monitor timeframe for Free diskspace [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
type = "string" type = "string"
default = "last_5m" default = "last_5m"
} }
variable "free_disk_space_threshold_warning" { variable "disk_space_threshold_warning" {
description = "Free disk space warning threshold" description = "Free disk space warning threshold"
default = 20 default = 80
} }
variable "free_disk_space_threshold_critical" { variable "disk_space_threshold_critical" {
description = "Free disk space critical threshold" description = "Free disk space critical threshold"
default = 10 default = 90
} }
variable "free_disk_space_forecast_silenced" { variable "disk_space_forecast_silenced" {
description = "Groups to mute for Free diskspace forecast monitor" description = "Groups to mute for Free diskspace forecast monitor"
type = "map" type = "map"
default = {} default = {}
} }
variable "free_disk_space_forecast_enabled" { variable "disk_space_forecast_enabled" {
description = "Flag to enable Free diskspace forecast monitor" description = "Flag to enable Free diskspace forecast monitor"
type = "string" type = "string"
default = "true" default = "true"
} }
variable "free_disk_space_forecast_extra_tags" { variable "disk_space_forecast_extra_tags" {
description = "Extra tags for Free diskspace forecast monitor" description = "Extra tags for Free diskspace forecast monitor"
type = "list" type = "list"
default = [] default = []
} }
variable "free_disk_space_forecast_message" { variable "disk_space_forecast_message" {
description = "Custom message for Free diskspace forecast monitor" description = "Custom message for Free diskspace forecast monitor"
type = "string" type = "string"
default = "" default = ""
} }
variable "free_disk_space_forecast_time_aggregator" { variable "disk_space_forecast_time_aggregator" {
description = "Monitor aggregator for Free diskspace forecast [available values: min, max or avg]" description = "Monitor aggregator for Free diskspace forecast [available values: min, max or avg]"
type = "string" type = "string"
default = "max" default = "max"
} }
variable "free_disk_space_forecast_timeframe" { variable "disk_space_forecast_timeframe" {
description = "Monitor timeframe for Free diskspace forecast [available values: `next_12h`, `next_#d` (1, 2, or 3), `next_#w` (1 or 2) or `next_#mo` (1, 2 or 3)]" description = "Monitor timeframe for Free diskspace forecast [available values: `next_12h`, `next_#d` (1, 2, or 3), `next_#w` (1 or 2) or `next_#mo` (1, 2 or 3)]"
type = "string" type = "string"
default = "next_1w" default = "next_1w"
} }
variable "free_disk_space_forecast_algorithm" { variable "disk_space_forecast_algorithm" {
description = "Algorithm for the Free diskspace Forecast monitor [available values: `linear` or `seasonal`]" description = "Algorithm for the Free diskspace Forecast monitor [available values: `linear` or `seasonal`]"
type = "string" type = "string"
default = "linear" default = "linear"
} }
variable "free_disk_space_forecast_deviations" { variable "disk_space_forecast_deviations" {
description = "Deviations for the Free diskspace Forecast monitor [available values: `1`, `2`, `3`, `4` or `5`]" description = "Deviations for the Free diskspace Forecast monitor [available values: `1`, `2`, `3`, `4` or `5`]"
type = "string" type = "string"
default = 1 default = 1
} }
variable "free_disk_space_forecast_interval" { variable "disk_space_forecast_interval" {
description = "Interval for the Free diskspace Forecast monitor [available values: `30m`, `60m` or `120m`]" description = "Interval for the Free diskspace Forecast monitor [available values: `30m`, `60m` or `120m`]"
type = "string" type = "string"
default = "60m" default = "60m"
} }
variable "free_disk_space_forecast_linear_history" { variable "disk_space_forecast_linear_history" {
description = "History for the Free diskspace Forecast monitor [available values: `12h`, `#d` (1, 2, or 3), `#w` (1, or 2) or `#mo` (1, 2 or 3)]" description = "History for the Free diskspace Forecast monitor [available values: `12h`, `#d` (1, 2, or 3), `#w` (1, or 2) or `#mo` (1, 2 or 3)]"
type = "string" type = "string"
default = "1w" default = "1w"
} }
variable "free_disk_space_forecast_linear_model" { variable "disk_space_forecast_linear_model" {
description = "Model for the Free diskspace Forecast monitor [available values: `default`, `simple` or `reactive`]" description = "Model for the Free diskspace Forecast monitor [available values: `default`, `simple` or `reactive`]"
type = "string" type = "string"
default = "default" default = "default"
} }
variable "free_disk_space_forecast_seasonal_seasonality" { variable "disk_space_forecast_seasonal_seasonality" {
description = "Seasonality for the Free diskspace Forecast monitor" description = "Seasonality for the Free diskspace Forecast monitor"
type = "string" type = "string"
default = "weekly" default = "weekly"
} }
variable "free_disk_space_forecast_threshold_critical_recovery" { variable "disk_space_forecast_threshold_critical_recovery" {
description = "Free disk space forecast recovery threshold" description = "Free disk space forecast recovery threshold"
default = 72 default = 72
} }
variable "free_disk_space_forecast_threshold_critical" { variable "disk_space_forecast_threshold_critical" {
description = "Free disk space forecast critical threshold" description = "Free disk space forecast critical threshold"
default = 80 default = 80
} }
variable "free_disk_inodes_silenced" { variable "disk_inodes_silenced" {
description = "Groups to mute for Free disk inodes monitor" description = "Groups to mute for Free disk inodes monitor"
type = "map" type = "map"
default = {} default = {}
} }
variable "free_disk_inodes_enabled" { variable "disk_inodes_enabled" {
description = "Flag to enable Free disk inodes monitor" description = "Flag to enable Free disk inodes monitor"
type = "string" type = "string"
default = "true" default = "true"
} }
variable "free_disk_inodes_extra_tags" { variable "disk_inodes_extra_tags" {
description = "Extra tags for Free disk inodes monitor" description = "Extra tags for Free disk inodes monitor"
type = "list" type = "list"
default = [] default = []
} }
variable "free_disk_inodes_message" { variable "disk_inodes_message" {
description = "Custom message for Free disk inodes monitor" description = "Custom message for Free disk inodes monitor"
type = "string" type = "string"
default = "" default = ""
} }
variable "free_disk_inodes_time_aggregator" { variable "disk_inodes_time_aggregator" {
description = "Monitor aggregator for Free disk inodes [available values: min, max or avg]" description = "Monitor aggregator for Free disk inodes [available values: min, max or avg]"
type = "string" type = "string"
default = "min" default = "min"
} }
variable "free_disk_inodes_timeframe" { variable "disk_inodes_timeframe" {
description = "Monitor timeframe for Free disk inodes [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" description = "Monitor timeframe for Free disk inodes [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
type = "string" type = "string"
default = "last_5m" default = "last_5m"
} }
variable "free_disk_inodes_threshold_warning" { variable "disk_inodes_threshold_warning" {
description = "Free disk space warning threshold" description = "Free disk space warning threshold"
default = 10 default = 90
} }
variable "free_disk_inodes_threshold_critical" { variable "disk_inodes_threshold_critical" {
description = "Free disk space critical threshold" description = "Free disk space critical threshold"
default = 5 default = 95
} }
variable "free_memory_silenced" { variable "memory_silenced" {
description = "Groups to mute for Free memory monitor" description = "Groups to mute for Free memory monitor"
type = "map" type = "map"
default = {} default = {}
} }
variable "free_memory_enabled" { variable "memory_enabled" {
description = "Flag to enable Free memory monitor" description = "Flag to enable Free memory monitor"
type = "string" type = "string"
default = "true" default = "true"
} }
variable "free_memory_extra_tags" { variable "memory_extra_tags" {
description = "Extra tags for Free memory monitor" description = "Extra tags for Free memory monitor"
type = "list" type = "list"
default = [] default = []
} }
variable "free_memory_message" { variable "memory_message" {
description = "Mandatory message for Free memory monitor to avoid NBH alerting by default" description = "Mandatory message for Free memory monitor to avoid NBH alerting by default"
type = "string" type = "string"
} }
variable "free_memory_time_aggregator" { variable "memory_time_aggregator" {
description = "Monitor aggregator for Free memory [available values: min, max or avg]" description = "Monitor aggregator for Free memory [available values: min, max or avg]"
type = "string" type = "string"
default = "max" default = "max"
} }
variable "free_memory_timeframe" { variable "memory_timeframe" {
description = "Monitor timeframe for Free memory [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" description = "Monitor timeframe for Free memory [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
type = "string" type = "string"
default = "last_5m" default = "last_5m"
} }
variable "free_memory_threshold_warning" { variable "memory_threshold_warning" {
description = "Free disk space warning threshold" description = "Free disk space warning threshold"
default = 10 default = 10
} }
variable "free_memory_threshold_critical" { variable "memory_threshold_critical" {
description = "Free disk space critical threshold" description = "Free disk space critical threshold"
default = 5 default = 5
} }

View File

@ -1,19 +1,19 @@
resource "datadog_monitor" "datadog_cpu_too_high" { resource "datadog_monitor" "cpu" {
count = "${var.cpu_high_enabled ? 1 : 0}" count = "${var.cpu_enabled ? 1 : 0}"
name = "[${var.environment}] CPU usage {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" name = "[${var.environment}] CPU usage {{#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_message, var.message)}"
query = <<EOF query = <<EOF
${var.cpu_high_time_aggregator}(${var.cpu_high_timeframe}): ( ${var.cpu_time_aggregator}(${var.cpu_timeframe}): (
100 - avg:system.cpu.idle${module.filter-tags.query_alert} by {region,host} 100 - avg:system.cpu.idle${module.filter-tags.query_alert} by {host}
) > ${var.cpu_high_threshold_critical} ) > ${var.cpu_threshold_critical}
EOF EOF
type = "metric alert" type = "metric alert"
thresholds { thresholds {
warning = "${var.cpu_high_threshold_warning}" warning = "${var.cpu_threshold_warning}"
critical = "${var.cpu_high_threshold_critical}" critical = "${var.cpu_threshold_critical}"
} }
notify_no_data = false notify_no_data = false
@ -25,27 +25,27 @@ resource "datadog_monitor" "datadog_cpu_too_high" {
locked = false locked = false
require_full_window = true require_full_window = true
silenced = "${var.cpu_high_silenced}" silenced = "${var.cpu_silenced}"
tags = ["env:${var.environment}", "type:system", "provider:system-check", "resource:generic", "team:claranet", "created-by:terraform", "${var.cpu_high_extra_tags}"] tags = ["env:${var.environment}", "type:system", "provider:system-check", "resource:generic", "team:claranet", "created-by:terraform", "${var.cpu_extra_tags}"]
} }
resource "datadog_monitor" "datadog_load_too_high" { resource "datadog_monitor" "load" {
count = "${var.cpu_load_enabled ? 1 : 0}" count = "${var.load_enabled ? 1 : 0}"
name = "[${var.environment}] CPU load 5 ratio {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}" name = "[${var.environment}] CPU load 5 ratio {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}"
message = "${coalesce(var.cpu_load_message, var.message)}" message = "${coalesce(var.load_message, var.message)}"
query = <<EOF query = <<EOF
${var.cpu_load_time_aggregator}(${var.cpu_load_timeframe}): ( ${var.load_time_aggregator}(${var.load_timeframe}): (
avg:system.load.norm.5${module.filter-tags.query_alert} by {region,host} avg:system.load.norm.5${module.filter-tags.query_alert} by {host}
) > ${var.cpu_load_threshold_critical} ) > ${var.load_threshold_critical}
EOF EOF
type = "metric alert" type = "metric alert"
thresholds { thresholds {
warning = "${var.cpu_load_threshold_warning}" warning = "${var.load_threshold_warning}"
critical = "${var.cpu_load_threshold_critical}" critical = "${var.load_threshold_critical}"
} }
notify_no_data = false notify_no_data = false
@ -57,28 +57,27 @@ resource "datadog_monitor" "datadog_load_too_high" {
locked = false locked = false
require_full_window = true require_full_window = true
silenced = "${var.cpu_load_silenced}" silenced = "${var.load_silenced}"
tags = ["env:${var.environment}", "type:system", "provider:system-core", "resource:generic", "team:claranet", "created-by:terraform", "${var.cpu_load_extra_tags}"] tags = ["env:${var.environment}", "type:system", "provider:system-core", "resource:generic", "team:claranet", "created-by:terraform", "${var.load_extra_tags}"]
} }
resource "datadog_monitor" "datadog_free_disk_space_too_low" { resource "datadog_monitor" "disk_space" {
count = "${var.free_disk_space_enabled ? 1 : 0}" count = "${var.disk_space_enabled ? 1 : 0}"
name = "[${var.environment}] Free disk space {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" name = "[${var.environment}] Disk space usage {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"
message = "${coalesce(var.free_disk_space_message, var.message)}" message = "${coalesce(var.disk_space_message, var.message)}"
query = <<EOF query = <<EOF
${var.free_disk_space_time_aggregator}(${var.free_disk_space_timeframe}): ( ${var.disk_space_time_aggregator}(${var.disk_space_timeframe}):
avg:system.disk.free${module.filter-tags-disk.query_alert} by {region,host,device} / avg:system.disk.in_use${module.filter-tags-disk.query_alert} by {host,device}
avg:system.disk.total${module.filter-tags-disk.query_alert} by {region,host,device} * 100 * 100 > ${var.disk_space_threshold_critical}
) < ${var.free_disk_space_threshold_critical}
EOF EOF
type = "metric alert" type = "metric alert"
thresholds { thresholds {
warning = "${var.free_disk_space_threshold_warning}" warning = "${var.disk_space_threshold_warning}"
critical = "${var.free_disk_space_threshold_critical}" critical = "${var.disk_space_threshold_critical}"
} }
notify_no_data = false notify_no_data = false
@ -90,33 +89,33 @@ resource "datadog_monitor" "datadog_free_disk_space_too_low" {
locked = false locked = false
require_full_window = true require_full_window = true
silenced = "${var.free_disk_space_silenced}" silenced = "${var.disk_space_silenced}"
tags = ["env:${var.environment}", "type:system", "provider:disk", "resource:generic", "team:claranet", "created-by:terraform", "${var.free_disk_space_extra_tags}"] tags = ["env:${var.environment}", "type:system", "provider:disk", "resource:generic", "team:claranet", "created-by:terraform", "${var.disk_space_extra_tags}"]
} }
resource "datadog_monitor" "datadog_free_disk_space_forecast" { resource "datadog_monitor" "disk_space_forecast" {
count = "${var.free_disk_space_forecast_enabled ? 1 : 0}" count = "${var.disk_space_forecast_enabled ? 1 : 0}"
name = "[${var.environment}] Disk Space could reach {{#is_alert}}{{threshold}}%{{/is_alert}} in a near future" name = "[${var.environment}] Disk Space usage could reach {{#is_alert}}{{threshold}}%{{/is_alert}} in a near future"
message = "${coalesce(var.free_disk_space_forecast_message, var.message)}" message = "${coalesce(var.disk_space_forecast_message, var.message)}"
query = <<EOF query = <<EOF
${var.free_disk_space_forecast_time_aggregator}(${var.free_disk_space_forecast_timeframe}): ${var.disk_space_forecast_time_aggregator}(${var.disk_space_forecast_timeframe}):
forecast(avg:system.disk.in_use${module.filter-tags-disk.query_alert} by {host,device} * 100, forecast(avg:system.disk.in_use${module.filter-tags-disk.query_alert} by {host,device} * 100,
'${var.free_disk_space_forecast_algorithm}', '${var.disk_space_forecast_algorithm}',
${var.free_disk_space_forecast_deviations}, ${var.disk_space_forecast_deviations},
interval='${var.free_disk_space_forecast_interval}', interval='${var.disk_space_forecast_interval}',
${var.free_disk_space_forecast_algorithm == "linear" ? format("history='%s',model='%s'", var.free_disk_space_forecast_linear_history, var.free_disk_space_forecast_linear_model): ""} ${var.disk_space_forecast_algorithm == "linear" ? format("history='%s',model='%s'", var.disk_space_forecast_linear_history, var.disk_space_forecast_linear_model): ""}
${var.free_disk_space_forecast_algorithm == "seasonal" ? format("seasonality='%s'", var.free_disk_space_forecast_seasonal_seasonality): ""} ${var.disk_space_forecast_algorithm == "seasonal" ? format("seasonality='%s'", var.disk_space_forecast_seasonal_seasonality): ""}
) )
>= ${var.free_disk_space_forecast_threshold_critical} >= ${var.disk_space_forecast_threshold_critical}
EOF EOF
type = "query alert" type = "query alert"
thresholds { thresholds {
critical_recovery = "${var.free_disk_space_forecast_threshold_critical_recovery}" critical_recovery = "${var.disk_space_forecast_threshold_critical_recovery}"
critical = "${var.free_disk_space_forecast_threshold_critical}" critical = "${var.disk_space_forecast_threshold_critical}"
} }
notify_audit = false notify_audit = false
@ -130,28 +129,27 @@ resource "datadog_monitor" "datadog_free_disk_space_forecast" {
evaluation_delay = "${var.evaluation_delay}" evaluation_delay = "${var.evaluation_delay}"
new_host_delay = "${var.new_host_delay}" new_host_delay = "${var.new_host_delay}"
silenced = "${var.free_disk_space_forecast_silenced}" silenced = "${var.disk_space_forecast_silenced}"
tags = ["env:${var.environment}", "type:system", "provider:disk", "resource:generic", "team:claranet", "created-by:terraform", "${var.free_disk_space_forecast_extra_tags}"] tags = ["env:${var.environment}", "type:system", "provider:disk", "resource:generic", "team:claranet", "created-by:terraform", "${var.disk_space_forecast_extra_tags}"]
} }
resource "datadog_monitor" "datadog_free_disk_space_inodes_too_low" { resource "datadog_monitor" "disk_inodes" {
count = "${var.free_disk_inodes_enabled ? 1 : 0}" count = "${var.disk_inodes_enabled ? 1 : 0}"
name = "[${var.environment}] Free disk inodes {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" name = "[${var.environment}] Disk inodes usage {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"
message = "${coalesce(var.free_disk_inodes_message, var.message)}" message = "${coalesce(var.disk_inodes_message, var.message)}"
query = <<EOF query = <<EOF
${var.free_disk_inodes_time_aggregator}(${var.free_disk_inodes_timeframe}): ( ${var.disk_inodes_time_aggregator}(${var.disk_inodes_timeframe}):
avg:system.fs.inodes.free${module.filter-tags-disk.query_alert} by {region,host,device} / avg:system.fs.inodes.in_use${module.filter-tags-disk.query_alert} by {host,device}
avg:system.fs.inodes.total${module.filter-tags-disk.query_alert} by {region,host,device} * 100 * 100 > ${var.disk_inodes_threshold_critical}
) < ${var.free_disk_inodes_threshold_critical}
EOF EOF
type = "metric alert" type = "metric alert"
thresholds { thresholds {
warning = "${var.free_disk_inodes_threshold_warning}" warning = "${var.disk_inodes_threshold_warning}"
critical = "${var.free_disk_inodes_threshold_critical}" critical = "${var.disk_inodes_threshold_critical}"
} }
notify_no_data = false notify_no_data = false
@ -163,28 +161,28 @@ resource "datadog_monitor" "datadog_free_disk_space_inodes_too_low" {
locked = false locked = false
require_full_window = true require_full_window = true
silenced = "${var.free_disk_inodes_silenced}" silenced = "${var.disk_inodes_silenced}"
tags = ["env:${var.environment}", "type:system", "provider:disk", "resource:generic", "team:claranet", "created-by:terraform", "${var.free_disk_inodes_extra_tags}"] tags = ["env:${var.environment}", "type:system", "provider:disk", "resource:generic", "team:claranet", "created-by:terraform", "${var.disk_inodes_extra_tags}"]
} }
resource "datadog_monitor" "datadog_free_memory" { resource "datadog_monitor" "memory" {
count = "${var.free_memory_enabled ? 1 : 0}" count = "${var.memory_enabled ? 1 : 0}"
name = "[${var.environment}] Free memory {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" name = "[${var.environment}] Usable Memory {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"
message = "${var.free_memory_message}" message = "${var.memory_message}"
query = <<EOF query = <<EOF
${var.free_memory_time_aggregator}(${var.free_memory_timeframe}): ( ${var.memory_time_aggregator}(${var.memory_timeframe}):
avg:system.mem.usable${module.filter-tags.query_alert} by {region,host} / avg:system.mem.usable${module.filter-tags.query_alert} by {host} /
avg:system.mem.total${module.filter-tags.query_alert} by {region,host} * 100 avg:system.mem.total${module.filter-tags.query_alert} by {host} * 100
) < ${var.free_memory_threshold_critical} < ${var.memory_threshold_critical}
EOF EOF
type = "metric alert" type = "metric alert"
thresholds { thresholds {
warning = "${var.free_memory_threshold_warning}" warning = "${var.memory_threshold_warning}"
critical = "${var.free_memory_threshold_critical}" critical = "${var.memory_threshold_critical}"
} }
notify_no_data = false notify_no_data = false
@ -197,7 +195,7 @@ resource "datadog_monitor" "datadog_free_memory" {
locked = false locked = false
require_full_window = true require_full_window = true
silenced = "${var.free_memory_silenced}" silenced = "${var.memory_silenced}"
tags = ["env:${var.environment}", "type:system", "provider:system-check", "resource:generic", "team:claranet", "created-by:terraform", "${var.free_memory_extra_tags}"] tags = ["env:${var.environment}", "type:system", "provider:system-check", "resource:generic", "team:claranet", "created-by:terraform", "${var.memory_extra_tags}"]
} }

View File

@ -1,29 +1,29 @@
output "datadog_cpu_too_high_id" { output "cpu_id" {
description = "id for monitor datadog_cpu_too_high" description = "id for monitor cpu"
value = "${datadog_monitor.datadog_cpu_too_high.*.id}" value = "${datadog_monitor.cpu.*.id}"
} }
output "datadog_load_too_high_id" { output "load_id" {
description = "id for monitor datadog_load_too_high" description = "id for monitor load"
value = "${datadog_monitor.datadog_load_too_high.*.id}" value = "${datadog_monitor.load.*.id}"
} }
output "datadog_free_disk_space_too_low_id" { output "disk_space_id" {
description = "id for monitor datadog_free_disk_space_too_low" description = "id for monitor disk_space"
value = "${datadog_monitor.datadog_free_disk_space_too_low.*.id}" value = "${datadog_monitor.disk_space.*.id}"
} }
output "datadog_free_disk_space_forecast_id" { output "disk_space_forecast_id" {
description = "id for monitor datadog_free_disk_space_forecast" description = "id for monitor disk_space_forecast"
value = "${datadog_monitor.datadog_free_disk_space_forecast.*.id}" value = "${datadog_monitor.disk_space_forecast.*.id}"
} }
output "datadog_free_disk_space_inodes_too_low_id" { output "disk_inodes_id" {
description = "id for monitor datadog_free_disk_space_inodes_too_low" description = "id for monitor disk_inodes"
value = "${datadog_monitor.datadog_free_disk_space_inodes_too_low.*.id}" value = "${datadog_monitor.disk_inodes.*.id}"
} }
output "datadog_free_memory_id" { output "memory_id" {
description = "id for monitor datadog_free_memory" description = "id for monitor memory"
value = "${datadog_monitor.datadog_free_memory.*.id}" value = "${datadog_monitor.memory.*.id}"
} }