Anomalies Unusual Anomaly
Query
let query_frequency = 1h;
let query_lookback = 3d;
let _MonitoredRules = toscalar(
_GetWatchlist('AlertName-SubstitutedDetections')
| where ProductName == "Anomalies"
| summarize make_list(AlertName)
);
Anomalies
| where TimeGenerated > ago(query_frequency)
| where not(replace_string(replace_string(RuleName, "(Preview) ", ""), " - Customized", "") in (_MonitoredRules))
| join kind = leftanti (
Anomalies
| where TimeGenerated between (ago(query_frequency + query_lookback) .. ago(query_frequency))
| distinct RuleName
) on RuleNameExplanation
This KQL query is designed to identify specific anomaly detection rules that have generated alerts within the last hour but have not done so in the previous three days. Here's a breakdown of what the query does:
-
Parameters Definition:
query_frequencyis set to 1 hour, indicating the recent time window for analysis.query_lookbackis set to 3 days, representing the historical period to compare against.
-
Watchlist Retrieval:
- It retrieves a list of monitored alert names from a watchlist named 'AlertName-SubstitutedDetections' where the product name is "Anomalies".
-
Current Alerts Filtering:
- It filters the
Anomaliestable to include only those alerts generated in the last hour (query_frequency).
- It filters the
-
Exclusion of Monitored Rules:
- It excludes alerts whose rule names, after removing "(Preview) " and " - Customized" from their names, are present in the monitored rules list.
-
Historical Comparison:
- It performs a left anti join with another set of
Anomaliesdata, which includes distinct rule names from the past 3 days up to 1 hour ago. - This step ensures that only rules that have not generated alerts in the previous 3 days are considered.
- It performs a left anti join with another set of
In summary, the query identifies anomaly detection rules that have triggered alerts in the last hour but did not trigger any alerts in the preceding three days, excluding certain monitored rules.
Details

Jose Sebastián Canós
Released: November 25, 2024
Tables
Anomalies
Keywords
AnomaliesAlertNameProductNameRuleNameTimeGenerated
Operators
lettoscalarwheresummarizemake_listagoreplace_stringinjoinkindbetweendistinct