Skip to content

Commit

Permalink
Merge branch 'main' into 5xx-error-alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
pluckyswan authored Oct 23, 2024
2 parents 8d66c8f + eca4729 commit e3b46ec
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
41 changes: 41 additions & 0 deletions operations/template/alert.tf
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,47 @@ resource "azurerm_monitor_metric_alert" "azure_5XX_alert" {
aggregation = "Count"
operator = "GreaterThanOrEqual"
threshold = 1
}

action {
action_group_id = azurerm_monitor_action_group.notify_slack_email[count.index].id
}

lifecycle {
# Ignore changes to tags because the CDC sets these automagically
ignore_changes = [
tags["business_steward"],
tags["center"],
tags["environment"],
tags["escid"],
tags["funding_source"],
tags["pii_data"],
tags["security_compliance"],
tags["security_steward"],
tags["support_group"],
tags["system"],
tags["technical_steward"],
tags["zone"]
]
}
}

resource "azurerm_monitor_metric_alert" "low_instance_count_alert" {
count = local.non_pr_environment ? 1 : 0
name = "cdcti-${var.environment}-azure-low-instance-count-alert"
resource_group_name = data.azurerm_resource_group.group.name
scopes = [azurerm_monitor_autoscale_setting.api_autoscale.id]
description = "The instance count in ${var.environment} is too low"
severity = 2 // warning
frequency = "PT1M" // Checks every 1 minute
window_size = "PT15M" // Every Check, looks back 15 minutes in history

criteria {
metric_namespace = "Microsoft.Insights/autoscalesettings"
metric_name = "ObservedCapacity"
aggregation = "Average"
operator = "LessThanOrEqual"
threshold = azurerm_monitor_autoscale_setting.api_autoscale.profile[0].capacity[0].default - 0.5
}

action {
Expand Down
4 changes: 3 additions & 1 deletion operations/template/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ locals {
rs_domain_prefix = "${local.selected_rs_environment_prefix}${length(local.selected_rs_environment_prefix) == 0 ? "" : "."}"
higher_environment_level = var.environment == "stg" || var.environment == "prd"
cdc_domain_environment = var.environment == "dev" || var.environment == "stg" || var.environment == "prd"
non_pr_environment = !strcontains(var.environment, "pr")

// If the environment looks like pr123, regexall will contain matches. If there are no matches, it's a non-pr env
non_pr_environment = length(regexall("^pr\\d+", var.environment)) == 0
}

data "azurerm_resource_group" "group" {
Expand Down

0 comments on commit e3b46ec

Please sign in to comment.