Skip to content

Commit

Permalink
feat: [P4PU-680] added allarm for redis (#63)
Browse files Browse the repository at this point in the history
Co-authored-by: antonioT90 <[email protected]>
  • Loading branch information
oleksiybozhykntt and antonioT90 authored Nov 14, 2024
1 parent a63bb70 commit 72cc631
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/06_domains/cittadini-app/00_data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
27 changes: 27 additions & 0 deletions src/06_domains/cittadini-app/12_alert.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 72cc631

Please sign in to comment.