@@ -36,55 +36,3 @@ resource "azurerm_monitor_scheduled_query_rules_alert_v2" "failure_event" {
3636 }
3737 }
3838}
39-
40- # IMPORTANT:
41- # Enable metrics store with all dimensions: https://docs.azure.cn/en-us/azure-monitor/app/metrics-overview?tabs=standard#custom-metrics-dimensions-and-preaggregation
42- # currently this feature is in preview.
43- resource "azurerm_monitor_scheduled_query_rules_alert_v2" "queue_length_high" {
44- for_each = var. enable_alerting ? toset ([
45- " notifications-message-batch-retries"
46- ]) : []
47-
48- name = " ${ var . app_short_name } -${ each . key } -${ var . environment } -queue-length-high-alert"
49- location = var. region
50- resource_group_name = azurerm_resource_group. main . name
51-
52- auto_mitigation_enabled = true
53- description = " Alert when queue length exceeds ${ var . queue_length_alert_threshold } "
54- display_name = " ${ var . app_short_name } Notifications Queue Length High Alert"
55- enabled = true
56- severity = 2
57- evaluation_frequency = " PT10M"
58- window_duration = " PT10M"
59- scopes = [var . app_insights_id ]
60-
61- criteria {
62- query = <<- KQL
63- customMetrics
64- | where name == "${ each . key } "
65- | extend environment = tostring(customDimensions.environment)
66- | where environment == "${ var . environment } "
67- | extend value = toreal(value)
68- | summarize avg_value = avg(value) by bin(timestamp, 5m)
69- | where avg_value > ${ var . queue_length_alert_threshold }
70- KQL
71-
72- metric_measure_column = " avg_value"
73- time_aggregation_method = " Average"
74- operator = " GreaterThan"
75- threshold = 0
76-
77- failing_periods {
78- minimum_failing_periods_to_trigger_alert = 1
79- number_of_evaluation_periods = 1
80- }
81- }
82-
83- action {
84- action_groups = [var . action_group_id ]
85- }
86-
87- tags = {
88- environment = var.environment
89- }
90- }
0 commit comments