From abf717d4d5e6177fc33f57328cda15b74f0d57da Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Sat, 10 Feb 2024 18:46:46 +0100 Subject: [PATCH 1/5] Add service health alerting --- code/infra/alerts.tf | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 code/infra/alerts.tf diff --git a/code/infra/alerts.tf b/code/infra/alerts.tf new file mode 100644 index 0000000..d46d955 --- /dev/null +++ b/code/infra/alerts.tf @@ -0,0 +1,40 @@ +resource "azurerm_monitor_activity_log_alert" "monitor_activity_log_alert_service_health" { + name = "${local.prefix}-alert-servicehealth" + resource_group_name = azurerm_resource_group.logging_rg.name + tags = var.tags + + enabled = true + description = "Alerts for service health and maintenance events." + scopes = [ + data.azurerm_subscription.current.id + ] + action { + action_group_id = azurerm_monitor_action_group.monitor_action_group.id + webhook_properties = { + "alert_custom_type" = "service-health", + "alert_custom_location" = var.location + "alert_custom_env" = var.environment + "alert_custom_sub" = data.azurerm_client_config.current.subscription_id + "alert_custom_resource_group" = azurerm_resource_group.extension_rg.name + "alert_custom_instance" = var.prefix + "alert_custom_layer" = "core" + "alert_custom_layer_name" = "core" + "alert_custom_snowseverity" = "Info" + "alert_custom_snowfgroup" = "A.TEC.GLOB.ADP.DL.3RD" + "alert_custom_snowincidentlevel" = "P3" + } + } + criteria { + category = "ServiceHealth" + service_health { + events = [ + "Incident", + "Maintenance" + ] + locations = [ + "Global", + data.azurerm_location.current.display_name + ] + } + } +} From cee3d95fce62ea0fd5ec970c63db78ef4d3ff1ab Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Sat, 10 Feb 2024 18:58:53 +0100 Subject: [PATCH 2/5] Update alert --- code/infra/alerts.tf | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/code/infra/alerts.tf b/code/infra/alerts.tf index d46d955..685157e 100644 --- a/code/infra/alerts.tf +++ b/code/infra/alerts.tf @@ -11,17 +11,11 @@ resource "azurerm_monitor_activity_log_alert" "monitor_activity_log_alert_servic action { action_group_id = azurerm_monitor_action_group.monitor_action_group.id webhook_properties = { - "alert_custom_type" = "service-health", - "alert_custom_location" = var.location - "alert_custom_env" = var.environment - "alert_custom_sub" = data.azurerm_client_config.current.subscription_id - "alert_custom_resource_group" = azurerm_resource_group.extension_rg.name - "alert_custom_instance" = var.prefix - "alert_custom_layer" = "core" - "alert_custom_layer_name" = "core" - "alert_custom_snowseverity" = "Info" - "alert_custom_snowfgroup" = "A.TEC.GLOB.ADP.DL.3RD" - "alert_custom_snowincidentlevel" = "P3" + "alert-type" = "service-health", + "location" = var.location + "environment" = var.environment + "subscription" = data.azurerm_client_config.current.subscription_id + "severity" = "Info" } } criteria { From fb7787bc7b6a56ab234c57d8948f206bc95d877a Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Sat, 10 Feb 2024 19:01:04 +0100 Subject: [PATCH 3/5] Add missing data object --- code/infra/data.tf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/code/infra/data.tf b/code/infra/data.tf index 5285bdf..fb20b54 100644 --- a/code/infra/data.tf +++ b/code/infra/data.tf @@ -1,5 +1,9 @@ data "azurerm_client_config" "current" {} +data "azurerm_location" "current" { + location = var.location +} + data "azurerm_virtual_network" "virtual_network" { name = local.virtual_network.name resource_group_name = local.virtual_network.resource_group_name From 52395c962764999ee16df1c17bd1df0b3cb1315d Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Sat, 10 Feb 2024 19:11:26 +0100 Subject: [PATCH 4/5] Add data object --- code/infra/data.tf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/infra/data.tf b/code/infra/data.tf index fb20b54..66f3212 100644 --- a/code/infra/data.tf +++ b/code/infra/data.tf @@ -1,5 +1,7 @@ data "azurerm_client_config" "current" {} +data "azurerm_subscription" "current" {} + data "azurerm_location" "current" { location = var.location } From a689041c549c83a5339a8c942bad42ec33e8f783 Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Sat, 10 Feb 2024 19:37:16 +0100 Subject: [PATCH 5/5] Update description of alert --- code/infra/alerts.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/infra/alerts.tf b/code/infra/alerts.tf index 685157e..ed2c8fc 100644 --- a/code/infra/alerts.tf +++ b/code/infra/alerts.tf @@ -4,7 +4,7 @@ resource "azurerm_monitor_activity_log_alert" "monitor_activity_log_alert_servic tags = var.tags enabled = true - description = "Alerts for service health and maintenance events." + description = "Alerts about service health and maintenance events." scopes = [ data.azurerm_subscription.current.id ]