diff --git a/cloud/azure/mysql/README.md b/cloud/azure/mysql/README.md index 23bbec5..550bb77 100644 --- a/cloud/azure/mysql/README.md +++ b/cloud/azure/mysql/README.md @@ -22,7 +22,7 @@ Creates DataDog monitors with the following checks: - Mysql Server IO consumption - Mysql Server memory usage - Mysql Server storage -- Mysql Server total connection reach 80 percent of the total limit +- Mysql Server total connection reach ## Inputs @@ -68,9 +68,11 @@ Creates DataDog monitors with the following checks: | new\_host\_delay | Delay in seconds before monitor new resource | string | `"300"` | no | | total\_connection\_enabled | Flag to enable Mysql status monitor | string | `"true"` | no | | total\_connection\_extra\_tags | Extra tags for Mysql status monitor | list | `[]` | no | -| total\_connection\_limit | Limit for Mysql total connection [See details : https://docs.microsoft.com/en-us/azure/mysql/concepts-limits] | string | `""` | no | +| total\_connection\_limit | Limit for Mysql total connection [See details : https://docs.microsoft.com/en-us/azure/mysql/concepts-limits] | string | n/a | yes | | total\_connection\_message | Custom message for Mysql total connection monitor | string | `""` | no | | total\_connection\_silenced | Groups to mute for Mysql total connection monitor | map | `{}` | no | +| total\_connection\_threshold\_critical | Mysql total connection threshold in percent (critical threshold) | string | `"80"` | no | +| total\_connection\_threshold\_warning | Mysql total connection threshold in percent (warning threshold) | string | `"70"` | no | | total\_connection\_time\_aggregator | Monitor aggregator for Mysql total connection [available values: min, max or avg] | string | `"min"` | no | | total\_connection\_timeframe | Monitor timeframe for Mysql total connection [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_5m"` | no | diff --git a/cloud/azure/mysql/inputs.tf b/cloud/azure/mysql/inputs.tf index aa65900..5dfd1c3 100644 --- a/cloud/azure/mysql/inputs.tf +++ b/cloud/azure/mysql/inputs.tf @@ -115,7 +115,16 @@ variable "total_connection_timeframe" { variable "total_connection_limit" { description = "Limit for Mysql total connection [See details : https://docs.microsoft.com/en-us/azure/mysql/concepts-limits]" type = "string" - default = "" +} + +variable "total_connection_threshold_warning" { + description = "Mysql total connection threshold in percent (warning threshold)" + default = "70" +} + +variable "total_connection_threshold_critical" { + description = "Mysql total connection threshold in percent (critical threshold)" + default = "80" } variable "free_storage_silenced" { diff --git a/cloud/azure/mysql/monitors-mysql.tf b/cloud/azure/mysql/monitors-mysql.tf index b165f04..1e412c0 100644 --- a/cloud/azure/mysql/monitors-mysql.tf +++ b/cloud/azure/mysql/monitors-mysql.tf @@ -33,17 +33,22 @@ resource "datadog_monitor" "mysql_cpu_usage" { resource "datadog_monitor" "mysql_total_connection" { count = "${var.total_connection_enabled ? 1 : 0}" - name = "[${var.environment}] Mysql Server total connection reach 80 percent of the total limit" + name = "[${var.environment}] Mysql Server total connection reach {{#is_alert}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}} {{warn_threshold}}% ({{value}}%){{/is_warning}} of the total limit" message = "${coalesce(var.total_connection_message, var.message)}" query = < 80 + ) * 100 > "${var.total_connection_threshold_critical}" EOF type = "metric alert" + thresholds { + critical = "${var.total_connection_threshold_critical}" + warning = "${var.total_connection_threshold_warning}" + } + silenced = "${var.total_connection_silenced}" notify_no_data = true