Skip to content

Commit

Permalink
Merge pull request #77 from DFE-Digital/770-adjust-db-monitoring
Browse files Browse the repository at this point in the history
Add window_size to postgres module
  • Loading branch information
johnake authored Nov 28, 2023
2 parents 8c6c2e0 + 207e1e9 commit 8380121
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions aks/postgres/resources.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions aks/postgres/tfdocs.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ No modules.
|------|-------------|------|---------|:--------:|
| <a name="input_admin_password"></a> [admin\_password](#input\_admin\_password) | Password of the admin user | `string` | `null` | no |
| <a name="input_admin_username"></a> [admin\_username](#input\_admin\_username) | Username of the admin user | `string` | `null` | no |
| <a name="input_alert_window_size"></a> [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 |
| <a name="input_azure_cpu_threshold"></a> [azure\_cpu\_threshold](#input\_azure\_cpu\_threshold) | n/a | `number` | `60` | no |
| <a name="input_azure_enable_backup_storage"></a> [azure\_enable\_backup\_storage](#input\_azure\_enable\_backup\_storage) | n/a | `bool` | `true` | no |
| <a name="input_azure_enable_high_availability"></a> [azure\_enable\_high\_availability](#input\_azure\_enable\_high\_availability) | n/a | `bool` | `false` | no |
Expand Down
6 changes: 6 additions & 0 deletions aks/postgres/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions aks/redis/resources.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions aks/redis/tfdocs.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ No modules.

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_alert_window_size"></a> [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 |
| <a name="input_azure_capacity"></a> [azure\_capacity](#input\_azure\_capacity) | n/a | `number` | `1` | no |
| <a name="input_azure_enable_monitoring"></a> [azure\_enable\_monitoring](#input\_azure\_enable\_monitoring) | n/a | `bool` | `true` | no |
| <a name="input_azure_family"></a> [azure\_family](#input\_azure\_family) | n/a | `string` | `"C"` | no |
Expand Down
7 changes: 7 additions & 0 deletions aks/redis/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit 8380121

Please sign in to comment.