Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
saliceti committed Jul 29, 2024
1 parent d476d03 commit 3392a20
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
19 changes: 8 additions & 11 deletions aks/postgres/resources.tf
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
locals {

alert_frequency_map = {
PT5M = "PT1M"
PT15M = "PT1M"
PT30M = "PT1M"
PT1H = "PT1M"
PT6H = "PT5M"
PT12H = "PT5M"
}

database_name = "${var.service_short}_${var.environment}"

name_suffix = var.name != null ? "-${var.name}" : ""
Expand All @@ -21,8 +11,15 @@ locals {

kubernetes_name = "${var.service_name}-${var.environment}-postgres${local.name_suffix}"

alert_frequency_map = {
PT5M = "PT1M"
PT15M = "PT1M"
PT30M = "PT1M"
PT1H = "PT1M"
PT6H = "PT5M"
PT12H = "PT5M"
}
alert_frequency = local.alert_frequency_map[var.alert_window_size]

}

# Username & password
Expand Down
11 changes: 11 additions & 0 deletions aks/redis/resources.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ locals {
azure_enable_monitoring = var.use_azure && var.azure_enable_monitoring

kubernetes_name = "${var.service_name}-${var.environment}-redis${local.name_suffix}"

alert_frequency_map = {
PT5M = "PT1M"
PT15M = "PT1M"
PT30M = "PT1M"
PT1H = "PT1M"
PT6H = "PT5M"
PT12H = "PT5M"
}
alert_frequency = local.alert_frequency_map[var.alert_window_size]
}

# Azure
Expand Down Expand Up @@ -86,6 +96,7 @@ resource "azurerm_monitor_metric_alert" "memory" {
scopes = [azurerm_redis_cache.main[0].id]
description = "Action will be triggered when memory use is greater than ${var.azure_memory_threshold}%"
window_size = var.alert_window_size
frequency = local.alert_frequency

criteria {
metric_namespace = "Microsoft.Cache/redis"
Expand Down
6 changes: 5 additions & 1 deletion aks/redis/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,9 @@ variable "alert_window_size" {
type = string
default = "PT5M"
nullable = false
description = "The period of time that is used to monitor alert activity e.g PT1M, PT5M, PT15M, PT30M, PT1H, PT6H or PT12H"
validation {
condition = contains(["PT1M", "PT5M", "PT15M", "PT30M", "PT1H", "PT6H", "PT12H"], var.alert_window_size)
error_message = "The alert_window_size must be one of: PT1M, PT5M, PT15M, PT30M, PT1H, PT6H, PT12H"
}
description = "The period of time that is used to monitor alert activity. The interval between checks is adjusted accordingly."
}

0 comments on commit 3392a20

Please sign in to comment.