From 207e1e94ae4de1982ae7066647c72d271a49cb9a Mon Sep 17 00:00:00 2001 From: John Ake Date: Mon, 27 Nov 2023 12:18:28 +0000 Subject: [PATCH] Add alert_window_size to postgres and redis modules --- aks/postgres/resources.tf | 3 +++ aks/postgres/tfdocs.md | 1 + aks/postgres/variables.tf | 6 ++++++ aks/redis/resources.tf | 1 + aks/redis/tfdocs.md | 1 + aks/redis/variables.tf | 7 +++++++ 6 files changed, 19 insertions(+) diff --git a/aks/postgres/resources.tf b/aks/postgres/resources.tf index 87bcbbd..4ba1a4a 100644 --- a/aks/postgres/resources.tf +++ b/aks/postgres/resources.tf @@ -151,6 +151,7 @@ resource "azurerm_monitor_metric_alert" "memory" { resource_group_name = data.azurerm_resource_group.main[0].name scopes = [azurerm_postgresql_flexible_server.main[0].id] description = "Action will be triggered when memory use is greater than 75%" + window_size = var.alert_window_size criteria { metric_namespace = "Microsoft.DBforPostgreSQL/flexibleServers" @@ -178,6 +179,7 @@ resource "azurerm_monitor_metric_alert" "cpu" { resource_group_name = data.azurerm_resource_group.main[0].name scopes = [azurerm_postgresql_flexible_server.main[0].id] description = "Action will be triggered when cpu use is greater than 60%" + window_size = var.alert_window_size criteria { metric_namespace = "Microsoft.DBforPostgreSQL/flexibleServers" @@ -205,6 +207,7 @@ resource "azurerm_monitor_metric_alert" "storage" { resource_group_name = data.azurerm_resource_group.main[0].name scopes = [azurerm_postgresql_flexible_server.main[0].id] description = "Action will be triggered when storage use is greater than 75%" + window_size = var.alert_window_size criteria { metric_namespace = "Microsoft.DBforPostgreSQL/flexibleServers" diff --git a/aks/postgres/tfdocs.md b/aks/postgres/tfdocs.md index 05e77f4..b7cb77b 100644 --- a/aks/postgres/tfdocs.md +++ b/aks/postgres/tfdocs.md @@ -47,6 +47,7 @@ No modules. |------|-------------|------|---------|:--------:| | [admin\_password](#input\_admin\_password) | Password of the admin user | `string` | `null` | no | | [admin\_username](#input\_admin\_username) | Username of the admin user | `string` | `null` | no | +| [alert\_window\_size](#input\_alert\_window\_size) | The period of time that is used to monitor alert activity e.g PT1M, PT5M, PT15M, PT30M, PT1H, PT6H or PT12H | `string` | `"PT5M"` | no | | [azure\_cpu\_threshold](#input\_azure\_cpu\_threshold) | n/a | `number` | `60` | no | | [azure\_enable\_backup\_storage](#input\_azure\_enable\_backup\_storage) | n/a | `bool` | `true` | no | | [azure\_enable\_high\_availability](#input\_azure\_enable\_high\_availability) | n/a | `bool` | `false` | no | diff --git a/aks/postgres/variables.tf b/aks/postgres/variables.tf index 71cb6e3..3ad5ddd 100644 --- a/aks/postgres/variables.tf +++ b/aks/postgres/variables.tf @@ -114,6 +114,12 @@ variable "azure_enable_monitoring" { default = true } +variable "alert_window_size" { + type = string + default = "PT5M" + description = "The period of time that is used to monitor alert activity e.g PT1M, PT5M, PT15M, PT30M, PT1H, PT6H or PT12H" +} + variable "azure_maintenance_window" { type = object({ day_of_week = optional(number) diff --git a/aks/redis/resources.tf b/aks/redis/resources.tf index bedaecb..33bb6b4 100644 --- a/aks/redis/resources.tf +++ b/aks/redis/resources.tf @@ -85,6 +85,7 @@ resource "azurerm_monitor_metric_alert" "memory" { resource_group_name = data.azurerm_resource_group.main[0].name scopes = [azurerm_redis_cache.main[0].id] description = "Action will be triggered when memory use is greater than 60%" + window_size = var.alert_window_size criteria { metric_namespace = "Microsoft.Cache/redis" diff --git a/aks/redis/tfdocs.md b/aks/redis/tfdocs.md index f45bf1b..0126cd0 100644 --- a/aks/redis/tfdocs.md +++ b/aks/redis/tfdocs.md @@ -32,6 +32,7 @@ No modules. | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| +| [alert\_window\_size](#input\_alert\_window\_size) | The period of time that is used to monitor alert activity e.g PT1M, PT5M, PT15M, PT30M, PT1H, PT6H or PT12H | `string` | `"PT5M"` | no | | [azure\_capacity](#input\_azure\_capacity) | n/a | `number` | `1` | no | | [azure\_enable\_monitoring](#input\_azure\_enable\_monitoring) | n/a | `bool` | `true` | no | | [azure\_family](#input\_azure\_family) | n/a | `string` | `"C"` | no | diff --git a/aks/redis/variables.tf b/aks/redis/variables.tf index 6feee69..9f20e91 100644 --- a/aks/redis/variables.tf +++ b/aks/redis/variables.tf @@ -103,3 +103,10 @@ variable "azure_patch_schedule" { })) default = [] } + +variable "alert_window_size" { + type = string + default = "PT5M" + description = "The period of time that is used to monitor alert activity e.g PT1M, PT5M, PT15M, PT30M, PT1H, PT6H or PT12H" +} +