Skip to content

Commit

Permalink
add terraform for low instance alert
Browse files Browse the repository at this point in the history
  • Loading branch information
pluckyswan committed Oct 24, 2024
1 parent 4662928 commit c34a73e
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions operations/template/alert.tf
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,45 @@ resource "azurerm_monitor_scheduled_query_rules_alert" "rs_sftp_log_errors_alert
tags["zone"]
]
}
}

resource "azurerm_monitor_metric_alert" "low_instance_count_alert" {
count = local.non_pr_environment ? 1 : 0
name = "cdc-rs-sftp-${var.environment}-azure-low-instance-count-alert"
resource_group_name = data.azurerm_resource_group.group.name
scopes = [azurerm_monitor_autoscale_setting.sftp_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.sftp_autoscale.profile[0].capacity[0].default - 0.5
}

action {
action_group_id = data.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"]
]
}
}

0 comments on commit c34a73e

Please sign in to comment.