diff --git a/database/postgresql/inputs.tf b/database/postgresql/inputs.tf index 8b44746..68f2a69 100644 --- a/database/postgresql/inputs.tf +++ b/database/postgresql/inputs.tf @@ -61,6 +61,19 @@ variable "postgresql_connection_message" { default = "" } +variable "postgresql_connection_time_aggregator" { + description = "Monitor time aggregator for PostgreSQL connection monitor [available values: min, max or avg]" + type = "string" + default = "avg" +} + +variable "postgresql_connection_timeframe" { + description = "Monitor timeframe for PostgreSQL connection monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" + type = "string" + default = "last_15m" +} + + ############################ ### PostgreSQL locks ### ############################ @@ -92,3 +105,17 @@ variable "postgresql_lock_message" { type = "string" default = "" } + +variable "postgresql_lock_time_aggregator" { + description = "Monitor time aggregator for PostgreSQL lock monitor [available values: min, max or avg]" + type = "string" + default = "min" +} + +variable "postgresql_lock_timeframe" { + description = "Monitor timeframe for PostgreSQL lock monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" + type = "string" + default = "last_5m" +} + + diff --git a/database/postgresql/monitors-postgresql.tf b/database/postgresql/monitors-postgresql.tf index e5bf424..30fac1c 100644 --- a/database/postgresql/monitors-postgresql.tf +++ b/database/postgresql/monitors-postgresql.tf @@ -5,9 +5,9 @@ resource "datadog_monitor" "postgresql_connection_too_high" { type = "metric alert" query = < ${var.postgresql_connection_threshold_critical} + * 100 > ${var.postgresql_connection_threshold_critical} EOF evaluation_delay = "${var.evaluation_delay}" @@ -36,9 +36,9 @@ resource "datadog_monitor" "postgresql_too_many_locks" { type = "metric alert" query = < ${var.postgresql_lock_threshold_critical} + ${var.postgresql_lock_time_aggregator}(${var.postgresql_lock_timeframe}): + default(avg:postgresql.locks${module.filter-tags.query_alert} by {server}, 0) + > ${var.postgresql_lock_threshold_critical} EOF evaluation_delay = "${var.evaluation_delay}"