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