Skip to content

Commit

Permalink
Update Azure DB PG Monitor to include Flexible IO monitoring
Browse files Browse the repository at this point in the history
  • Loading branch information
J-Mx committed Aug 28, 2024
1 parent cfa3a8c commit 4673986
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions cloud/azure/postgresql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ Creates DataDog monitors with the following checks:
| <a name="input_free_storage_threshold_warning"></a> [free\_storage\_threshold\_warning](#input\_free\_storage\_threshold\_warning) | PostgreSQL Free Storage remaining in percent (warning threshold) | `string` | `"20"` | no |
| <a name="input_free_storage_time_aggregator"></a> [free\_storage\_time\_aggregator](#input\_free\_storage\_time\_aggregator) | Monitor aggregator for PostgreSQL Free Storage [available values: min, max or avg] | `string` | `"min"` | no |
| <a name="input_free_storage_timeframe"></a> [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 |
| <a name="input_io_consumption_enabled"></a> [io\_consumption\_enabled](#input\_io\_consumption\_enabled) | Flag to enable PostgreSQL status monitor (only working when `server_type` is `single`) | `string` | `"true"` | no |
| <a name="input_io_consumption_extra_tags"></a> [io\_consumption\_extra\_tags](#input\_io\_consumption\_extra\_tags) | Extra tags for PostgreSQL status monitor | `list(string)` | `[]` | no |
| <a name="input_io_consumption_enabled"></a> [io\_consumption\_enabled](#input\_io\_consumption\_enabled) | Flag to enable PostgreSQL IO consumption monitor | `string` | `"true"` | no |
| <a name="input_io_consumption_extra_tags"></a> [io\_consumption\_extra\_tags](#input\_io\_consumption\_extra\_tags) | Extra tags for PostgreSQL IO consumption monitor | `list(string)` | `[]` | no |
| <a name="input_io_consumption_message"></a> [io\_consumption\_message](#input\_io\_consumption\_message) | Custom message for PostgreSQL IO consumption monitor | `string` | `""` | no |
| <a name="input_io_consumption_threshold_critical"></a> [io\_consumption\_threshold\_critical](#input\_io\_consumption\_threshold\_critical) | PostgreSQL IO consumption in percent (critical threshold) | `string` | `"90"` | no |
| <a name="input_io_consumption_threshold_warning"></a> [io\_consumption\_threshold\_warning](#input\_io\_consumption\_threshold\_warning) | PostgreSQL IO consumption in percent (warning threshold) | `string` | `"80"` | no |
Expand Down
4 changes: 2 additions & 2 deletions cloud/azure/postgresql/inputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
}
Expand Down
3 changes: 2 additions & 1 deletion cloud/azure/postgresql/locals.tf
Original file line number Diff line number Diff line change
@@ -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]
}
4 changes: 2 additions & 2 deletions cloud/azure/postgresql/monitors-postgresql.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <<EOQ
${var.io_consumption_time_aggregator}(${var.io_consumption_timeframe}): (
avg:azure.${local.metric_namespace}.io_consumption_percent${module.filter-tags.query_alert} by {resource_group,region,name}
avg:azure.${local.metric_namespace}.${local.metric_io_consumption_percent}${module.filter-tags.query_alert} by {resource_group,region,name}
) > ${var.io_consumption_threshold_critical}
EOQ

Expand Down

0 comments on commit 4673986

Please sign in to comment.