KQL Library


A browsable catalog of KQL queries for Microsoft Sentinel, Defender XDR, and Log Analytics.

A running library of deceptively simple KQL.

DevSecOpsDad

The KQL Library.

The queries I keep coming back to whenever a complicated problem shows up in Microsoft Sentinel, Defender XDR, or Log Analytics. Grouped by what they answer, each one shipped with the description of when to reach for it.


Type to search all queries, or pick a category below.

Analytics Rules 19 queries Queries designed (or used) as the body of a Sentinel Analytics Rule — they're written to produce discrete detection events on a schedule rather than to be run interactively. Cost & Ingest 26 queries The FinOps side of Sentinel and Log Analytics — how much you're ingesting, where it's coming from, and what it's costing you. Everything here targets the `Usage` table, `_BilledSize`, or specific noisy sources. Email & Phishing 6 queries Defender for Office 365 queries against `EmailEvents` — phishing volume, malware, and external-account abuse patterns. Health Checks 2 queries Meta-queries about the workspace itself — is your detection stack actually working, and what's it firing on? Hunting 32 queries Ad-hoc investigative queries. These aren't packaged as Sentinel Analytics Rules — they're the "let me pull on this thread" queries you reach for during triage, incident response, or when a stakeholder asks a specific question. Identity 3 queries Entra ID, Active Directory, and PIM activity queries — who did what to whom, when. MITRE ATT&CK 2 queries Queries that summarize what's been observed in the environment against the MITRE ATT&CK matrix. Pi-hole 9 queries Queries against Pi-hole DNS data ingested into a Log Analytics workspace (as a custom `PiHole` / `pihole_CL` table). Useful for home-lab telemetry, DNS-based hunting practice, and workshop material. Posture 4 queries Attack-surface and asset-posture queries — the inventory-style queries that hand you a finite, closable list rather than an infinite stream of adversary telemetry. Reference 1 query Teaching examples — queries kept because they illustrate a KQL concept rather than solve a specific operational problem. Reporting 3 queries Periodic-summary queries for stakeholder reporting — weekly, monthly, or quarterly. The "here's what happened this period and what changed" view.