From 3984d31a8795f59107a5d1b1475034b7fa0d1e81 Mon Sep 17 00:00:00 2001 From: Quentin Manfroi Date: Tue, 21 Aug 2018 12:04:27 +0200 Subject: [PATCH 1/5] MON-289 add dropped connections monitor --- middleware/nginx/inputs.tf | 35 ++++++++++++++++++++++++++++++ middleware/nginx/monitors-nginx.tf | 29 +++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/middleware/nginx/inputs.tf b/middleware/nginx/inputs.tf index a8680d6..9605d89 100644 --- a/middleware/nginx/inputs.tf +++ b/middleware/nginx/inputs.tf @@ -60,3 +60,38 @@ variable "nginx_connect_threshold_critical" { type = "string" default = "1.1754943508222875e-38" } + +variable "nginx_dropped_silenced" { + description = "Groups to mute for Nginx dropped connections monitor" + type = "map" + default = {} +} + +variable "nginx_dropped_extra_tags" { + description = "Extra tags for Nginx dropped connections monitor" + type = "list" + default = [] +} + +variable "nginx_dropped_message" { + description = "Custom message for Nginx dropped connections monitor" + type = "string" + default = "" +} + +variable "nginx_dropped_time_aggregator" { + description = "Monitor aggregator for Nginx dropped connections [available values: min, max or avg]" + type = "string" + default = "min" +} + +variable "nginx_dropped_timeframe" { + description = "Monitor timeframe for Nginx dropped connections [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 "nginx_dropped_threshold_critical" { + description = "php fpm busy critical threshold" + default = 0 +} diff --git a/middleware/nginx/monitors-nginx.tf b/middleware/nginx/monitors-nginx.tf index 8776db7..747590b 100644 --- a/middleware/nginx/monitors-nginx.tf +++ b/middleware/nginx/monitors-nginx.tf @@ -27,3 +27,32 @@ resource "datadog_monitor" "datadog_nginx_process" { tags = ["env:${var.environment}", "type:middleware", "provider:nginx", "resource:nginx", "team:claranet", "created-by:terraform", "${var.nginx_connect_extra_tags}"] } + +resource "datadog_monitor" "datadog_nginx_dropped_connections" { + name = "[${var.environment}] Nginx dropped connections {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}" + message = "${coalesce(var.nginx_dropped_message, var.message)}" + + type = "metric alert" + + query = "${var.nginx_dropped_time_aggregator}(${var.nginx_dropped_timeframe}):avg:nginx.net.conn_dropped_per_s${module.filter-tags.query_alert} by {host} > ${var.nginx_dropped_threshold_critical}" + + thresholds { + warning = "${var.nginx_dropped_threshold_warning}" + critical = "${var.nginx_dropped_threshold_critical}" + } + + notify_no_data = false + evaluation_delay = "${var.evaluation_delay}" + new_host_delay = "${var.new_host_delay}" + notify_audit = false + timeout_h = 0 + include_tags = true + locked = false + require_full_window = true + + silenced = "${var.nginx_dropped_silenced}" + + tags = ["env:${var.environment}", "type:middleware", "provider:nginx", "resource:nginx", "team:claranet", "created-by:terraform", "${var.nginx_dropped_extra_tags}"] +} + + From 666e87a70fa933f9e8e944a2f21abc338b5bcc04 Mon Sep 17 00:00:00 2001 From: Quentin Manfroi Date: Tue, 21 Aug 2018 12:07:17 +0200 Subject: [PATCH 2/5] MON-289 auto update --- middleware/nginx/README.md | 8 ++++++++ middleware/nginx/monitors-nginx.tf | 2 -- middleware/nginx/outputs.tf | 5 +++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/middleware/nginx/README.md b/middleware/nginx/README.md index 6b59e94..f4ff998 100644 --- a/middleware/nginx/README.md +++ b/middleware/nginx/README.md @@ -17,6 +17,7 @@ module "datadog-monitors-middleware-nginx" { Creates DataDog monitors with the following checks: - Nginx vhost status does not respond +- Nginx dropped connections ## Inputs @@ -33,11 +34,18 @@ Creates DataDog monitors with the following checks: | nginx_connect_message | Custom message for Nginx status monitor | string | `` | no | | nginx_connect_silenced | Groups to mute for Nginx status monitor | map | `` | no | | nginx_connect_threshold_critical | Nginx status monitor (critical threshold) | string | `1.1754943508222875e-38` | no | +| nginx_dropped_extra_tags | Extra tags for Nginx dropped connections monitor | list | `` | no | +| nginx_dropped_message | Custom message for Nginx dropped connections monitor | string | `` | no | +| nginx_dropped_silenced | Groups to mute for Nginx dropped connections monitor | map | `` | no | +| nginx_dropped_threshold_critical | php fpm busy critical threshold | string | `0` | no | +| nginx_dropped_time_aggregator | Monitor aggregator for Nginx dropped connections [available values: min, max or avg] | string | `min` | no | +| nginx_dropped_timeframe | Monitor timeframe for Nginx dropped connections [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_5m` | no | ## Outputs | Name | Description | |------|-------------| +| datadog_nginx_dropped_connections_id | id for monitor datadog_nginx_dropped_connections | | datadog_nginx_process_id | id for monitor datadog_nginx_process | ## Related documentation diff --git a/middleware/nginx/monitors-nginx.tf b/middleware/nginx/monitors-nginx.tf index 747590b..6868b38 100644 --- a/middleware/nginx/monitors-nginx.tf +++ b/middleware/nginx/monitors-nginx.tf @@ -54,5 +54,3 @@ resource "datadog_monitor" "datadog_nginx_dropped_connections" { tags = ["env:${var.environment}", "type:middleware", "provider:nginx", "resource:nginx", "team:claranet", "created-by:terraform", "${var.nginx_dropped_extra_tags}"] } - - diff --git a/middleware/nginx/outputs.tf b/middleware/nginx/outputs.tf index f533cec..ec41806 100644 --- a/middleware/nginx/outputs.tf +++ b/middleware/nginx/outputs.tf @@ -2,3 +2,8 @@ output "datadog_nginx_process_id" { description = "id for monitor datadog_nginx_process" value = "${datadog_monitor.datadog_nginx_process.*.id}" } + +output "datadog_nginx_dropped_connections_id" { + description = "id for monitor datadog_nginx_dropped_connections" + value = "${datadog_monitor.datadog_nginx_dropped_connections.id}" +} From ef8b68d664735995943b57ec9a8597370f89f588 Mon Sep 17 00:00:00 2001 From: Quentin Manfroi Date: Tue, 21 Aug 2018 12:08:27 +0200 Subject: [PATCH 3/5] MON-289 remove warning threshold for droppred connections --- middleware/nginx/monitors-nginx.tf | 1 - 1 file changed, 1 deletion(-) diff --git a/middleware/nginx/monitors-nginx.tf b/middleware/nginx/monitors-nginx.tf index 6868b38..ade45f1 100644 --- a/middleware/nginx/monitors-nginx.tf +++ b/middleware/nginx/monitors-nginx.tf @@ -37,7 +37,6 @@ resource "datadog_monitor" "datadog_nginx_dropped_connections" { query = "${var.nginx_dropped_time_aggregator}(${var.nginx_dropped_timeframe}):avg:nginx.net.conn_dropped_per_s${module.filter-tags.query_alert} by {host} > ${var.nginx_dropped_threshold_critical}" thresholds { - warning = "${var.nginx_dropped_threshold_warning}" critical = "${var.nginx_dropped_threshold_critical}" } From 23cdf9059c6b87f917a36b164ccce63824cd4088 Mon Sep 17 00:00:00 2001 From: Quentin Manfroi Date: Tue, 21 Aug 2018 17:24:36 +0200 Subject: [PATCH 4/5] MON-289 fix threshold variable description --- middleware/nginx/README.md | 2 +- middleware/nginx/inputs.tf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/middleware/nginx/README.md b/middleware/nginx/README.md index f4ff998..a59e3d4 100644 --- a/middleware/nginx/README.md +++ b/middleware/nginx/README.md @@ -37,7 +37,7 @@ Creates DataDog monitors with the following checks: | nginx_dropped_extra_tags | Extra tags for Nginx dropped connections monitor | list | `` | no | | nginx_dropped_message | Custom message for Nginx dropped connections monitor | string | `` | no | | nginx_dropped_silenced | Groups to mute for Nginx dropped connections monitor | map | `` | no | -| nginx_dropped_threshold_critical | php fpm busy critical threshold | string | `0` | no | +| nginx_dropped_threshold_critical | Nginx dropped connections critical threshold | string | `0` | no | | nginx_dropped_time_aggregator | Monitor aggregator for Nginx dropped connections [available values: min, max or avg] | string | `min` | no | | nginx_dropped_timeframe | Monitor timeframe for Nginx dropped connections [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_5m` | no | diff --git a/middleware/nginx/inputs.tf b/middleware/nginx/inputs.tf index 9605d89..30345ad 100644 --- a/middleware/nginx/inputs.tf +++ b/middleware/nginx/inputs.tf @@ -92,6 +92,6 @@ variable "nginx_dropped_timeframe" { } variable "nginx_dropped_threshold_critical" { - description = "php fpm busy critical threshold" + description = "Nginx dropped connections critical threshold" default = 0 } From d5ef54845198d6939b06a2f65775723261637494 Mon Sep 17 00:00:00 2001 From: Quentin Manfroi Date: Thu, 30 Aug 2018 16:14:00 +0200 Subject: [PATCH 5/5] MON-289 auto update --- middleware/nginx/README.md | 2 +- middleware/nginx/outputs.tf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/middleware/nginx/README.md b/middleware/nginx/README.md index a59e3d4..2ab227d 100644 --- a/middleware/nginx/README.md +++ b/middleware/nginx/README.md @@ -16,8 +16,8 @@ module "datadog-monitors-middleware-nginx" { Creates DataDog monitors with the following checks: -- Nginx vhost status does not respond - Nginx dropped connections +- Nginx vhost status does not respond ## Inputs diff --git a/middleware/nginx/outputs.tf b/middleware/nginx/outputs.tf index ec41806..970174c 100644 --- a/middleware/nginx/outputs.tf +++ b/middleware/nginx/outputs.tf @@ -5,5 +5,5 @@ output "datadog_nginx_process_id" { output "datadog_nginx_dropped_connections_id" { description = "id for monitor datadog_nginx_dropped_connections" - value = "${datadog_monitor.datadog_nginx_dropped_connections.id}" + value = "${datadog_monitor.datadog_nginx_dropped_connections.*.id}" }