Advanced hunting uses Kusto Query Language (KQL) to query endpoint and cross-domain telemetry proactively. Results can reveal indicators, affected entities, behavior patterns, and candidates for custom detection rules.
DeviceProcessEvents
| where Timestamp > ago(7d)
| where FileName =~ "powershell.exe"
| where ProcessCommandLine has_any ("downloadstring", "invoke-webrequest")
| project Timestamp, DeviceName, AccountName, ProcessCommandLine
| top 100 by Timestamp desc
- Filter time and high-selectivity columns early.
- Prefer
has for whole tokens over contains. - Project only required columns before joins.
- Place the smaller table on the left side of a join.
Exam takeaway: hunting is proactive; custom detections operationalize a useful query so it runs automatically.
Official lessonKQL hunting and query performance