Merge branch 'MON-320_prefer_greater_logic' into 'master'

MON-320 greater logic for system monitors

Closes MON-320

See merge request claranet/pt-monitoring/projects/datadog/terraform/monitors!45
This commit is contained in:
Quentin Manfroi 2019-04-23 17:21:55 +02:00
commit 0ffcebaec6
4 changed files with 211 additions and 213 deletions

View File

@ -9,7 +9,7 @@ module "datadog-monitors-system-generic" {
environment = "${var.environment}"
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 usage
- Disk Space forecast
- Free disk inodes
- Free disk space
- Free memory
- Disk inodes usage
- Disk Space usage forecast
- Disk space usage
- Usable Memory
## Inputs
| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| cpu\_high\_enabled | Flag to enable CPU high monitor | string | `"true"` | no |
| cpu\_high\_extra\_tags | Extra tags for CPU high monitor | list | `[]` | no |
| cpu\_high\_message | Custom message for CPU high monitor | string | `""` | no |
| cpu\_high\_silenced | Groups to mute for CPU high monitor | map | `{}` | no |
| cpu\_high\_threshold\_critical | CPU high critical threshold | string | `"90"` | no |
| cpu\_high\_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\_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\_load\_enabled | Flag to enable CPU load ratio monitor | string | `"true"` | no |
| cpu\_load\_extra\_tags | Extra tags for CPU load ratio monitor | list | `[]` | no |
| cpu\_load\_message | Custom message for CPU load ratio monitor | string | `""` | no |
| cpu\_load\_silenced | Groups to mute for CPU load ratio monitor | map | `{}` | no |
| cpu\_load\_threshold\_critical | CPU load ratio critical threshold | string | `"2.5"` | no |
| cpu\_load\_threshold\_warning | CPU load ratio warning threshold | string | `"2"` | no |
| cpu\_load\_time\_aggregator | Monitor aggregator for CPU load ratio [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 |
| cpu\_enabled | Flag to enable CPU high monitor | string | `"true"` | no |
| cpu\_extra\_tags | Extra tags for CPU high monitor | list | `[]` | no |
| cpu\_message | Custom message for CPU high monitor | string | `""` | no |
| cpu\_silenced | Groups to mute for CPU high monitor | map | `{}` | no |
| cpu\_threshold\_critical | CPU high critical threshold | string | `"90"` | no |
| cpu\_threshold\_warning | CPU high warning threshold | string | `"85"` | no |
| cpu\_time\_aggregator | Monitor aggregator for CPU high [available values: min, max or avg] | string | `"min"` | 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 |
| disk\_inodes\_enabled | Flag to enable Free disk inodes monitor | string | `"true"` | no |
| disk\_inodes\_extra\_tags | Extra tags for Free disk inodes monitor | list | `[]` | no |
| disk\_inodes\_message | Custom message for Free disk inodes monitor | string | `""` | no |
| disk\_inodes\_silenced | Groups to mute for Free disk inodes monitor | map | `{}` | no |
| disk\_inodes\_threshold\_critical | Free disk space critical threshold | string | `"95"` | no |
| disk\_inodes\_threshold\_warning | Free disk space warning threshold | string | `"90"` | no |
| disk\_inodes\_time\_aggregator | Monitor aggregator for Free disk inodes [available values: min, max or avg] | string | `"min"` | 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 |
| 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\_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 |
| free\_disk\_inodes\_enabled | Flag to enable Free disk inodes monitor | string | `"true"` | no |
| free\_disk\_inodes\_extra\_tags | Extra tags for Free disk inodes monitor | list | `[]` | no |
| free\_disk\_inodes\_message | Custom message for Free disk inodes monitor | string | `""` | no |
| free\_disk\_inodes\_silenced | Groups to mute for Free disk inodes monitor | map | `{}` | no |
| free\_disk\_inodes\_threshold\_critical | Free disk space critical threshold | string | `"5"` | no |
| free\_disk\_inodes\_threshold\_warning | Free disk space warning threshold | string | `"10"` | no |
| free\_disk\_inodes\_time\_aggregator | Monitor aggregator for Free disk inodes [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 |
| free\_disk\_space\_enabled | Flag to enable Free diskspace monitor | string | `"true"` | no |
| free\_disk\_space\_extra\_tags | Extra tags for Free diskspace monitor | list | `[]` | no |
| free\_disk\_space\_forecast\_algorithm | Algorithm for the Free diskspace Forecast monitor [available values: `linear` or `seasonal`] | string | `"linear"` | no |
| free\_disk\_space\_forecast\_deviations | Deviations for the Free diskspace Forecast monitor [available values: `1`, `2`, `3`, `4` or `5`] | string | `"1"` | no |
| free\_disk\_space\_forecast\_enabled | Flag to enable Free diskspace forecast monitor | string | `"true"` | no |
| free\_disk\_space\_forecast\_extra\_tags | Extra tags for Free diskspace forecast monitor | list | `[]` | no |
| free\_disk\_space\_forecast\_interval | Interval for the Free diskspace Forecast monitor [available values: `30m`, `60m` or `120m`] | string | `"60m"` | 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 |
| 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 |
| load\_enabled | Flag to enable CPU load ratio monitor | string | `"true"` | no |
| load\_extra\_tags | Extra tags for CPU load ratio monitor | list | `[]` | no |
| load\_message | Custom message for CPU load ratio monitor | string | `""` | no |
| load\_silenced | Groups to mute for CPU load ratio monitor | map | `{}` | no |
| load\_threshold\_critical | CPU load ratio critical threshold | string | `"2.5"` | no |
| load\_threshold\_warning | CPU load ratio warning threshold | string | `"2"` | no |
| load\_time\_aggregator | Monitor aggregator for CPU load ratio [available values: min, max or avg] | string | `"min"` | 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 |
| memory\_enabled | Flag to enable Free memory monitor | string | `"true"` | no |
| memory\_extra\_tags | Extra tags for Free memory monitor | list | `[]` | no |
| memory\_message | Mandatory message for Free memory monitor to avoid NBH alerting by default | string | n/a | yes |
| memory\_silenced | Groups to mute for Free memory monitor | map | `{}` | no |
| memory\_threshold\_critical | Free disk space critical threshold | string | `"5"` | no |
| memory\_threshold\_warning | Free disk space warning threshold | string | `"10"` | no |
| memory\_time\_aggregator | Monitor aggregator for Free memory [available values: min, max or avg] | string | `"max"` | 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 |
| 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 |
@ -95,12 +95,12 @@ Creates DataDog monitors with the following checks:
| Name | Description |
|------|-------------|
| datadog\_cpu\_too\_high\_id | id for monitor datadog_cpu_too_high |
| datadog\_free\_disk\_space\_forecast\_id | id for monitor datadog_free_disk_space_forecast |
| datadog\_free\_disk\_space\_inodes\_too\_low\_id | id for monitor datadog_free_disk_space_inodes_too_low |
| datadog\_free\_disk\_space\_too\_low\_id | id for monitor datadog_free_disk_space_too_low |
| datadog\_free\_memory\_id | id for monitor datadog_free_memory |
| datadog\_load\_too\_high\_id | id for monitor datadog_load_too_high |
| cpu\_id | id for monitor cpu |
| disk\_inodes\_id | id for monitor disk_inodes |
| disk\_space\_forecast\_id | id for monitor disk_space_forecast |
| disk\_space\_id | id for monitor disk_space |
| load\_id | id for monitor load |
| memory\_id | id for monitor memory |
## Related documentation

View File

@ -36,313 +36,313 @@ variable "filter_tags_custom_excluded" {
# System generic specific
variable "cpu_high_silenced" {
variable "cpu_silenced" {
description = "Groups to mute for CPU high monitor"
type = "map"
default = {}
}
variable "cpu_high_enabled" {
variable "cpu_enabled" {
description = "Flag to enable CPU high monitor"
type = "string"
default = "true"
}
variable "cpu_high_extra_tags" {
variable "cpu_extra_tags" {
description = "Extra tags for CPU high monitor"
type = "list"
default = []
}
variable "cpu_high_message" {
variable "cpu_message" {
description = "Custom message for CPU high monitor"
type = "string"
default = ""
}
variable "cpu_high_time_aggregator" {
variable "cpu_time_aggregator" {
description = "Monitor aggregator for CPU high [available values: min, max or avg]"
type = "string"
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`]"
type = "string"
default = "last_10m"
}
variable "cpu_high_threshold_warning" {
variable "cpu_threshold_warning" {
description = "CPU high warning threshold"
default = 85
}
variable "cpu_high_threshold_critical" {
variable "cpu_threshold_critical" {
description = "CPU high critical threshold"
default = 90
}
variable "cpu_load_silenced" {
variable "load_silenced" {
description = "Groups to mute for CPU load ratio monitor"
type = "map"
default = {}
}
variable "cpu_load_enabled" {
variable "load_enabled" {
description = "Flag to enable CPU load ratio monitor"
type = "string"
default = "true"
}
variable "cpu_load_extra_tags" {
variable "load_extra_tags" {
description = "Extra tags for CPU load ratio monitor"
type = "list"
default = []
}
variable "cpu_load_message" {
variable "load_message" {
description = "Custom message for CPU load ratio monitor"
type = "string"
default = ""
}
variable "cpu_load_time_aggregator" {
variable "load_time_aggregator" {
description = "Monitor aggregator for CPU load ratio [available values: min, max or avg]"
type = "string"
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`]"
type = "string"
default = "last_15m"
}
variable "cpu_load_threshold_warning" {
variable "load_threshold_warning" {
description = "CPU load ratio warning threshold"
default = 2
}
variable "cpu_load_threshold_critical" {
variable "load_threshold_critical" {
description = "CPU load ratio critical threshold"
default = 2.5
}
variable "free_disk_space_silenced" {
variable "disk_space_silenced" {
description = "Groups to mute for Free diskspace monitor"
type = "map"
default = {}
}
variable "free_disk_space_enabled" {
variable "disk_space_enabled" {
description = "Flag to enable Free diskspace monitor"
type = "string"
default = "true"
}
variable "free_disk_space_extra_tags" {
variable "disk_space_extra_tags" {
description = "Extra tags for Free diskspace monitor"
type = "list"
default = []
}
variable "free_disk_space_message" {
variable "disk_space_message" {
description = "Custom message for Free diskspace monitor"
type = "string"
default = ""
}
variable "free_disk_space_time_aggregator" {
variable "disk_space_time_aggregator" {
description = "Monitor aggregator for Free diskspace [available values: min, max or avg]"
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`]"
type = "string"
default = "last_5m"
}
variable "free_disk_space_threshold_warning" {
variable "disk_space_threshold_warning" {
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"
default = 10
default = 90
}
variable "free_disk_space_forecast_silenced" {
variable "disk_space_forecast_silenced" {
description = "Groups to mute for Free diskspace forecast monitor"
type = "map"
default = {}
}
variable "free_disk_space_forecast_enabled" {
variable "disk_space_forecast_enabled" {
description = "Flag to enable Free diskspace forecast monitor"
type = "string"
default = "true"
}
variable "free_disk_space_forecast_extra_tags" {
variable "disk_space_forecast_extra_tags" {
description = "Extra tags for Free diskspace forecast monitor"
type = "list"
default = []
}
variable "free_disk_space_forecast_message" {
variable "disk_space_forecast_message" {
description = "Custom message for Free diskspace forecast monitor"
type = "string"
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]"
type = "string"
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)]"
type = "string"
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`]"
type = "string"
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`]"
type = "string"
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`]"
type = "string"
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)]"
type = "string"
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`]"
type = "string"
default = "default"
}
variable "free_disk_space_forecast_seasonal_seasonality" {
variable "disk_space_forecast_seasonal_seasonality" {
description = "Seasonality for the Free diskspace Forecast monitor"
type = "string"
default = "weekly"
}
variable "free_disk_space_forecast_threshold_critical_recovery" {
variable "disk_space_forecast_threshold_critical_recovery" {
description = "Free disk space forecast recovery threshold"
default = 72
}
variable "free_disk_space_forecast_threshold_critical" {
variable "disk_space_forecast_threshold_critical" {
description = "Free disk space forecast critical threshold"
default = 80
}
variable "free_disk_inodes_silenced" {
variable "disk_inodes_silenced" {
description = "Groups to mute for Free disk inodes monitor"
type = "map"
default = {}
}
variable "free_disk_inodes_enabled" {
variable "disk_inodes_enabled" {
description = "Flag to enable Free disk inodes monitor"
type = "string"
default = "true"
}
variable "free_disk_inodes_extra_tags" {
variable "disk_inodes_extra_tags" {
description = "Extra tags for Free disk inodes monitor"
type = "list"
default = []
}
variable "free_disk_inodes_message" {
variable "disk_inodes_message" {
description = "Custom message for Free disk inodes monitor"
type = "string"
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]"
type = "string"
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`]"
type = "string"
default = "last_5m"
}
variable "free_disk_inodes_threshold_warning" {
variable "disk_inodes_threshold_warning" {
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"
default = 5
default = 95
}
variable "free_memory_silenced" {
variable "memory_silenced" {
description = "Groups to mute for Free memory monitor"
type = "map"
default = {}
}
variable "free_memory_enabled" {
variable "memory_enabled" {
description = "Flag to enable Free memory monitor"
type = "string"
default = "true"
}
variable "free_memory_extra_tags" {
variable "memory_extra_tags" {
description = "Extra tags for Free memory monitor"
type = "list"
default = []
}
variable "free_memory_message" {
variable "memory_message" {
description = "Mandatory message for Free memory monitor to avoid NBH alerting by default"
type = "string"
}
variable "free_memory_time_aggregator" {
variable "memory_time_aggregator" {
description = "Monitor aggregator for Free memory [available values: min, max or avg]"
type = "string"
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`]"
type = "string"
default = "last_5m"
}
variable "free_memory_threshold_warning" {
variable "memory_threshold_warning" {
description = "Free disk space warning threshold"
default = 10
}
variable "free_memory_threshold_critical" {
variable "memory_threshold_critical" {
description = "Free disk space critical threshold"
default = 5
}

View File

@ -1,19 +1,19 @@
resource "datadog_monitor" "datadog_cpu_too_high" {
count = "${var.cpu_high_enabled ? 1 : 0}"
resource "datadog_monitor" "cpu" {
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}}"
message = "${coalesce(var.cpu_high_message, var.message)}"
message = "${coalesce(var.cpu_message, var.message)}"
query = <<EOF
${var.cpu_high_time_aggregator}(${var.cpu_high_timeframe}): (
100 - avg:system.cpu.idle${module.filter-tags.query_alert} by {region,host}
) > ${var.cpu_high_threshold_critical}
${var.cpu_time_aggregator}(${var.cpu_timeframe}): (
100 - avg:system.cpu.idle${module.filter-tags.query_alert} by {host}
) > ${var.cpu_threshold_critical}
EOF
type = "metric alert"
thresholds {
warning = "${var.cpu_high_threshold_warning}"
critical = "${var.cpu_high_threshold_critical}"
warning = "${var.cpu_threshold_warning}"
critical = "${var.cpu_threshold_critical}"
}
notify_no_data = false
@ -25,27 +25,27 @@ resource "datadog_monitor" "datadog_cpu_too_high" {
locked = false
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" {
count = "${var.cpu_load_enabled ? 1 : 0}"
resource "datadog_monitor" "load" {
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}}"
message = "${coalesce(var.cpu_load_message, var.message)}"
message = "${coalesce(var.load_message, var.message)}"
query = <<EOF
${var.cpu_load_time_aggregator}(${var.cpu_load_timeframe}): (
avg:system.load.norm.5${module.filter-tags.query_alert} by {region,host}
) > ${var.cpu_load_threshold_critical}
${var.load_time_aggregator}(${var.load_timeframe}): (
avg:system.load.norm.5${module.filter-tags.query_alert} by {host}
) > ${var.load_threshold_critical}
EOF
type = "metric alert"
thresholds {
warning = "${var.cpu_load_threshold_warning}"
critical = "${var.cpu_load_threshold_critical}"
warning = "${var.load_threshold_warning}"
critical = "${var.load_threshold_critical}"
}
notify_no_data = false
@ -57,28 +57,27 @@ resource "datadog_monitor" "datadog_load_too_high" {
locked = false
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" {
count = "${var.free_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}}"
message = "${coalesce(var.free_disk_space_message, var.message)}"
resource "datadog_monitor" "disk_space" {
count = "${var.disk_space_enabled ? 1 : 0}"
name = "[${var.environment}] Disk space usage {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"
message = "${coalesce(var.disk_space_message, var.message)}"
query = <<EOF
${var.free_disk_space_time_aggregator}(${var.free_disk_space_timeframe}): (
avg:system.disk.free${module.filter-tags-disk.query_alert} by {region,host,device} /
avg:system.disk.total${module.filter-tags-disk.query_alert} by {region,host,device} * 100
) < ${var.free_disk_space_threshold_critical}
${var.disk_space_time_aggregator}(${var.disk_space_timeframe}):
avg:system.disk.in_use${module.filter-tags-disk.query_alert} by {host,device}
* 100 > ${var.disk_space_threshold_critical}
EOF
type = "metric alert"
thresholds {
warning = "${var.free_disk_space_threshold_warning}"
critical = "${var.free_disk_space_threshold_critical}"
warning = "${var.disk_space_threshold_warning}"
critical = "${var.disk_space_threshold_critical}"
}
notify_no_data = false
@ -90,33 +89,33 @@ resource "datadog_monitor" "datadog_free_disk_space_too_low" {
locked = false
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" {
count = "${var.free_disk_space_forecast_enabled ? 1 : 0}"
name = "[${var.environment}] Disk Space could reach {{#is_alert}}{{threshold}}%{{/is_alert}} in a near future"
message = "${coalesce(var.free_disk_space_forecast_message, var.message)}"
resource "datadog_monitor" "disk_space_forecast" {
count = "${var.disk_space_forecast_enabled ? 1 : 0}"
name = "[${var.environment}] Disk Space usage could reach {{#is_alert}}{{threshold}}%{{/is_alert}} in a near future"
message = "${coalesce(var.disk_space_forecast_message, var.message)}"
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,
'${var.free_disk_space_forecast_algorithm}',
${var.free_disk_space_forecast_deviations},
interval='${var.free_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.free_disk_space_forecast_algorithm == "seasonal" ? format("seasonality='%s'", var.free_disk_space_forecast_seasonal_seasonality): ""}
'${var.disk_space_forecast_algorithm}',
${var.disk_space_forecast_deviations},
interval='${var.disk_space_forecast_interval}',
${var.disk_space_forecast_algorithm == "linear" ? format("history='%s',model='%s'", var.disk_space_forecast_linear_history, var.disk_space_forecast_linear_model): ""}
${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
type = "query alert"
thresholds {
critical_recovery = "${var.free_disk_space_forecast_threshold_critical_recovery}"
critical = "${var.free_disk_space_forecast_threshold_critical}"
critical_recovery = "${var.disk_space_forecast_threshold_critical_recovery}"
critical = "${var.disk_space_forecast_threshold_critical}"
}
notify_audit = false
@ -130,28 +129,27 @@ resource "datadog_monitor" "datadog_free_disk_space_forecast" {
evaluation_delay = "${var.evaluation_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" {
count = "${var.free_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}}"
message = "${coalesce(var.free_disk_inodes_message, var.message)}"
resource "datadog_monitor" "disk_inodes" {
count = "${var.disk_inodes_enabled ? 1 : 0}"
name = "[${var.environment}] Disk inodes usage {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"
message = "${coalesce(var.disk_inodes_message, var.message)}"
query = <<EOF
${var.free_disk_inodes_time_aggregator}(${var.free_disk_inodes_timeframe}): (
avg:system.fs.inodes.free${module.filter-tags-disk.query_alert} by {region,host,device} /
avg:system.fs.inodes.total${module.filter-tags-disk.query_alert} by {region,host,device} * 100
) < ${var.free_disk_inodes_threshold_critical}
${var.disk_inodes_time_aggregator}(${var.disk_inodes_timeframe}):
avg:system.fs.inodes.in_use${module.filter-tags-disk.query_alert} by {host,device}
* 100 > ${var.disk_inodes_threshold_critical}
EOF
type = "metric alert"
thresholds {
warning = "${var.free_disk_inodes_threshold_warning}"
critical = "${var.free_disk_inodes_threshold_critical}"
warning = "${var.disk_inodes_threshold_warning}"
critical = "${var.disk_inodes_threshold_critical}"
}
notify_no_data = false
@ -163,28 +161,28 @@ resource "datadog_monitor" "datadog_free_disk_space_inodes_too_low" {
locked = false
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" {
count = "${var.free_memory_enabled ? 1 : 0}"
name = "[${var.environment}] Free memory {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"
message = "${var.free_memory_message}"
resource "datadog_monitor" "memory" {
count = "${var.memory_enabled ? 1 : 0}"
name = "[${var.environment}] Usable Memory {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"
message = "${var.memory_message}"
query = <<EOF
${var.free_memory_time_aggregator}(${var.free_memory_timeframe}): (
avg:system.mem.usable${module.filter-tags.query_alert} by {region,host} /
avg:system.mem.total${module.filter-tags.query_alert} by {region,host} * 100
) < ${var.free_memory_threshold_critical}
${var.memory_time_aggregator}(${var.memory_timeframe}):
avg:system.mem.usable${module.filter-tags.query_alert} by {host} /
avg:system.mem.total${module.filter-tags.query_alert} by {host} * 100
< ${var.memory_threshold_critical}
EOF
type = "metric alert"
thresholds {
warning = "${var.free_memory_threshold_warning}"
critical = "${var.free_memory_threshold_critical}"
warning = "${var.memory_threshold_warning}"
critical = "${var.memory_threshold_critical}"
}
notify_no_data = false
@ -197,7 +195,7 @@ resource "datadog_monitor" "datadog_free_memory" {
locked = false
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" {
description = "id for monitor datadog_cpu_too_high"
value = "${datadog_monitor.datadog_cpu_too_high.*.id}"
output "cpu_id" {
description = "id for monitor cpu"
value = "${datadog_monitor.cpu.*.id}"
}
output "datadog_load_too_high_id" {
description = "id for monitor datadog_load_too_high"
value = "${datadog_monitor.datadog_load_too_high.*.id}"
output "load_id" {
description = "id for monitor load"
value = "${datadog_monitor.load.*.id}"
}
output "datadog_free_disk_space_too_low_id" {
description = "id for monitor datadog_free_disk_space_too_low"
value = "${datadog_monitor.datadog_free_disk_space_too_low.*.id}"
output "disk_space_id" {
description = "id for monitor disk_space"
value = "${datadog_monitor.disk_space.*.id}"
}
output "datadog_free_disk_space_forecast_id" {
description = "id for monitor datadog_free_disk_space_forecast"
value = "${datadog_monitor.datadog_free_disk_space_forecast.*.id}"
output "disk_space_forecast_id" {
description = "id for monitor disk_space_forecast"
value = "${datadog_monitor.disk_space_forecast.*.id}"
}
output "datadog_free_disk_space_inodes_too_low_id" {
description = "id for monitor datadog_free_disk_space_inodes_too_low"
value = "${datadog_monitor.datadog_free_disk_space_inodes_too_low.*.id}"
output "disk_inodes_id" {
description = "id for monitor disk_inodes"
value = "${datadog_monitor.disk_inodes.*.id}"
}
output "datadog_free_memory_id" {
description = "id for monitor datadog_free_memory"
value = "${datadog_monitor.datadog_free_memory.*.id}"
output "memory_id" {
description = "id for monitor memory"
value = "${datadog_monitor.memory.*.id}"
}