Skip to content

Commit

Permalink
feat: [PAYMCLOUD-139] Add Opsgenie action group for production alerti…
Browse files Browse the repository at this point in the history
…ng (#2543)

* Add Opsgenie action group for production alerting

This update incorporates Opsgenie into the monitoring action groups for production environments. The addition ensures that critical alerts are directed to Opsgenie for improved incident management. The configuration checks the environment and conditionally includes the Opsgenie action group as needed.

Signed-off-by: Fabio Felici <[email protected]>

* Update AKS module and migrate alerts to log-based

Updated the AKS module version to v8.58.0 and migrated metric-based alerts to log-based alerts for improved accuracy. Commented out old metric-alert configurations and removed them from the `custom_metric_alerts` in favor of the new `custom_logs_alerts`.

Signed-off-by: Fabio Felici <[email protected]>

* Remove commented AKS metric alerts

Deleted extensive commented-out AKS metric alert configurations in 99_locals.tf. This cleanup improves file readability and maintenance by removing obsolete or unused alert definitions.

Signed-off-by: Fabio Felici <[email protected]>

---------

Signed-off-by: Fabio Felici <[email protected]>
  • Loading branch information
ffppa authored Nov 21, 2024
1 parent 598ed1e commit f81aab5
Show file tree
Hide file tree
Showing 4 changed files with 245 additions and 152 deletions.
5 changes: 5 additions & 0 deletions src/aks-leonardo/00_monitor.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,8 @@ data "azurerm_monitor_action_group" "email" {
name = local.monitor_action_group_email_name
}

data "azurerm_monitor_action_group" "opsgenie" {
count = var.env_short == "p" ? 1 : 0
resource_group_name = var.monitor_resource_group_name
name = local.monitor_action_group_opsgenie_name
}
37 changes: 23 additions & 14 deletions src/aks-leonardo/03_aks_0.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ resource "azurerm_resource_group" "rg_aks" {
}

module "aks_leonardo" {
source = "git::https://github.com/pagopa/terraform-azurerm-v3.git//kubernetes_cluster?ref=v8.55.0"
source = "git::https://github.com/pagopa/terraform-azurerm-v3.git//kubernetes_cluster?ref=v8.58.0"

name = local.aks_cluster_name
location = var.location
Expand Down Expand Up @@ -56,19 +56,28 @@ module "aks_leonardo" {
addon_azure_key_vault_secrets_provider_enabled = true
addon_azure_pod_identity_enabled = true

alerts_enabled = var.aks_alerts_enabled
custom_metric_alerts = local.aks_metrics_alerts

action = [
{
action_group_id = data.azurerm_monitor_action_group.slack.id
webhook_properties = null
},
{
action_group_id = data.azurerm_monitor_action_group.email.id
webhook_properties = null
}
]
alerts_enabled = var.aks_alerts_enabled
# custom_metric_alerts = local.aks_metrics_alerts
custom_logs_alerts = local.aks_logs_alerts

action = flatten([
[
{
action_group_id = data.azurerm_monitor_action_group.slack.id
webhook_properties = null
},
{
action_group_id = data.azurerm_monitor_action_group.email.id
webhook_properties = null
}
],
(var.env == "prod" ? [
{
action_group_id = data.azurerm_monitor_action_group.opsgenie.0.id
webhook_properties = null
}
] : [])
])

microsoft_defender_log_analytics_workspace_id = var.env == "prod" ? data.azurerm_log_analytics_workspace.log_analytics_italy.id : null

Expand Down
Loading

0 comments on commit f81aab5

Please sign in to comment.