diff --git a/operations/template/alert.tf b/operations/template/alert.tf index a1191406f..9e666a340 100644 --- a/operations/template/alert.tf +++ b/operations/template/alert.tf @@ -515,3 +515,45 @@ resource "azurerm_monitor_scheduled_query_rules_alert" "ti-log-errors-alert" { ] } } + +resource "azurerm_monitor_metric_alert" "api-response-time-alert" { + count = local.non_pr_environment ? 1 : 0 + name = "cdcti-${var.environment}-api-response-time-alert" + resource_group_name = data.azurerm_resource_group.group.name + scopes = [azurerm_linux_web_app.api.id] + description = "Alerts when the average API response time across the service plan is high" + severity = 2 + frequency = "PT1M" + window_size = "PT15M" + + criteria { + metric_name = "HttpResponseTime" + metric_namespace = "microsoft.Web/sites" + aggregation = "Average" + operator = "GreaterThan" + threshold = 5 # Value is in seconds + } + + 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"] + ] + } + +}