From 396098da4067762db9de50464c1809d945fbdd51 Mon Sep 17 00:00:00 2001 From: J-Mx Date: Thu, 29 Aug 2024 10:47:40 +0200 Subject: [PATCH] Update Azure DB PG Monitor to include Flexible IO monitoring (#56) --- cloud/azure/postgresql/README.md | 4 ++-- cloud/azure/postgresql/inputs.tf | 4 ++-- cloud/azure/postgresql/locals.tf | 3 ++- cloud/azure/postgresql/monitors-postgresql.tf | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cloud/azure/postgresql/README.md b/cloud/azure/postgresql/README.md index 3ce69373..f0679f25 100644 --- a/cloud/azure/postgresql/README.md +++ b/cloud/azure/postgresql/README.md @@ -75,8 +75,8 @@ Creates DataDog monitors with the following checks: | [free\_storage\_threshold\_warning](#input\_free\_storage\_threshold\_warning) | PostgreSQL Free Storage remaining in percent (warning threshold) | `string` | `"20"` | no | | [free\_storage\_time\_aggregator](#input\_free\_storage\_time\_aggregator) | Monitor aggregator for PostgreSQL Free Storage [available values: min, max or avg] | `string` | `"min"` | no | | [free\_storage\_timeframe](#input\_free\_storage\_timeframe) | Monitor timeframe for PostgreSQL Free Storage [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | `string` | `"last_15m"` | no | -| [io\_consumption\_enabled](#input\_io\_consumption\_enabled) | Flag to enable PostgreSQL status monitor (only working when `server_type` is `single`) | `string` | `"true"` | no | -| [io\_consumption\_extra\_tags](#input\_io\_consumption\_extra\_tags) | Extra tags for PostgreSQL status monitor | `list(string)` | `[]` | no | +| [io\_consumption\_enabled](#input\_io\_consumption\_enabled) | Flag to enable PostgreSQL IO consumption monitor | `string` | `"true"` | no | +| [io\_consumption\_extra\_tags](#input\_io\_consumption\_extra\_tags) | Extra tags for PostgreSQL IO consumption monitor | `list(string)` | `[]` | no | | [io\_consumption\_message](#input\_io\_consumption\_message) | Custom message for PostgreSQL IO consumption monitor | `string` | `""` | no | | [io\_consumption\_threshold\_critical](#input\_io\_consumption\_threshold\_critical) | PostgreSQL IO consumption in percent (critical threshold) | `string` | `"90"` | no | | [io\_consumption\_threshold\_warning](#input\_io\_consumption\_threshold\_warning) | PostgreSQL IO consumption in percent (warning threshold) | `string` | `"80"` | no | diff --git a/cloud/azure/postgresql/inputs.tf b/cloud/azure/postgresql/inputs.tf index e1bc9f66..5eec947a 100644 --- a/cloud/azure/postgresql/inputs.tf +++ b/cloud/azure/postgresql/inputs.tf @@ -178,13 +178,13 @@ variable "free_storage_threshold_critical" { } variable "io_consumption_enabled" { - description = "Flag to enable PostgreSQL status monitor (only working when `server_type` is `single`)" + description = "Flag to enable PostgreSQL IO consumption monitor" type = string default = "true" } variable "io_consumption_extra_tags" { - description = "Extra tags for PostgreSQL status monitor" + description = "Extra tags for PostgreSQL IO consumption monitor" type = list(string) default = [] } diff --git a/cloud/azure/postgresql/locals.tf b/cloud/azure/postgresql/locals.tf index 5e8cedd0..91c6c7f1 100644 --- a/cloud/azure/postgresql/locals.tf +++ b/cloud/azure/postgresql/locals.tf @@ -1,3 +1,4 @@ locals { - metric_namespace = { "single" : "dbforpostgresql_servers", "flexible" : "dbforpostgresql_flexibleservers" }[var.server_type] + metric_namespace = { "single" : "dbforpostgresql_servers", "flexible" : "dbforpostgresql_flexibleservers" }[var.server_type] + metric_io_consumption_percent = { "single" : "io_consumption_percent", "flexible" : "disk_iops_consumed_percentage" }[var.server_type] } diff --git a/cloud/azure/postgresql/monitors-postgresql.tf b/cloud/azure/postgresql/monitors-postgresql.tf index 449b03f8..77793748 100644 --- a/cloud/azure/postgresql/monitors-postgresql.tf +++ b/cloud/azure/postgresql/monitors-postgresql.tf @@ -85,14 +85,14 @@ EOQ } resource "datadog_monitor" "postgresql_io_consumption" { - count = (var.io_consumption_enabled == "true" && var.server_type == "single") ? 1 : 0 + count = (var.io_consumption_enabled == "true") ? 1 : 0 name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Postgresql ${title(var.server_type)} Server IO consumption {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" message = coalesce(var.io_consumption_message, var.message) type = "query alert" query = < ${var.io_consumption_threshold_critical} EOQ