Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure Log Alert #1484

Merged
merged 8 commits into from
Oct 24, 2024
11 changes: 4 additions & 7 deletions operations/template/alert.tf
Original file line number Diff line number Diff line change
Expand Up @@ -260,22 +260,19 @@ resource "azurerm_monitor_scheduled_query_rules_alert" "ti-log-errors-alert" {

query = <<-QUERY
AppServiceConsoleLogs
| where TimeGenerated >= ago(00.001m)
and TimeGenerated <= now()
| project columnifexists("ResultDescription", 'default_value')
| project JsonResult = parse_json(ResultDescription)
| evaluate bag_unpack(JsonResult) : (level:string)
| evaluate bag_unpack(JsonResult) : (level: string, message: string)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a time filter to the query to ensure it only processes recent logs, which can improve performance and relevance of the alert. [important]

| where level in ( 'ERROR' )
| summarize count()
QUERY

severity = 3
frequency = 10
time_window = 30
frequency = 5
time_window = 15
auto_mitigation_enabled = true

trigger {
operator = "GreaterThan"
operator = "GreaterThanOrEqual"
threshold = 1
}

Expand Down