Skip to content

Commit

Permalink
feat: [PAYMCLOUD-175] Add infra_opsgenie to action groups in alerts o…
Browse files Browse the repository at this point in the history
…n next-core (#2580)

Add infra_opsgenie to action groups in alerts

This change incorporates the infra_opsgenie action group into the existing alert configurations across multiple Terraform files. The infra_opsgenie action group is added under various alert actions, and it is specifically enabled conditionally for production environments in several monitoring configurations. This ensures critical alerts are also sent to the infra_opsgenie group, enhancing our alerting capabilities.

Signed-off-by: Fabio Felici <[email protected]>
  • Loading branch information
ffppa authored Nov 22, 2024
1 parent 7bb7c24 commit 31dcabb
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 52 deletions.
31 changes: 21 additions & 10 deletions src/next-core/03_apim.tf
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,27 @@ module "apim" {

alerts_enabled = var.apim_v2_alerts_enabled

action = [
{
action_group_id = azurerm_monitor_action_group.slack.id
webhook_properties = null
},
{
action_group_id = azurerm_monitor_action_group.email.id
webhook_properties = null
}
]
# takes a list and replaces any elements that are lists with a
# flattened sequence of the list contents.
# In this case, we enable OpsGenie only on prod env
action = flatten([
[
{
action_group_id = azurerm_monitor_action_group.slack.id
webhook_properties = null
},
{
action_group_id = azurerm_monitor_action_group.email.id
webhook_properties = null
}
],
(var.env == "prod" ? [
{
action_group_id = azurerm_monitor_action_group.infra_opsgenie.0.id
webhook_properties = null
}
] : [])
])

# metrics docs
# https://docs.microsoft.com/en-us/azure/azure-monitor/essentials/metrics-supported#microsoftapimanagementservice
Expand Down
31 changes: 21 additions & 10 deletions src/next-core/04_appgw.tf
Original file line number Diff line number Diff line change
Expand Up @@ -568,16 +568,27 @@ module "app_gw" {

alerts_enabled = var.app_gateway_alerts_enabled

action = [
{
action_group_id = azurerm_monitor_action_group.slack.id
webhook_properties = null
},
{
action_group_id = azurerm_monitor_action_group.email.id
webhook_properties = null
}
]
# takes a list and replaces any elements that are lists with a
# flattened sequence of the list contents.
# In this case, we enable OpsGenie only on prod env
action = flatten([
[
{
action_group_id = azurerm_monitor_action_group.slack.id
webhook_properties = null
},
{
action_group_id = azurerm_monitor_action_group.email.id
webhook_properties = null
}
],
(var.env == "prod" ? [
{
action_group_id = azurerm_monitor_action_group.infra_opsgenie.0.id
webhook_properties = null
}
] : [])
])

# metrics docs
# https://docs.microsoft.com/en-us/azure/azure-monitor/essentials/metrics-supported#microsoftnetworkapplicationgateways
Expand Down
31 changes: 21 additions & 10 deletions src/next-core/04_appgw_integration.tf
Original file line number Diff line number Diff line change
Expand Up @@ -234,16 +234,27 @@ module "app_gw_integration" {

alerts_enabled = var.integration_app_gateway_alerts_enabled

action = [
{
action_group_id = azurerm_monitor_action_group.slack.id
webhook_properties = null
},
{
action_group_id = azurerm_monitor_action_group.email.id
webhook_properties = null
}
]
# takes a list and replaces any elements that are lists with a
# flattened sequence of the list contents.
# In this case, we enable OpsGenie only on prod env
action = flatten([
[
{
action_group_id = azurerm_monitor_action_group.slack.id
webhook_properties = null
},
{
action_group_id = azurerm_monitor_action_group.email.id
webhook_properties = null
}
],
(var.env == "prod" ? [
{
action_group_id = azurerm_monitor_action_group.infra_opsgenie.0.id
webhook_properties = null
}
] : [])
])

# metrics docs
# https://docs.microsoft.com/en-us/azure/azure-monitor/essentials/metrics-supported#microsoftnetworkapplicationgateways
Expand Down
63 changes: 43 additions & 20 deletions src/next-core/05_messages.tf
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,28 @@ module "event_hub03" {

alerts_enabled = var.ehns_alerts_enabled
metric_alerts = var.ehns_metric_alerts
action = [
{
action_group_id = azurerm_monitor_action_group.slack.id
webhook_properties = null
},
{
action_group_id = azurerm_monitor_action_group.email.id
webhook_properties = null
}
]

# takes a list and replaces any elements that are lists with a
# flattened sequence of the list contents.
# In this case, we enable OpsGenie only on prod env
action = flatten([
[
{
action_group_id = azurerm_monitor_action_group.slack.id
webhook_properties = null
},
{
action_group_id = azurerm_monitor_action_group.email.id
webhook_properties = null
}
],
(var.env == "prod" ? [
{
action_group_id = azurerm_monitor_action_group.infra_opsgenie.0.id
webhook_properties = null
}
] : [])
])

tags = var.tags
}
Expand Down Expand Up @@ -110,16 +122,27 @@ module "event_hub04" {

eventhubs = var.eventhubs_04

action = [
{
action_group_id = azurerm_monitor_action_group.slack.id
webhook_properties = null
},
{
action_group_id = azurerm_monitor_action_group.email.id
webhook_properties = null
}
]
# takes a list and replaces any elements that are lists with a
# flattened sequence of the list contents.
# In this case, we enable OpsGenie only on prod env
action = flatten([
[
{
action_group_id = azurerm_monitor_action_group.slack.id
webhook_properties = null
},
{
action_group_id = azurerm_monitor_action_group.email.id
webhook_properties = null
}
],
(var.env == "prod" ? [
{
action_group_id = azurerm_monitor_action_group.infra_opsgenie.0.id
webhook_properties = null
}
] : [])
])

tags = var.tags
}
Expand Down
11 changes: 9 additions & 2 deletions src/next-core/06_node_forwarder.tf
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,10 @@ resource "azurerm_monitor_metric_alert" "app_service_over_cpu_usage" {
action {
action_group_id = azurerm_monitor_action_group.new_conn_srv_opsgenie[0].id
}
action {
action_group_id = azurerm_monitor_action_group.infra_opsgenie.0.id
}


tags = var.tags
}
Expand Down Expand Up @@ -401,6 +405,9 @@ resource "azurerm_monitor_metric_alert" "app_service_over_mem_usage" {
action {
action_group_id = azurerm_monitor_action_group.new_conn_srv_opsgenie[0].id
}
action {
action_group_id = azurerm_monitor_action_group.infra_opsgenie.0.id
}

tags = var.tags
}
Expand Down Expand Up @@ -461,7 +468,7 @@ resource "azurerm_monitor_scheduled_query_rules_alert" "opex_pagopa-node-forward
location = var.location

action {
action_group = [azurerm_monitor_action_group.email.id, azurerm_monitor_action_group.slack.id, azurerm_monitor_action_group.mo_email.id, azurerm_monitor_action_group.new_conn_srv_opsgenie[0].id]
action_group = [azurerm_monitor_action_group.email.id, azurerm_monitor_action_group.slack.id, azurerm_monitor_action_group.mo_email.id, azurerm_monitor_action_group.new_conn_srv_opsgenie[0].id, azurerm_monitor_action_group.infra_opsgenie.0.id]
email_subject = "Email Header"
custom_webhook_payload = "{}"
}
Expand Down Expand Up @@ -495,7 +502,7 @@ resource "azurerm_monitor_scheduled_query_rules_alert" "opex_pagopa-node-forward
location = var.location

action {
action_group = [azurerm_monitor_action_group.email.id, azurerm_monitor_action_group.slack.id, azurerm_monitor_action_group.mo_email.id, azurerm_monitor_action_group.new_conn_srv_opsgenie[0].id]
action_group = [azurerm_monitor_action_group.email.id, azurerm_monitor_action_group.slack.id, azurerm_monitor_action_group.mo_email.id, azurerm_monitor_action_group.new_conn_srv_opsgenie[0].id, azurerm_monitor_action_group.infra_opsgenie.0.id]
email_subject = "Email Header"
custom_webhook_payload = "{}"
}
Expand Down
3 changes: 3 additions & 0 deletions src/next-core/08_natgateway.tf
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ resource "azurerm_monitor_metric_alert" "snat_connection_over_10K" {
action {
action_group_id = azurerm_monitor_action_group.new_conn_srv_opsgenie[0].id
}
action {
action_group_id = azurerm_monitor_action_group.infra_opsgenie.0.id
}

tags = var.tags
}

0 comments on commit 31dcabb

Please sign in to comment.