diff --git a/database/postgresql/README.md b/database/postgresql/README.md index e96d886..d5228e0 100644 --- a/database/postgresql/README.md +++ b/database/postgresql/README.md @@ -31,11 +31,11 @@ Inputs | filter_tags_custom | Tags used for custom filtering when filter_tags_use_defaults is false | string | `*` | no | | postgresql_connection_threshold_critical | Maximum critical acceptable percent of connections | string | `80` | no | | postgresql_connection_threshold_warning | Maximum warning acceptable percent of connections | string | `70` | no | -| postgresql_connection_silenced | Groups to mute PostgreSQL connection monitor | map | `` | no | +| postgresql_connection_silenced | Groups to mute for PostgreSQL connection monitor | map | `` | no | | postgresql_connection_message | Custom message for PostgreSQL connection monitor | string | `` | no | | postgresql_thread_threshold_critical | Maximum critical acceptable number of threads | string | `500` | no | | postgresql_thread_threshold_warning | Maximum warning acceptable number of threads | string | `400` | no | -| postgresql_thread_silenced | Groups to mute PostgreSQL threads monitor | map | `` | no | +| postgresql_thread_silenced | Groups to mute for PostgreSQL threads monitor | map | `` | no | | postgresql_thread_message | Custom message for PostgreSQL thread monitor | string | `` | no | | message | Message sent when a monitor is triggered | string | - | yes | diff --git a/database/postgresql/inputs.tf b/database/postgresql/inputs.tf index 9c884f5..a6eecbb 100644 --- a/database/postgresql/inputs.tf +++ b/database/postgresql/inputs.tf @@ -39,11 +39,17 @@ variable "postgresql_connection_threshold_warning" { } variable "postgresql_connection_silenced" { - description = "Groups to mute PostgreSQL connection monitor" + description = "Groups to mute for PostgreSQL connection monitor" type = "map" default = {} } +variable "postgresql_connection_enabled" { + description = "Flag to enable PostgreSQL connection monitor" + type = "string" + default = "true" +} + variable "postgresql_connection_message" { description = "Custom message for PostgreSQL connection monitor" type = "string" @@ -65,11 +71,17 @@ variable "postgresql_lock_threshold_warning" { } variable "posgresql_lock_silenced" { - description = "Groups to mute PostgreSQL lock monitor" + description = "Groups to mute for PostgreSQL lock monitor" type = "map" default = {} } +variable "postgresql_lock_enabled" { + description = "Flag to enable PostgreSQL lock monitor" + type = "string" + default = "true" +} + variable "postgresql_lock_message" { description = "Custom message for PostgreSQL lock monitor" type = "string" diff --git a/database/postgresql/monitors-postgresql.tf b/database/postgresql/monitors-postgresql.tf index d2778d7..090edfa 100644 --- a/database/postgresql/monitors-postgresql.tf +++ b/database/postgresql/monitors-postgresql.tf @@ -7,6 +7,7 @@ data "template_file" "filter" { } resource "datadog_monitor" "postgresql_connection_too_high" { + count = "${var.postgresql_connection_enabled ? 1 : 0}" name = "[${var.environment}] PostgreSQL Connections {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" message = "${coalesce(var.postgresql_connection_message, var.message)}" type = "metric alert" @@ -37,6 +38,7 @@ resource "datadog_monitor" "postgresql_connection_too_high" { } resource "datadog_monitor" "postgresql_too_many_locks" { + count = "${var.postgresql_lock_enabled ? 1 : 0}" name = "[${var.environment}] PostgreSQL too many locks {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}" message = "${coalesce(var.postgresql_lock_message, var.message)}" type = "metric alert"