Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Azure DB PG Monitor to include Flexible IO monitoring #56

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading