Skip to content

Commit 6e9c09e

Browse files
committed
Batch marked as failed event alert for App Insights
This enables an alert that will trigger if one instance of a log based on the query is returned - so if the batch_marked_failed event is triggered once. https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_scheduled_query_rules_alert_v2
1 parent dcc2965 commit 6e9c09e

File tree

1 file changed

+38
-0
lines changed
  • infrastructure/modules/container-apps

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
resource "azurerm_monitor_scheduled_query_rules_alert_v2" "failure_event" {
2+
count = var.enable_alerting ? 1 : 0
3+
4+
auto_mitigation_enabled = false
5+
description = "An alert triggered by a custom event batch_marked_as_failed logged in code"
6+
enabled = var.enable_alerting
7+
evaluation_frequency = "PT5M"
8+
location = var.region
9+
name = "${var.app_short_name}-batch-failed-alert"
10+
resource_group_name = azurerm_resource_group.main.name
11+
scopes = [var.app_insights_id]
12+
severity = 2
13+
skip_query_validation = false
14+
target_resource_types = ["microsoft.insights/components"]
15+
window_duration = "PT5M"
16+
workspace_alerts_storage_enabled = false
17+
18+
action {
19+
action_groups = [var.action_group_id]
20+
}
21+
22+
criteria {
23+
operator = "GreaterThan"
24+
query = <<-QUERY
25+
customEvents
26+
| where name == "batch_marked_as_failed"
27+
| project timestamp, name
28+
| project-rename TimeGenerated=timestamp
29+
QUERY
30+
threshold = 0
31+
time_aggregation_method = "Count"
32+
33+
failing_periods {
34+
minimum_failing_periods_to_trigger_alert = 1
35+
number_of_evaluation_periods = 1
36+
}
37+
}
38+
}

0 commit comments

Comments
 (0)