From 6c484fd4ab7217256514449c6c24c4df369f08e9 Mon Sep 17 00:00:00 2001 From: Shahid Azim Date: Tue, 3 Feb 2026 12:59:54 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20disabled=20auto=E2=80=91mitigation=20and?= =?UTF-8?q?=20adjusted=204xx/5xx=20alert=20rules=20to=20fire=20when=20tota?= =?UTF-8?q?l=20is=20greater=20than=20or=20equal=20to=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- infrastructure/modules/function-app/alerts.tf | 8 +++++--- infrastructure/modules/function-app/variables.tf | 6 ++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/infrastructure/modules/function-app/alerts.tf b/infrastructure/modules/function-app/alerts.tf index fd351520..5c888fe7 100644 --- a/infrastructure/modules/function-app/alerts.tf +++ b/infrastructure/modules/function-app/alerts.tf @@ -9,12 +9,13 @@ resource "azurerm_monitor_metric_alert" "function_4xx" { window_size = var.alert_window_size frequency = local.alert_frequency severity = 2 # Warning + auto_mitigate = var.alert_auto_mitigate criteria { metric_namespace = "Microsoft.Web/sites" metric_name = "Http4xx" aggregation = "Total" # Count total 4xx errors - operator = "GreaterThan" + operator = "GreaterThanOrEqual" threshold = var.alert_4xx_threshold } @@ -39,13 +40,14 @@ resource "azurerm_monitor_metric_alert" "function_5xx" { description = "Action will be triggered when 5xx errors exceed ${var.alert_5xx_threshold}" window_size = var.alert_window_size frequency = local.alert_frequency - severity = 2 # Warning + severity = 1 # Error + auto_mitigate = var.alert_auto_mitigate criteria { metric_namespace = "Microsoft.Web/sites" metric_name = "Http5xx" aggregation = "Total" # Count total 5xx errors - operator = "GreaterThan" + operator = "GreaterThanOrEqual" threshold = var.alert_5xx_threshold } diff --git a/infrastructure/modules/function-app/variables.tf b/infrastructure/modules/function-app/variables.tf index 79cb4751..325372d8 100644 --- a/infrastructure/modules/function-app/variables.tf +++ b/infrastructure/modules/function-app/variables.tf @@ -303,6 +303,12 @@ variable "alert_window_size" { description = "The period of time that is used to monitor alert activity e.g. PT1M, PT5M, PT15M, PT30M, PT1H, PT6H, PT12H. The interval between checks is adjusted accordingly." } +variable "alert_auto_mitigate" { + type = bool + description = "Enable or disable automatic mitigation of the alert when the issue is resolved." + default = true +} + variable "enable_alerting" { description = "Whether monitoring and alerting is enabled for the App Service Plan." type = bool