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.
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?
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:
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: