KQL playground

Write Kusto Query Language and run it in your browser against a week of Microsoft Sentinel and Defender XDR logs from a fictional company, with Microsoft's own table and column names.

What is this KQL playground?

Real KQL

Operators, functions and error messages like Kusto's. What you write here works in Sentinel and Defender. Microsoft's KQL reference ↗

A week of logs

Sign-ins, processes, network, email and Windows events from a fictional company, with Microsoft's tables.

Real infection data (Pro)

With HTK Pro, swap the practice data for documented incidents rebuilt event by event, with their investigation guide.

Run KQL in your browser

Try it with real infection dataPro

Unlock datasets from real incidents with investigation guides that use KQL, Wireshark and more.

How to write your first KQL query

KQL reads top to bottom: a table, then a chain of operators joined by a pipe (|), each one working on the result of the previous one.

  1. 1

    Start with a table

    Write the table name on the first line, for example SigninLogs. Every KQL query starts with the data source.

  2. 2

    Filter with where

    Add a line starting with | where to keep only what matters: | where ResultType != "0" keeps the failed sign-ins. ResultType is text, so the code goes in quotes.

  3. 3

    Choose columns with project

    | project TimeGenerated, UserPrincipalName, IPAddress shows only the columns you need, in that order.

  4. 4

    Count with summarize

    | summarize count() by IPAddress groups the rows and counts them: the IP that stands out is where you look next.

Tables you can query, with a query to start each one

The same tables and columns as Microsoft Sentinel and Defender XDR advanced hunting. Press Run and the query loads in the playground above.

Microsoft Entra ID

SigninLogs

Every Entra ID sign-in: who, from which IP and country, into which app and whether it worked.

  • UserPrincipalName
  • IPAddress
  • Location
  • ResultType
  • AppDisplayName
  • LocationDetails

Answers: Who fails to sign in and from where? Is there a password spray?

Failures per IP

SigninLogs
| where ResultType != "0"
| summarize Failures = count() by IPAddress
| top 5 by Failures
Windows · Sentinel

SecurityEvent

Windows security events: logons, processes, created accounts and group changes.

  • EventID
  • Computer
  • Account
  • LogonType
  • IpAddress
  • TargetAccount

Answers: Is there RDP brute force? Did someone create an account or clear the log?

Failed RDP logons

SecurityEvent
| where EventID == 4625 and LogonType == 10
| summarize count() by IpAddress, Computer
Defender for Endpoint

DeviceProcessEvents

Processes started on devices, with their command line and the parent process that launched them.

  • DeviceName
  • FileName
  • ProcessCommandLine
  • InitiatingProcessFileName
  • AccountName

Answers: Did Word launch PowerShell? What did that account run?

Office child processes

DeviceProcessEvents
| where InitiatingProcessFileName in~ ("winword.exe", "excel.exe")
| project Timestamp, DeviceName, FileName, ProcessCommandLine
Defender for Endpoint

DeviceNetworkEvents

Network connections made by each process: destination, port and whether it succeeded.

  • RemoteIP
  • RemotePort
  • RemoteUrl
  • ActionType
  • InitiatingProcessFileName

Answers: Which device talks to a server every few minutes (beaconing)?

Connections per hour

DeviceNetworkEvents
| summarize Connections = count() by bin(Timestamp, 1h)
| render timechart
Defender for Office 365

EmailEvents

Received email: sender, subject, verdict and whether it was delivered, junked or blocked.

  • SenderFromAddress
  • RecipientEmailAddress
  • Subject
  • DeliveryAction
  • ThreatTypes

Answers: Who received the phishing and who did the filter stop it for?

Delivered phishing

EmailEvents
| where ThreatTypes == "Phish" and DeliveryAction == "Delivered"
| project Timestamp, RecipientEmailAddress, Subject
Context for joins

IdentityInfo · DeviceInfo

The people directory (department, job title, roles) and the device inventory, to give context to the other tables.

  • AccountUPN
  • Department
  • AssignedRoles
  • OSPlatform
  • MachineGroup

Answers: Which department are the affected people in? Is any of them an admin?

Phishing by department

EmailEvents
| where ThreatTypes == "Phish"
| join kind=inner (IdentityInfo) on $left.RecipientEmailAddress == $right.AccountUPN
| summarize count() by Department

Practise with our platform and exercises

Free course

KQL from Zero

From your first query to joins and Sentinel detection rules, with guided labs in this console and a final exam.

Start for free →Create a free account and save your progress
HTK Pro

Every lab · €14.99/month

  • Every KQL and Wireshark lab, full incidents included
  • The SOC simulators with KQL advanced hunting
  • Course videos and certificates
See HTK Pro

KQL cheat sheet for threat hunting →

Learn it with “KQL from Zero”, free

This is what it looks like inside: short lessons and, in every lab, the same tool as on this page with a concrete task, a question that marks itself and hints if you get stuck. With a free account and no card.

  • Every task tells you what to look for and why it matters
  • Hints when you get stuck, without giving the answer away
  • XP, a final exam and a course certificate
  • Pick up where you left off, from any device

More free courses

See every free course →
IntroductoryFree

SOC Analyst: Your First Shift

The L1 analyst's job taught as the work itself. You read the six fields every alert has, answer the four triage questions in order, prioritise a full queue and enrich indicators without tipping off the attacker. You practise the cases you will see most (a reported email, an EDR detection, night-time beaconing, an impossible logon) and write escalation tickets L2 accepts.

2 guided labs · 6 h of content

FreeView course →
IntroductoryFree

Wireshark from Zero

Wireshark from the first capture, with nothing to install. You learn to get around the interface, write display filters and tell them from capture filters, follow a TCP conversation and read DNS, HTTP and TLS. You finish using the statistics and Expert Information to find a scan, ARP spoofing and a data leak in a simulated Wireshark in the browser.

8 guided labs · 3.5 h of content

FreeView course →
IntroductoryFree

Introduction to Cybersecurity

Your starting point if you have never worked in security. You learn the CIA triad and use it to reason about any incident, see how ransomware, stealers and phishing reach their victims, and take a real phishing email apart: headers, SPF/DKIM/DMARC, links and domain. It closes with a map of the specialisms so you can choose your next step with some basis.

2 guided labs · 4.5 h of content

FreeView course →

Career track

This tool is part of the SOC Analyst track

Querying the SIEM to confirm or dismiss an alert is a SOC analyst's daily work. The track takes you from zero to that job, with the alert queue, the report and the escalation.

21 courses · 41 h · about 8 weeks at an hour a day

See the full track →

Frequently asked questions

Yes, here. This playground runs the queries in your own browser on sample data, so you need no Azure subscription, no Log Analytics workspace and no account.

Yes. Tables, columns and operators have the same names, so a query you write here works there unchanged. It supports the everyday subset: where, project, extend, summarize, sort, top, take, distinct, search, let, union, join, render and the usual date and text functions.

No. It only loads the sample dataset, so nothing of yours leaves your computer. To query your own data, use Log Analytics in Azure or the free Azure Data Explorer cluster.

To search and analyse logs in Microsoft Sentinel, Defender XDR advanced hunting, Azure Monitor and Azure Data Explorer. SOC analysts use it to investigate alerts and write detection rules; administrators, to troubleshoot.

Yes: a password spray, an impossible-travel sign-in, a phishing campaign, a malicious macro, a beaconing device and RDP brute force on a server. The free course guides you through them in its labs.

With the free KQL from Zero course: four modules from the first query to joins and detection rules, with labs in this console. For a quick reference, the KQL cheat sheet for threat hunting on the blog.

From running queries to writing detections

The free course teaches KQL from zero, with guided labs in this same console and a final exam.