azureazureportalazure-alerts

Why can't I create an azure alert rule with a specific KQL query


I was tasked to create an alert rule for a specific VM using custom log search and with query from the client's parameter sheet:

Event
| where EventLog == "System"
| where EventLevelName == "Critical"
| where Computer == "testVM1"
| where TimeGenerated > ago(1m)

with 1 minute aggregation granularity and 1 minute frequency evaluation based from the client's parameter sheet. As expected, upon creation it threw an error:

Error: Failed to create alert rule test. One-minute frequency is not supported for this query. Either switch to five-minute frequency or adapt the query.

alert rule image

I also found out that there are certain limitations in creating alert rules with 1 minute frequency. I just can't understand how and why is the query not acceptable? can someone explain it to me step by step?


Solution

  • Creating an azure alert rule with a specific KQL query

    I had created the alert rule for a specific VM using custom log search. With the 1-minute aggregation granularity and 1 minute frequency of evaluation. I had work around in my environment the KQL query works fine

    Event
    | where EventLog == "System"
    | where EventLevelName == "Critical"
    | where Computer =="<Your VM Name>"
    | where TimeGenerated > ago(1m)
    | summarize EventCount = count()
    

    Output:

    enter image description here

    enter image description here

    enter image description here

    Sometimes Azure Monitor will not immediately trigger the alerts due to log data ingestion latency, Azure Monitor will take a minimum 5-minute evaluation frequency for log-based alerts to avoid unreliable or delayed alerts.

    Reference:

    Log data ingestion time in Azure Monitor