Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions infrastructure/modules/function-app/alerts.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
}

Expand Down
6 changes: 6 additions & 0 deletions infrastructure/modules/function-app/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading