MON-96 - Update middleware monitors with EOF best practice

This commit is contained in:
Alexandre Gaillet 2018-03-23 14:53:39 +01:00
parent 999019339c
commit 84f4e8d5ba
8 changed files with 62 additions and 13 deletions

View File

@ -24,8 +24,10 @@ Inputs
| Name | Description | Type | Default | Required | | Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:| |------|-------------|:----:|:-----:|:-----:|
| apache_process_message | Custom message for Apache process monitor | string | `` | no | | apache_connect_message | Custom message for Apache process monitor | string | `` | no |
| apache_process_silenced | Groups to mute for Apache process monitor | map | `<map>` | no | | apache_connect_silenced | Groups to mute for Apache process monitor | map | `<map>` | no |
| environment | Architecture Environment | string | - | yes | | environment | Architecture Environment | string | - | 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_use_defaults | Use default filter tags convention | string | `true` | no |
| message | Message sent when an alert is triggered | string | - | yes | | message | Message sent when an alert is triggered | string | - | yes |

View File

@ -14,6 +14,16 @@ variable "message" {
description = "Message sent when an alert is triggered" description = "Message sent when an alert is triggered"
} }
variable "filter_tags_use_defaults" {
description = "Use default filter tags convention"
default = "true"
}
variable "filter_tags_custom" {
description = "Tags used for custom filtering when filter_tags_use_defaults is false"
default = "*"
}
# Apache Middleware specific # Apache Middleware specific
variable "apache_connect_silenced" { variable "apache_connect_silenced" {

View File

@ -1,9 +1,20 @@
data "template_file" "filter" {
template = "$${filter}"
vars {
filter = "${var.filter_tags_use_defaults == "true" ? format("dd_monitoring:enabled,dd_apache:enabled,env:%s", var.environment) : "${var.filter_tags_custom}"}"
}
}
resource "datadog_monitor" "datadog_apache_process" { resource "datadog_monitor" "datadog_apache_process" {
name = "[${var.environment}] Can't connect to apache vhost status" name = "[${var.environment}] Can't connect to apache vhost status"
message = "${coalesce(var.apache_connect_message, var.message)}" message = "${coalesce(var.apache_connect_message, var.message)}"
type = "service check" type = "service check"
query = "\"apache.can_connect\".over(\"dd_monitoring:enabled\",\"dd_apache:enabled\",\"env:${var.environment}\").by(\"host\",\"port\").last(6).count_by_status()"
query = <<EOF
"apache.can_connect".over(${data.template_file.filter.rendered}).by("host","port").last(6).count_by_status()
EOF
thresholds = { thresholds = {
ok = 1 ok = 1

View File

@ -26,6 +26,8 @@ Inputs
|------|-------------|:----:|:-----:|:-----:| |------|-------------|:----:|:-----:|:-----:|
| environment | Architecture Environment | string | - | yes | | environment | Architecture Environment | string | - | 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_use_defaults | Use default filter tags convention | string | `true` | no |
| message | Message sent when an alert is triggered | string | - | yes | | message | Message sent when an alert is triggered | string | - | yes |
| nginx_process_message | Custom message for Nginx process monitor | string | `` | no | | nginx_connect_message | Custom message for Nginx process monitor | string | `` | no |
| nginx_process_silenced | Groups to mute for Nginx process monitor | map | `<map>` | no | | nginx_connect_silenced | Groups to mute for Nginx process monitor | map | `<map>` | no |

View File

@ -14,6 +14,16 @@ variable "message" {
description = "Message sent when an alert is triggered" description = "Message sent when an alert is triggered"
} }
variable "filter_tags_use_defaults" {
description = "Use default filter tags convention"
default = "true"
}
variable "filter_tags_custom" {
description = "Tags used for custom filtering when filter_tags_use_defaults is false"
default = "*"
}
# Nginx Middleware specific # Nginx Middleware specific
variable "nginx_connect_silenced" { variable "nginx_connect_silenced" {

View File

@ -1,9 +1,20 @@
data "template_file" "filter" {
template = "$${filter}"
vars {
filter = "${var.filter_tags_use_defaults == "true" ? format("dd_monitoring:enabled,dd_nginx:enabled,env:%s", var.environment) : "${var.filter_tags_custom}"}"
}
}
resource "datadog_monitor" "datadog_nginx_process" { resource "datadog_monitor" "datadog_nginx_process" {
name = "[${var.environment}] Can't connect to nginx vhost status" name = "[${var.environment}] Can't connect to nginx vhost status"
message = "${coalesce(var.nginx_connect_message, var.message)}" message = "${coalesce(var.nginx_connect_message, var.message)}"
type = "service check" type = "service check"
query = "\"nginx.can_connect\".over(\"dd_monitoring:enabled\",\"dd_nginx:enabled\",\"env:${var.environment}\").by(\"host\",\"port\").last(6).count_by_status()"
query = <<EOF
"nginx.can_connect".over(${data.template_file.filter.rendered}).by("host","port").last(6).count_by_status()
EOF
thresholds = { thresholds = {
ok = 1 ok = 1

View File

@ -35,5 +35,5 @@ Inputs
| php_fpm_busy_silenced | Groups to mute for PHP FPM busy worker monitor | map | `<map>` | no | | php_fpm_busy_silenced | Groups to mute for PHP FPM busy worker monitor | map | `<map>` | no |
| php_fpm_busy_threshold_critical | php fpm busy critical threshold | string | `0.9` | no | | php_fpm_busy_threshold_critical | php fpm busy critical threshold | string | `0.9` | no |
| php_fpm_busy_threshold_warning | php fpm busy warning threshold | string | `0.8` | no | | php_fpm_busy_threshold_warning | php fpm busy warning threshold | string | `0.8` | no |
| php_fpm_process_message | Custom message for PHP FPM process monitor | string | `` | no | | php_fpm_connect_message | Custom message for PHP FPM process monitor | string | `` | no |
| php_fpm_process_silenced | Groups to mute for PHP FPM process monitor | map | `<map>` | no | | php_fpm_connect_silenced | Groups to mute for PHP FPM process monitor | map | `<map>` | no |

View File

@ -45,7 +45,10 @@ resource "datadog_monitor" "datadog_fpm_process" {
message = "${coalesce(var.php_fpm_connect_message, var.message)}" message = "${coalesce(var.php_fpm_connect_message, var.message)}"
type = "service check" type = "service check"
query = "\"php_fpm.can_ping\".over(\"dd_monitoring:enabled\",\"dd_php_fpm:enabled\",\"env:${var.environment}\").by(\"host\",\"port\").last(6).count_by_status()"
query = <<EOF
"php_fpm.can_ping".over(${data.template_file.filter.rendered}).by("host","port").last(6).count_by_status()
EOF
thresholds = { thresholds = {
ok = 1 ok = 1