Skip to content

Commit

Permalink
Adding resource health alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
frasermolyneux committed Dec 24, 2024
1 parent db3a6fb commit 1316561
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
45 changes: 45 additions & 0 deletions terraform/data.monitor_action_groups.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
provider "azurerm" {
alias = "azure_monitor"
subscription_id = var.environment == "prd" ? "7760848c-794d-4a19-8cb2-52f71a21ac2b" : "d68448b0-9947-46d7-8771-baa331a3063a"
features {}
storage_use_azuread = true
}

locals {
azure_monitor_resource_group = "rg-platform-monitoring-${var.environment}-uksouth"
}

data "azurerm_monitor_action_group" "critical" {
provider = azurerm.azure_monitor

name = "p0-critical-alerts-${var.environment}"
resource_group_name = local.azure_monitor_resource_group
}

data "azurerm_monitor_action_group" "high" {
provider = azurerm.azure_monitor

name = "p1-high-alerts-${var.environment}"
resource_group_name = local.azure_monitor_resource_group
}

data "azurerm_monitor_action_group" "moderate" {
provider = azurerm.azure_monitor

name = "p2-moderate-alerts-${var.environment}"
resource_group_name = local.azure_monitor_resource_group
}

data "azurerm_monitor_action_group" "low" {
provider = azurerm.azure_monitor

name = "p3-low-alerts-${var.environment}"
resource_group_name = local.azure_monitor_resource_group
}

data "azurerm_monitor_action_group" "informational" {
provider = azurerm.azure_monitor

name = "p4-informational-alerts-${var.environment}"
resource_group_name = local.azure_monitor_resource_group
}
23 changes: 23 additions & 0 deletions terraform/resource_health_alerts.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
resource "azurerm_monitor_activity_log_alert" "rg_resource_health" {
name = "portal-event-ingest-${var.environment} - ${azurerm_resource_group.rg.name} - resource health"

resource_group_name = azurerm_resource_group.rg.name
location = "global"

scopes = [azurerm_resource_group.rg.id]
description = "Resource health alert for ${azurerm_resource_group.rg.name} resource group"

criteria {
category = "ResourceHealth"

resource_health {
previous = ["Available"]
}
}

action {
action_group_id = var.environment == "prd" ? data.azurerm_monitor_action_group.critical.id : data.azurerm_monitor_action_group.informational.id
}

tags = var.tags
}

0 comments on commit 1316561

Please sign in to comment.