For Microsoft Defender and Microsoft Sentinel
Practise and learn KQL
KQL is the query language behind advanced hunting in Microsoft Defender XDR and log search in Microsoft Sentinel. Practise it with exercises written like the tickets you get on shift, on realistic lab data, and see straight away whether your query found the right rows.
DEFENDER · KQL
DeviceProcessEvents
| where Timestamp > ago(24h)
| where InitiatingProcessFileName =~ "outlook.exe"
| where FileName in~ ("powershell.exe", "cmd.exe")
Questions you’ll answer
Every exercise starts as a ticket. You write the query that answers it.
DeviceProcessEvents
| where Timestamp > ago(7d)
| where FileName =~ "powershell.exe"
| where ProcessCommandLine contains "-enc"
| project Timestamp, DeviceName, AccountName, ProcessCommandLine
SigninLogs
| where TimeGenerated > startofday(now())
| where ResultType != "0"
| summarize Failures = count() by UserPrincipalName
| top 10 by Failures
Where you’ll use it
- Microsoft Defender XDRCalled advanced hunting in the portal.
- Microsoft SentinelSame language as Defender, different tables.
What you’ll learn, from beginner to advanced
Twelve modules in three levels. Each one has a short lesson, questions to answer and then exercises.
Beginner
- Your first queryTables,
take,whereandproject, withago()for time. - Matching text
==and=~,has,contains,startswithandin~. - Sorting and limiting
sort by,topanddistinct. - Counting
count,summarize … byanddcount().
Intermediate
- Working with time
bin(),betweenand building a timeline. - Shaping results
extend,parse,extract()andstrcat(). - Joining tables
joinkinds like inner, leftouter and leftanti, andlookup. - Real investigationsProcess trees in Defender, sign-in patterns in Sentinel.
Advanced
- Reusable queries
let, user-defined functions andmaterialize(). - Nested data
parse_json(),mv-expandandbag_unpack. - Baselines and anomalies
make-seriesandarg_max()to find what’s unusual. - Fast queries at scaleFilter on time first, prefer
hastocontains, drop columns early.
Worth knowing before you start
==is case-sensitive and=~isn’t, so Outlook.EXE and outlook.exe are not the same to==.hasmatches whole words and is faster thancontains, which matches any part of the text.- Defender and Sentinel share the language but not the tables. Defender uses
Timestamp, Sentinel usesTimeGenerated.
Cheat sheet
Compare
Other languages
Be first in when it launches
KQL is one of the languages SOC Fluent launches with. Join the waitlist and we’ll email you once, on launch day.
Free to join. Students get 50% off at launch.