diff --git a/middleware/nginx/README.md b/middleware/nginx/README.md index 6b59e94..2ab227d 100644 --- a/middleware/nginx/README.md +++ b/middleware/nginx/README.md @@ -16,6 +16,7 @@ module "datadog-monitors-middleware-nginx" { Creates DataDog monitors with the following checks: +- Nginx dropped connections - Nginx vhost status does not respond ## 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 | 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 | ## 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/inputs.tf b/middleware/nginx/inputs.tf index a8680d6..30345ad 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 = "Nginx dropped connections critical threshold" + default = 0 +} diff --git a/middleware/nginx/monitors-nginx.tf b/middleware/nginx/monitors-nginx.tf index 8776db7..ade45f1 100644 --- a/middleware/nginx/monitors-nginx.tf +++ b/middleware/nginx/monitors-nginx.tf @@ -27,3 +27,29 @@ 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 { + 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}"] +} diff --git a/middleware/nginx/outputs.tf b/middleware/nginx/outputs.tf index f533cec..970174c 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}" +}