diff --git a/src/domains/elt/_modules/function_apps/function_app_elt.tf b/src/domains/elt/_modules/function_apps/function_app_elt.tf index 1a36dda80..d5a43157c 100644 --- a/src/domains/elt/_modules/function_apps/function_app_elt.tf +++ b/src/domains/elt/_modules/function_apps/function_app_elt.tf @@ -95,7 +95,7 @@ locals { MESSAGE_STATUS_FAILURE_QUEUE_NAME = "pdnd-io-cosmosdb-message-status-failure" SERVICES_FAILURE_QUEUE_NAME = "pdnd-io-cosmosdb-services-failure" SERVICE_PREFERENCES_FAILURE_QUEUE_NAME = local.service_preferences_failure_queue_name - PROFILES_FAILURE_QUEUE_NAME = "pdnd-io-cosmosdb-profiles-failure" + PROFILES_FAILURE_QUEUE_NAME = local.profiles_failure_queue_name INTERNAL_TEST_FISCAL_CODES = module.tests.test_users.all } @@ -168,8 +168,8 @@ module "function_elt" { "${local.function_elt.app_settings.SERVICES_FAILURE_QUEUE_NAME}-poison", local.service_preferences_failure_queue_name, "${local.service_preferences_failure_queue_name}-poison", - local.function_elt.app_settings.PROFILES_FAILURE_QUEUE_NAME, - "${local.function_elt.app_settings.PROFILES_FAILURE_QUEUE_NAME}-poison" + local.profiles_failure_queue_name, + "${local.profiles_failure_queue_name}-poison" ], "containers" = [], "blobs_retention_days" = 1, diff --git a/src/domains/elt/_modules/function_apps/locals.tf b/src/domains/elt/_modules/function_apps/locals.tf index 0c76a15dd..cb209ae22 100644 --- a/src/domains/elt/_modules/function_apps/locals.tf +++ b/src/domains/elt/_modules/function_apps/locals.tf @@ -17,4 +17,5 @@ locals { pn_service_id = "01G40DWQGKY5GRWSNM4303VNRP" service_preferences_failure_queue_name = "pdnd-io-cosmosdb-service-preferences-failure" + profiles_failure_queue_name = "pdnd-io-cosmosdb-profiles-failure" } diff --git a/src/domains/elt/_modules/function_apps/monitor.tf b/src/domains/elt/_modules/function_apps/monitor.tf index bc4b2c271..5ea114d5e 100644 --- a/src/domains/elt/_modules/function_apps/monitor.tf +++ b/src/domains/elt/_modules/function_apps/monitor.tf @@ -54,5 +54,39 @@ resource "azurerm_monitor_scheduled_query_rules_alert_v2" "service_preferences_f ] } + tags = var.tags +} + +resource "azurerm_monitor_scheduled_query_rules_alert_v2" "profiles_failure_alert_rule" { + enabled = true + name = "[CITIZEN-AUTH | iopfneltsdt] Failures on pdnd-io-cosmosdb-profiles-failure-poison" + resource_group_name = var.resource_group_name + location = var.location + + scopes = [data.azurerm_storage_account.function_elt_internal_storage.id] + description = "Permanent failures processing Profiles export to PDND. REQUIRED MANUAL ACTION" + severity = 1 + auto_mitigation_enabled = false + + window_duration = "PT15M" # Select the interval that's used to group the data points by using the aggregation type function. Choose an Aggregation granularity (period) that's greater than the Frequency of evaluation to reduce the likelihood of missing the first evaluation period of an added time series. + evaluation_frequency = "PT15M" # Select how often the alert rule is to be run. Select a frequency that's smaller than the aggregation granularity to generate a sliding window for the evaluation. + + criteria { + query = <<-QUERY + StorageQueueLogs + | where OperationName contains "PutMessage" + | where Uri contains "${local.profiles_failure_queue_name}-poison" + QUERY + operator = "GreaterThan" + threshold = 0 + time_aggregation_method = "Count" + } + + action { + action_groups = [ + data.azurerm_monitor_action_group.quarantine_error_action_group.id, + ] + } + tags = var.tags } \ No newline at end of file