diff --git a/src/06_domains/cittadini-app/00_data.tf b/src/06_domains/cittadini-app/00_data.tf index e61efb2..20aaae3 100644 --- a/src/06_domains/cittadini-app/00_data.tf +++ b/src/06_domains/cittadini-app/00_data.tf @@ -38,4 +38,9 @@ data "azurerm_key_vault_secret" "appinsights_connection_string" { data "azurerm_log_analytics_workspace" "log_analytics" { name = local.log_analytics_name resource_group_name = local.monitor_resource_group_name +} + +data "azurerm_redis_cache" "redis_common" { + name = "${local.project}-redis" + resource_group_name = "${local.project}-redis-rg" } \ No newline at end of file diff --git a/src/06_domains/cittadini-app/12_alert.tf b/src/06_domains/cittadini-app/12_alert.tf index d16272e..96cebd9 100644 --- a/src/06_domains/cittadini-app/12_alert.tf +++ b/src/06_domains/cittadini-app/12_alert.tf @@ -118,5 +118,32 @@ resource "azurerm_monitor_metric_alert" "ram_cluster_usage" { action_group_id = azurerm_monitor_action_group.slack_cittadini[0].id } + tags = var.tags +} + +resource "azurerm_monitor_metric_alert" "redis_server_load" { + count = var.alert_enabled ? 1 : 0 + + name = "${local.project}-redis-server-load" + resource_group_name = data.azurerm_resource_group.monitor_rg.name + + scopes = [data.azurerm_redis_cache.redis_common.id] + severity = 0 + frequency = "PT15M" + window_size = "PT30M" + criteria { + metric_namespace = "Microsoft.Cache/redis" + metric_name = "allserverLoad" + aggregation = "Average" + threshold = 80 + operator = "GreaterThan" + } + + description = "Trigger alert when Redis serve usage is greater than 80%" + enabled = true + action { + action_group_id = azurerm_monitor_action_group.slack_cittadini[0].id + } + tags = var.tags } \ No newline at end of file