MON-66: Terraform HCL re-format (fmt)

This commit is contained in:
Jérôme Respaut 2017-10-27 17:10:38 +02:00
parent 5869c941b4
commit ac6e0d69e1
14 changed files with 146 additions and 156 deletions

View File

@ -112,5 +112,3 @@ resource "datadog_monitor" "ELB_backend_latency" {
new_host_delay = "${var.elb_config["delay"]}" new_host_delay = "${var.elb_config["delay"]}"
no_data_timeframe = 20 no_data_timeframe = 20
} }

View File

@ -1,13 +1,9 @@
resource "datadog_monitor" "rds-mysql_cpu_80_15min" { resource "datadog_monitor" "rds-mysql_cpu_80_15min" {
name = "[${var.env}] rds Cpu high > 90% for 15 min on {{host.identifier}}" name = "[${var.env}] rds Cpu high > 90% for 15 min on {{host.identifier}}"
message = "{{#is_alert}}\n${var.hno_escalation_group} \n{{/is_alert}} \n{{#is_recovery}}\n${var.hno_escalation_group}\n{{/is_recovery}}\n{{#is_warning}}\n${var.ho_escalation_group} \n{{/is_warning}} \n{{#is_warning_recovery}}\n${var.ho_escalation_group}\n{{/is_warning_recovery}}" message = "{{#is_alert}}\n${var.hno_escalation_group} \n{{/is_alert}} \n{{#is_recovery}}\n${var.hno_escalation_group}\n{{/is_recovery}}\n{{#is_warning}}\n${var.ho_escalation_group} \n{{/is_warning}} \n{{#is_warning_recovery}}\n${var.ho_escalation_group}\n{{/is_warning_recovery}}"
count = "${var.dd_aws_rds == "enabled" ? 1 : 0 }" count = "${var.dd_aws_rds == "enabled" ? 1 : 0 }"
query = "avg(last_15m):avg:aws.rds.cpuutilization{dd_monitoring:enabled,dd_aws_rds:enabled,env:${var.env}} by {name,region} > 90" query = "avg(last_15m):avg:aws.rds.cpuutilization{dd_monitoring:enabled,dd_aws_rds:enabled,env:${var.env}} by {name,region} > 90"
type = "query alert" type = "query alert"
@ -36,7 +32,6 @@ resource "datadog_monitor" "mysql_rds_free_space_low" {
query = "avg(last_15m): avg:aws.rds.free_storage_space{dd_monitoring:enabled,dd_aws_rds:enabled,env:${var.env}} by {name,region} / avg:aws.rds.total_storage_space{dd_monitoring:enabled,dd_rds-mysql_basics:enabled,env:${var.env},!dd_custom_rds-mysql:enabled} by {identifier,region} * 100 < 10" query = "avg(last_15m): avg:aws.rds.free_storage_space{dd_monitoring:enabled,dd_aws_rds:enabled,env:${var.env}} by {name,region} / avg:aws.rds.total_storage_space{dd_monitoring:enabled,dd_rds-mysql_basics:enabled,env:${var.env},!dd_custom_rds-mysql:enabled} by {identifier,region} * 100 < 10"
count = "${var.dd_aws_rds == "enabled" ? 1 : 0 }" count = "${var.dd_aws_rds == "enabled" ? 1 : 0 }"
thresholds { thresholds {
warning = "${var.rds_mem_threshold["warning"]}" warning = "${var.rds_mem_threshold["warning"]}"
critical = "${var.rds_mem_threshold["critical"]}" critical = "${var.rds_mem_threshold["critical"]}"
@ -52,6 +47,4 @@ resource "datadog_monitor" "mysql_rds_free_space_low" {
require_full_window = true require_full_window = true
new_host_delay = "${var.rds_config["delay"]}" new_host_delay = "${var.rds_config["delay"]}"
no_data_timeframe = 20 no_data_timeframe = 20
} }

View File

@ -1,8 +1,8 @@
resource "datadog_monitor" "datadog_cassandra_down" { resource "datadog_monitor" "datadog_cassandra_down" {
name = "Cassandra service is down" name = "Cassandra service is down"
message = "{{#is_alert}}\n${var.alert_HNO} \n{{/is_alert}} \n{{#is_recovery}}\n${var.alert_HNO}\n{{/is_recovery}}" message = "{{#is_alert}}\n${var.alert_HNO} \n{{/is_alert}} \n{{#is_recovery}}\n${var.alert_HNO}\n{{/is_recovery}}"
query = "\"cassandra.can_connect\".over(\"cassandra-node\").by(\"host\",\"instance\").last(2).count_by_status()" query = "\"cassandra.can_connect\".over(\"cassandra-node\").by(\"host\",\"instance\").last(2).count_by_status()"
type = "service check" type = "service check"
notify_no_data = false notify_no_data = false
renotify_interval = 60 renotify_interval = 60
@ -36,3 +36,4 @@ renotify_interval = 0
no_data_timeframe = 20 no_data_timeframe = 20
}*/ }*/

View File

@ -1,8 +1,8 @@
resource "datadog_monitor" "cloud_sql_cpu_90" { resource "datadog_monitor" "cloud_sql_cpu_90" {
name = "Cloud SQL CPU high > 90%" name = "Cloud SQL CPU high > 90%"
message = "{{#is_alert}}\n${var.alert_HNO} \n{{/is_alert}} \n{{#is_recovery}}\n${var.alert_HNO}\n{{/is_recovery}}" message = "{{#is_alert}}\n${var.alert_HNO} \n{{/is_alert}} \n{{#is_recovery}}\n${var.alert_HNO}\n{{/is_recovery}}"
query = "avg(last_5m):avg:gcp.cloudsql.database.cpu.utilization{project_id:${var.project_id}} >= 90" query = "avg(last_5m):avg:gcp.cloudsql.database.cpu.utilization{project_id:${var.project_id}} >= 90"
type = "query alert" type = "query alert"
notify_no_data = false notify_no_data = false
renotify_interval = 60 renotify_interval = 60
@ -18,9 +18,9 @@ resource "datadog_monitor" "cloud_sql_cpu_90" {
} }
resource "datadog_monitor" "cloud_sql_disk_space" { resource "datadog_monitor" "cloud_sql_disk_space" {
name = "Cloud SQL free disk space < 10%" name = "Cloud SQL free disk space < 10%"
message = "{{#is_alert}}\n${var.alert_HNO} \n{{/is_alert}} \n{{#is_recovery}}\n${var.alert_HNO}\n{{/is_recovery}}\n{{#is_warning}}\n${var.warning_HO} \n{{/is_warning}} \n{{#is_warning_recovery}}\n${var.warning_HO}\n{{/is_warning_recovery}}" message = "{{#is_alert}}\n${var.alert_HNO} \n{{/is_alert}} \n{{#is_recovery}}\n${var.alert_HNO}\n{{/is_recovery}}\n{{#is_warning}}\n${var.warning_HO} \n{{/is_warning}} \n{{#is_warning_recovery}}\n${var.warning_HO}\n{{/is_warning_recovery}}"
query = "avg(last_5m):avg:gcp.cloudsql.database.disk.bytes_used{project_id:${var.project_id}} by {database_id} / avg:gcp.cloudsql.database.disk.quota{project_id:${var.project_id}} by {database_id} * 100 >= 90" query = "avg(last_5m):avg:gcp.cloudsql.database.disk.bytes_used{project_id:${var.project_id}} by {database_id} / avg:gcp.cloudsql.database.disk.quota{project_id:${var.project_id}} by {database_id} * 100 >= 90"
thresholds { thresholds {
warning = 70 warning = 70
@ -42,60 +42,58 @@ resource "datadog_monitor" "cloud_sql_disk_space" {
} }
resource "datadog_monitor" "cloud_sql_connection_80" { resource "datadog_monitor" "cloud_sql_connection_80" {
name = "Cloud SQL MySQL connection > 80% of max connections" name = "Cloud SQL MySQL connection > 80% of max connections"
message = "{{#is_alert}}\n${var.alert_HNO} \n{{/is_alert}} \n{{#is_recovery}}\n${var.alert_HNO}\n{{/is_recovery}}" message = "{{#is_alert}}\n${var.alert_HNO} \n{{/is_alert}} \n{{#is_recovery}}\n${var.alert_HNO}\n{{/is_recovery}}"
query = "avg(last_5m):avg:gcp.cloudsql.database.network.connections{*} > 3500" query = "avg(last_5m):avg:gcp.cloudsql.database.network.connections{*} > 3500"
type = "metric alert" type = "metric alert"
notify_no_data = false notify_no_data = false
renotify_interval = 60 renotify_interval = 60
notify_audit = false notify_audit = false
timeout_h = 0 timeout_h = 0
include_tags = true include_tags = true
locked = false locked = false
require_full_window = true require_full_window = true
new_host_delay = 300 new_host_delay = 300
notify_no_data = false notify_no_data = false
renotify_interval = 0 renotify_interval = 0
no_data_timeframe = 20 no_data_timeframe = 20
} }
resource "datadog_monitor" "cloud_sql_lag" { resource "datadog_monitor" "cloud_sql_lag" {
name = "Cloud SQL MySQL lag > 45min" name = "Cloud SQL MySQL lag > 45min"
message = "{{#is_alert}}\n${var.alert_HNO} \n{{/is_alert}} \n{{#is_recovery}}\n${var.alert_HNO}\n{{/is_recovery}}" message = "{{#is_alert}}\n${var.alert_HNO} \n{{/is_alert}} \n{{#is_recovery}}\n${var.alert_HNO}\n{{/is_recovery}}"
query = "min(last_10m):avg:gcp.cloudsql.database.mysql.replication.seconds_behind_master{*} by {database_id} > 2700" query = "min(last_10m):avg:gcp.cloudsql.database.mysql.replication.seconds_behind_master{*} by {database_id} > 2700"
type = "metric alert" type = "metric alert"
notify_no_data = false
renotify_interval = 60
notify_audit = false
timeout_h = 0
include_tags = true
locked = false
require_full_window = true
new_host_delay = 300
notify_no_data = false
renotify_interval = 0
no_data_timeframe = 20
notify_no_data = false
renotify_interval = 60
notify_audit = false
timeout_h = 0
include_tags = true
locked = false
require_full_window = true
new_host_delay = 300
notify_no_data = false
renotify_interval = 0
no_data_timeframe = 20
} }
resource "datadog_monitor" "cloud_sql_replication" { resource "datadog_monitor" "cloud_sql_replication" {
name = "Cloud SQL Failover not ready to replication" name = "Cloud SQL Failover not ready to replication"
message = "{{#is_alert}}\n${var.alert_HNO} \n{{/is_alert}} \n{{#is_recovery}}\n${var.alert_HNO}\n{{/is_recovery}}" message = "{{#is_alert}}\n${var.alert_HNO} \n{{/is_alert}} \n{{#is_recovery}}\n${var.alert_HNO}\n{{/is_recovery}}"
query = "max(last_5m):avg:gcp.cloudsql.database.mysql.replication.available_for_failover{*} <= 0" query = "max(last_5m):avg:gcp.cloudsql.database.mysql.replication.available_for_failover{*} <= 0"
type = "metric alert" type = "metric alert"
notify_no_data = false
renotify_interval = 60
notify_audit = false
timeout_h = 0
include_tags = true
locked = false
require_full_window = true
new_host_delay = 300
notify_no_data = false
renotify_interval = 0
no_data_timeframe = 20
notify_no_data = false
renotify_interval = 60
notify_audit = false
timeout_h = 0
include_tags = true
locked = false
require_full_window = true
new_host_delay = 300
notify_no_data = false
renotify_interval = 0
no_data_timeframe = 20
} }

View File

@ -1,8 +1,8 @@
resource "datadog_monitor" "datadog_gcp_lb_request_count" { resource "datadog_monitor" "datadog_gcp_lb_request_count" {
name = "GCP LoadBalancer request count changed too fast" name = "GCP LoadBalancer request count changed too fast"
message = "" message = ""
query = "change(sum(last_5m),last_30m):avg:gcp.loadbalancing.http.request_count{*} by {backend_name}.as_count() >= 300" query = "change(sum(last_5m),last_30m):avg:gcp.loadbalancing.http.request_count{*} by {backend_name}.as_count() >= 300"
type = "query alert" type = "query alert"
notify_no_data = false notify_no_data = false
renotify_interval = 60 renotify_interval = 60
@ -15,15 +15,13 @@ resource "datadog_monitor" "datadog_gcp_lb_request_count" {
notify_no_data = false notify_no_data = false
renotify_interval = 0 renotify_interval = 0
no_data_timeframe = 20 no_data_timeframe = 20
} }
resource "datadog_monitor" "datadog_gcp_lb_500" { resource "datadog_monitor" "datadog_gcp_lb_500" {
name = "GCP LoadBalancer 500 ratio > 5%" name = "GCP LoadBalancer 500 ratio > 5%"
message = "" message = ""
query = "sum(last_10m):avg:gcp.loadbalancing.http.request_count{response_code_class:500} by {backend_name}.as_count() / avg:gcp.loadbalancing.http.request_count{*} by {backend_name}.as_count() > 0.2" query = "sum(last_10m):avg:gcp.loadbalancing.http.request_count{response_code_class:500} by {backend_name}.as_count() / avg:gcp.loadbalancing.http.request_count{*} by {backend_name}.as_count() > 0.2"
type = "query alert" type = "query alert"
notify_no_data = false notify_no_data = false
renotify_interval = 60 renotify_interval = 60
@ -36,15 +34,13 @@ resource "datadog_monitor" "datadog_gcp_lb_500" {
notify_no_data = false notify_no_data = false
renotify_interval = 0 renotify_interval = 0
no_data_timeframe = 20 no_data_timeframe = 20
} }
resource "datadog_monitor" "datadog_gcp_lb_backend_latency" { resource "datadog_monitor" "datadog_gcp_lb_backend_latency" {
name = "GCP LB backend latency > 2s" name = "GCP LB backend latency > 2s"
message = "" message = ""
query = "min(last_5m):avg:gcp.loadbalancing.http.backend_latencies.avg{*} by {backend_name} > 2000" query = "min(last_5m):avg:gcp.loadbalancing.http.backend_latencies.avg{*} by {backend_name} > 2000"
type = "metric alert" type = "metric alert"
notify_no_data = false notify_no_data = false
renotify_interval = 60 renotify_interval = 60
@ -57,15 +53,13 @@ resource "datadog_monitor" "datadog_gcp_lb_backend_latency" {
notify_no_data = false notify_no_data = false
renotify_interval = 0 renotify_interval = 0
no_data_timeframe = 20 no_data_timeframe = 20
} }
resource "datadog_monitor" "datadog_gcp_lb_latency" { resource "datadog_monitor" "datadog_gcp_lb_latency" {
name = "GCP LB latency > 5s" name = "GCP LB latency > 5s"
message = "" message = ""
query = "avg(last_5m):avg:gcp.loadbalancing.http.total_latencies.avg{*} > 5000" query = "avg(last_5m):avg:gcp.loadbalancing.http.total_latencies.avg{*} > 5000"
type = "query alert" type = "query alert"
thresholds { thresholds {
warning = 3000 warning = 3000
@ -83,5 +77,4 @@ resource "datadog_monitor" "datadog_gcp_lb_latency" {
notify_no_data = false notify_no_data = false
renotify_interval = 0 renotify_interval = 0
no_data_timeframe = 20 no_data_timeframe = 20
} }

View File

@ -4,79 +4,90 @@ variable "ho_escalation_group" {}
variable env {} variable env {}
variable region {} variable region {}
##linux ##linux
variable "dd_linux_basics" { variable "dd_linux_basics" {
default = "disabled" default = "disabled"
} }
variable "linux_basics_config" { variable "linux_basics_config" {
type = "map" type = "map"
default = { default = {
notify_no_data = false notify_no_data = false
delay = 900 delay = 900
} }
} }
variable "dd_custom_cpu" { variable "dd_custom_cpu" {
type = "map" type = "map"
default = { default = {
status = "disabled" status = "disabled"
} }
} }
## RDS ## RDS
variable "dd_aws_rds" { variable "dd_aws_rds" {
default = "disabled" default = "disabled"
} }
variable "rds_config" { variable "rds_config" {
type = "map" type = "map"
default = { default = {
notify_no_data = false notify_no_data = false
delay = 900 delay = 900
}
}
variable "rds_cpu_threshold" {
type = "map"
default = {
warning = 80
critical = 90
}
}
variable "rds_mem_threshold" {
default = {
warning = 20
critical = 10
} }
} }
variable "rds_cpu_threshold" {
type = "map"
default = {
warning = 80
critical = 90
}
}
variable "rds_mem_threshold" {
default = {
warning = 20
critical = 10
}
}
## ELB ## ELB
variable "dd_aws_elb" { variable "dd_aws_elb" {
default = "disable" default = "disable"
} }
variable "elb_config" { variable "elb_config" {
type = "map" type = "map"
default = { default = {
notify_no_data = false notify_no_data = false
delay = 900 delay = 900
} }
} }
variable "elb_5xx_threshold" { variable "elb_5xx_threshold" {
default = { default = {
warning = 5 warning = 5
critical = 10 critical = 10
} }
} }
variable "elb_4xx_threshold" { variable "elb_4xx_threshold" {
default = { default = {
warning = 5 warning = 5
critical = 10 critical = 10
} }
} }
variable "elb_backend_latency" { variable "elb_backend_latency" {
default = { default = {
warning = 1000 warning = 1000
critical = 5000 critical = 5000
} }
} }
@ -84,6 +95,7 @@ variable "elb_backend_latency" {
variable "dd_nginx" { variable "dd_nginx" {
default = "disabled" default = "disabled"
} }
variable "dd_php_fpm" { variable "dd_php_fpm" {
default = "disabled" default = "disabled"
} }
@ -91,17 +103,21 @@ variable "dd_php_fpm" {
variable "dd_apache" { variable "dd_apache" {
default = "disabled" default = "disabled"
} }
variable "apache_nginx_fpm_config" { variable "apache_nginx_fpm_config" {
type = "map" type = "map"
default = { default = {
notify_no_data = false notify_no_data = false
delay = 900 delay = 900
} }
} }
variable "php_fpm_busy_threshold" { variable "php_fpm_busy_threshold" {
type = "map" type = "map"
default = { default = {
warning = 0.8 warning = 0.8
critical = 0.9 critical = 0.9
} }
} }

View File

@ -2,14 +2,13 @@ resource "datadog_monitor" "Apache_process" {
name = "[${var.env}] Nginx process is down on {{host.name}}" name = "[${var.env}] Nginx process is down on {{host.name}}"
message = "{{#is_alert}}\n${var.hno_escalation_group} \n{{/is_alert}} \n{{#is_recovery}}\n${var.hno_escalation_group}\n{{/is_recovery}}\n{{#is_warning}}\n${var.ho_escalation_group} \n{{/is_warning}} \n{{#is_warning_recovery}}\n${var.ho_escalation_group}\n{{/is_warning_recovery}}" message = "{{#is_alert}}\n${var.hno_escalation_group} \n{{/is_alert}} \n{{#is_recovery}}\n${var.hno_escalation_group}\n{{/is_recovery}}\n{{#is_warning}}\n${var.ho_escalation_group} \n{{/is_warning}} \n{{#is_warning_recovery}}\n${var.ho_escalation_group}\n{{/is_warning_recovery}}"
type = "service check" type = "service check"
query = "\"process.up\".over(\"dd_monitoring:enabled\",\"dd_apache:enabled\",\"process:apache\",\"env:${var.env}\").by(\"host\",\"process\", \"app\").last(4).count_by_status()" query = "\"process.up\".over(\"dd_monitoring:enabled\",\"dd_apache:enabled\",\"process:apache\",\"env:${var.env}\").by(\"host\",\"process\", \"app\").last(4).count_by_status()"
count = "${var.dd_apache == "enabled" ? 1 : 0 }" count = "${var.dd_apache == "enabled" ? 1 : 0 }"
thresholds = { thresholds = {
ok = 1 ok = 1
warning = 2 warning = 2
critical = 4 critical = 4
} }

View File

@ -2,14 +2,13 @@ resource "datadog_monitor" "Nginx_process" {
name = "[${var.env}] Nginx process is down on {{host.name}}" name = "[${var.env}] Nginx process is down on {{host.name}}"
message = "{{#is_alert}}\n${var.hno_escalation_group} \n{{/is_alert}} \n{{#is_recovery}}\n${var.hno_escalation_group}\n{{/is_recovery}}\n{{#is_warning}}\n${var.ho_escalation_group} \n{{/is_warning}} \n{{#is_warning_recovery}}\n${var.ho_escalation_group}\n{{/is_warning_recovery}}" message = "{{#is_alert}}\n${var.hno_escalation_group} \n{{/is_alert}} \n{{#is_recovery}}\n${var.hno_escalation_group}\n{{/is_recovery}}\n{{#is_warning}}\n${var.ho_escalation_group} \n{{/is_warning}} \n{{#is_warning_recovery}}\n${var.ho_escalation_group}\n{{/is_warning_recovery}}"
type = "service check" type = "service check"
query = "\"process.up\".over(\"dd_monitoring:enabled\",\"dd_nginx:enabled\",\"process:nginx\",\"env:${var.env}\").by(\"host\",\"process\", \"app\").last(4).count_by_status()" query = "\"process.up\".over(\"dd_monitoring:enabled\",\"dd_nginx:enabled\",\"process:nginx\",\"env:${var.env}\").by(\"host\",\"process\", \"app\").last(4).count_by_status()"
count = "${var.dd_nginx == "enabled" ? 1 : 0 }" count = "${var.dd_nginx == "enabled" ? 1 : 0 }"
thresholds = { thresholds = {
ok = 1 ok = 1
warning = 2 warning = 2
critical = 4 critical = 4
} }

View File

@ -2,7 +2,6 @@ resource "datadog_monitor" "php-fpm_process_idle" {
name = "[${var.env}] php_fpm busy worker > 90% on {{host.name}}" name = "[${var.env}] php_fpm busy worker > 90% on {{host.name}}"
message = "{{#is_alert}}\n${var.hno_escalation_group} \n{{/is_alert}} \n{{#is_recovery}}\n${var.hno_escalation_group}\n{{/is_recovery}}\n{{#is_warning}}\n${var.ho_escalation_group} \n{{/is_warning}} \n{{#is_warning_recovery}}\n${var.ho_escalation_group}\n{{/is_warning_recovery}}" message = "{{#is_alert}}\n${var.hno_escalation_group} \n{{/is_alert}} \n{{#is_recovery}}\n${var.hno_escalation_group}\n{{/is_recovery}}\n{{#is_warning}}\n${var.ho_escalation_group} \n{{/is_warning}} \n{{#is_warning_recovery}}\n${var.ho_escalation_group}\n{{/is_warning_recovery}}"
type = "query alert" type = "query alert"
query = "avg(last_10m):avg:php_fpm.processes.active{dd_monitoring:enabled,dd_php_fpm:enabled,env:${var.env}} by {host,region,app} / ( avg:php_fpm.processes.idle{dd_monitoring:enabled,dd_php_fpm:enabled,env:${var.env}} by {host,region,app} + avg:php_fpm.processes.active{dd_monitoring:enabled,dd_php_fpm:enabled,env:${var.env}} by {host,region,stack} ) > 0.90" query = "avg(last_10m):avg:php_fpm.processes.active{dd_monitoring:enabled,dd_php_fpm:enabled,env:${var.env}} by {host,region,app} / ( avg:php_fpm.processes.idle{dd_monitoring:enabled,dd_php_fpm:enabled,env:${var.env}} by {host,region,app} + avg:php_fpm.processes.active{dd_monitoring:enabled,dd_php_fpm:enabled,env:${var.env}} by {host,region,stack} ) > 0.90"
count = "${var.dd_php_fpm == "enabled" ? 1 : 0 }" count = "${var.dd_php_fpm == "enabled" ? 1 : 0 }"
@ -25,19 +24,17 @@ resource "datadog_monitor" "php-fpm_process_idle" {
no_data_timeframe = 20 no_data_timeframe = 20
} }
resource "datadog_monitor" "FPM_process" { resource "datadog_monitor" "FPM_process" {
name = "[${var.env}] FPM process is down on {{host.name}}" name = "[${var.env}] FPM process is down on {{host.name}}"
message = "{{#is_alert}}\n${var.hno_escalation_group} \n{{/is_alert}} \n{{#is_recovery}}\n${var.hno_escalation_group}\n{{/is_recovery}}\n{{#is_warning}}\n${var.ho_escalation_group} \n{{/is_warning}} \n{{#is_warning_recovery}}\n${var.ho_escalation_group}\n{{/is_warning_recovery}}" message = "{{#is_alert}}\n${var.hno_escalation_group} \n{{/is_alert}} \n{{#is_recovery}}\n${var.hno_escalation_group}\n{{/is_recovery}}\n{{#is_warning}}\n${var.ho_escalation_group} \n{{/is_warning}} \n{{#is_warning_recovery}}\n${var.ho_escalation_group}\n{{/is_warning_recovery}}"
type = "service check" type = "service check"
query = "\"process.up\".over(\"dd_monitoring:enabled\",\"dd_php_fpm:enabled\",\"process:php_fpm\",\"env:${var.env}\").by(\"host\",\"process\", \"app\").last(4).count_by_status()" query = "\"process.up\".over(\"dd_monitoring:enabled\",\"dd_php_fpm:enabled\",\"process:php_fpm\",\"env:${var.env}\").by(\"host\",\"process\", \"app\").last(4).count_by_status()"
count = "${var.dd_nginx == "enabled" ? 1 : 0 }" count = "${var.dd_nginx == "enabled" ? 1 : 0 }"
thresholds = { thresholds = {
ok = 1 ok = 1
warning = 2 warning = 2
critical = 4 critical = 4
} }

View File

@ -22,4 +22,3 @@ resource "datadog_monitor" "cpu_custom" {
require_full_window = true require_full_window = true
no_data_timeframe = 20 no_data_timeframe = 20
} }

View File

@ -24,7 +24,7 @@ resource "datadog_monitor" "cpu_95_5min" {
query = "min(last_5m):avg:system.cpu.system{dd_monitoring:enabled,dd_linux_basics:enabled,env:${var.env},!dd_custom_cpu:enabled} by {host,region,stack} + avg:system.cpu.user{dd_monitoring:enabled,dd_linux_basics:enabled,!dd_custom_cpu:enabled} by {host,region,stack} > 95" query = "min(last_5m):avg:system.cpu.system{dd_monitoring:enabled,dd_linux_basics:enabled,env:${var.env},!dd_custom_cpu:enabled} by {host,region,stack} + avg:system.cpu.user{dd_monitoring:enabled,dd_linux_basics:enabled,!dd_custom_cpu:enabled} by {host,region,stack} > 95"
type = "query alert" type = "query alert"
count = "${var.dd_linux_basics == "enabled" ? 1 : 0}" count = "${var.dd_linux_basics == "enabled" ? 1 : 0}"
notify_no_data = "${var.linux_basics_config["notify_no_data"]}" notify_no_data = "${var.linux_basics_config["notify_no_data"]}"
evaluation_delay = "${var.linux_basics_config["delay"]}" evaluation_delay = "${var.linux_basics_config["delay"]}"
@ -39,12 +39,12 @@ resource "datadog_monitor" "cpu_95_5min" {
} }
resource "datadog_monitor" "datadog_free_disk_space_5" { resource "datadog_monitor" "datadog_free_disk_space_5" {
name = "[${var.env}] Free disk space < 5% on {{host.name}}" name = "[${var.env}] Free disk space < 5% on {{host.name}}"
message = "{{#is_alert}}\n${var.hno_escalation_group}\n{{/is_alert}}\n{{#is_recovery}}\n${var.hno_escalation_group}\n{{/is_recovery}}" message = "{{#is_alert}}\n${var.hno_escalation_group}\n{{/is_alert}}\n{{#is_recovery}}\n${var.hno_escalation_group}\n{{/is_recovery}}"
query = "sum(last_5m):avg:system.disk.free{dd_monitoring:enabled,dd_linux_basics:enabled,env:${var.env},!dd_custom_cpu:enabled} by {host,device,region,stack} / avg:system.disk.total{dd_monitoring:enabled,dd_linux_basics:enabled,!dd_custom_cpu:enabled} by {host,device,region,stack} * 100 < 5" query = "sum(last_5m):avg:system.disk.free{dd_monitoring:enabled,dd_linux_basics:enabled,env:${var.env},!dd_custom_cpu:enabled} by {host,device,region,stack} / avg:system.disk.total{dd_monitoring:enabled,dd_linux_basics:enabled,!dd_custom_cpu:enabled} by {host,device,region,stack} * 100 < 5"
type = "query alert" type = "query alert"
count = "${var.dd_linux_basics == "enabled" ? 1 : 0}" count = "${var.dd_linux_basics == "enabled" ? 1 : 0}"
notify_no_data = "${var.linux_basics_config["notify_no_data"]}" notify_no_data = "${var.linux_basics_config["notify_no_data"]}"
evaluation_delay = "${var.linux_basics_config["delay"]}" evaluation_delay = "${var.linux_basics_config["delay"]}"
@ -136,22 +136,20 @@ resource "datadog_monitor" "datadog_free_disk_space_inodes_10" {
# type = "query alert" # type = "query alert"
# count = "${var.dd_linux_basics == "enabled" ? 1 : 0}" # count = "${var.dd_linux_basics == "enabled" ? 1 : 0}"
# notify_no_data = "${var.linux_basics_config["notify_no_data"]}"
# notify_no_data = "${var.linux_basics_config["notify_no_data"]}" # evaluation_delay = "${var.linux_basics_config["delay"]}"
# evaluation_delay = "${var.linux_basics_config["delay"]}" # new_host_delay = "${var.linux_basics_config["delay"]}"
# new_host_delay = "${var.linux_basics_config["delay"]}" # renotify_interval = 60
# renotify_interval = 60 # notify_audit = false
# notify_audit = false # timeout_h = 0
# timeout_h = 0 # include_tags = true
# include_tags = true # locked = false
# locked = false # require_full_window = true
# require_full_window = true # no_data_timeframe = 20
# no_data_timeframe = 20
# } # }
resource "datadog_monitor" "datadog_free_memory" { resource "datadog_monitor" "datadog_free_memory" {
name = "[${var.env}] Free memory < 5% on {{host.name}}" name = "[${var.env}] Free memory < 5% on {{host.name}}"
message = "Debugging alert - no escalation" message = "Debugging alert - no escalation"
query = "sum(last_1m):avg:system.mem.free{dd_monitoring:enabled,dd_linux_basics:enabled,env:${var.env},!dd_custom_memory:enabled} by {host,region,stack} / avg:system.mem.total{dd_monitoring:enabled,dd_linux_basics:enabled,env:${var.env},!dd_custom_memory:enabled} by {host,region,stack} * 100 < 5" query = "sum(last_1m):avg:system.mem.free{dd_monitoring:enabled,dd_linux_basics:enabled,env:${var.env},!dd_custom_memory:enabled} by {host,region,stack} / avg:system.mem.total{dd_monitoring:enabled,dd_linux_basics:enabled,env:${var.env},!dd_custom_memory:enabled} by {host,region,stack} * 100 < 5"
@ -174,18 +172,21 @@ resource "datadog_monitor" "datadog_free_memory" {
# name = "Host unreachable" # name = "Host unreachable"
# message = "{{#is_alert}}\n${var.hno_escalation_group} \n{{/is_alert}} \n{{#is_recovery}}\n${var.hno_escalation_group} \n{{/is_recovery}}" # message = "{{#is_alert}}\n${var.hno_escalation_group} \n{{/is_alert}} \n{{#is_recovery}}\n${var.hno_escalation_group} \n{{/is_recovery}}"
# query = "datadog.agent.up.over(dd_monitoring:enabled,dd_linux_basics:enabled,env:${var.env},!dd_custom_cpu:enabled).last(1).count_by_status()" # query = "datadog.agent.up.over(dd_monitoring:enabled,dd_linux_basics:enabled,env:${var.env},!dd_custom_cpu:enabled).last(1).count_by_status()"
# type = "service check" # type = "service check"
# count = "${var.dd_linux_basics == "enabled" ? 1 : 0}" # count = "${var.dd_linux_basics == "enabled" ? 1 : 0}"
# notify_no_data = "${var.linux_basics_config["notify_no_data"]}"
# evaluation_delay = "${var.linux_basics_config["delay"]}" # notify_no_data = "${var.linux_basics_config["notify_no_data"]}"
# new_host_delay = "${var.linux_basics_config["delay"]}" # evaluation_delay = "${var.linux_basics_config["delay"]}"
# renotify_interval = 60 # new_host_delay = "${var.linux_basics_config["delay"]}"
# notify_audit = false # renotify_interval = 60
# timeout_h = 0 # notify_audit = false
# include_tags = true # timeout_h = 0
# locked = false # include_tags = true
# require_full_window = true # locked = false
# no_data_timeframe = 20 # require_full_window = true
# no_data_timeframe = 20
# } # }

View File

@ -1,3 +1 @@
resource "null_resource" "test-migration" {} resource "null_resource" "test-migration" {}

View File

@ -5,6 +5,7 @@ variable region {}
variable "critical_escalation_group" { variable "critical_escalation_group" {
default = "@pagerduty_HODummy" default = "@pagerduty_HODummy"
} }
variable "warning_escalation_group" { variable "warning_escalation_group" {
default = "@pagerduty_HNODummy" default = "@pagerduty_HNODummy"
} }
@ -19,4 +20,3 @@ variable "dd_linux_basics" {
variable "dd_aws_rds" { variable "dd_aws_rds" {
default = "enabled" default = "enabled"
} }

View File

@ -1,14 +1,12 @@
module "datadog-monitors" { module "datadog-monitors" {
source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git" source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git"
env = "${var.environment}" env = "${var.environment}"
region = "${var.region}" region = "${var.region}"
critical_escalation_group = "${var.critical_escalation_group}" critical_escalation_group = "${var.critical_escalation_group}"
warning_escalation_group = "${var.warning_escalation_group}" warning_escalation_group = "${var.warning_escalation_group}"
dd_aws_rds = "${var.dd_aws_rds}"
dd_aws_rds = "${var.dd_aws_rds}" dd_linux_basics = "${var.dd_linux_basics}"
dd_linux_basics = "${var.dd_linux_basics}"
} }