KQL for Detection and Threat Hunting
Master KQL for Detection and Threat Hunting
Write powerful, efficient KQL queries that turn massive amounts of security data into fast, actionable insights. Master Kusto Query Language to hunt threats, build high-fidelity detections, investigate incidents, and automate response; all inside Microsoft Sentinel, Defender XDR, and Log Analytics.
What you'll be able to do
Course Syllabus
Every module and every lesson. Open a module to see its lessons.
Download the full syllabus (PDF)
Phase 1: Anatomy of KQL
What KQL for Detection and Threat Hunting teaches: the query language behind every hunt, detection, and investigation in Microsoft Sentinel, Defender XDR, and Log Analytics.
8 lessonsHide lessons
- 0.1 Three Questions You Cannot Answer Without KQLPreview
- 0.2 The Microsoft Security Data ModelPreview
- 0.3 The Eight Tables You Will Query Every DayPreview
- 0.4 Your First Security QueryPreview
- 0.5 What This Course BuildsPreview
- 0.6 Setting Up Your Lab EnvironmentPreview
- Module SummaryPreview
- Check My KnowledgePreview
The tabular data model, the query pipeline, every data type, type conversion, and null handling.
Master every where operator, string comparison, datetime filter, extend pattern, and project variant.
Every summarize function, time-based grouping with bin, set and list aggregations, ordering and limiting, and pivot patterns.
Phase 2: Intermediate Techniques
Every join flavour with performance implications, union for combining tables, lookup for enrichment, and cross-table investigation patterns that trace attacks across data sources.
9 lessonsHide lessons
- 4.1 Join Fundamentals. Combining Rows from Two Tables
- 4.2 Join Flavours. Choosing the Right Join for Every Investigation
- 4.3 Join Performance. Why Joins Are Expensive and How to Control the Cost
- 4.4 Union. Combining Rows from Multiple Tables
- 4.5 Lookup. Lightweight Enrichment Without Full Join Overhead
- 4.6 Cross-Table Investigation Patterns. Tracing Attacks Across Data Sources
- 4.7 Materialize and Let. Reusing Results Across Complex Queries
- Module Summary
- Check My Knowledge
Parse, extract, parse_json, string manipulation, URL decomposition, and building log parsers.
8 lessonsHide lessons
- 5.1 The parse Operator. Extracting Structure from Unstructured Strings
- 5.2 extract and extract_all. Regex-Based Extraction
- 5.3 parse_json and Dynamic Nested Data
- 5.4 String Functions, split, substring, replace, and Transformation
- 5.5 URL and Email Decomposition for Threat Analysis
- 5.6 Building Custom Log Parsers
- Module Summary
- Check My Knowledge
Regular expressions, dynamic arrays with mv-expand and mv-apply, the let statement, user-defined functions, and externaldata.
8 lessonsHide lessons
- 6.1 mv-expand and mv-apply. Working with Dynamic Arrays
- 6.2 Advanced Regex Patterns for Security Analysis
- 6.3 let Statements and User-Defined Functions
- 6.4 externaldata. Querying External Reference Files
- 6.5 IP Range Functions and CIDR Matching
- 6.6 Watchlist-Driven Detection Patterns
- Module Summary
- Check My Knowledge
Phase 3: Advanced Patterns
Make-series, series decomposition, automated anomaly detection, statistical analysis, baseline comparison patterns, and building anomaly detection rules from raw logs.
8 lessonsHide lessons
- 7.1 make_series. Converting Events into Time-Series Data
- 7.2 series_decompose. Separating Trend, Seasonal, and Residual Components
- 7.3 series_decompose_anomalies. Automated Anomaly Detection
- 7.4 Baseline Comparison Patterns. Per-Entity Behavioral Profiles
- 7.5 Rate-of-Change Detection and Sliding Windows
- 7.6 Building Anomaly Detection Rules for Production
- Module Summary
- Check My Knowledge
Entity relationships, attack path reconstruction, network graph patterns, identity mapping, and recursive multi-hop investigation queries.
Query engine internals, performance analysis, materialized views, optimizing for large datasets, common anti-patterns, and writing queries that scale from development to production.
8 lessonsHide lessons
- 9.1 Query Engine Internals. How KQL Executes Your Queries
- 9.2 Common Anti-Patterns That Kill Performance
- 9.3 Partition Pruning and Term Indexing
- 9.4 Materialized Views and Stored Functions
- 9.5 Optimizing Joins and Time-Series Queries at Scale
- 9.6 Query Limits, Diagnostics, and Performance Monitoring
- Module Summary
- Check My Knowledge
Phase 4: Mastery
Converting investigation queries into production detection rules.
8 lessonsHide lessons
- 10.1 From Investigation Query to Detection Rule
- 10.2 Scheduled vs NRT Rules. Choosing the Right Rule Type
- 10.3 Entity Mapping and Alert Enrichment
- 10.4 Threshold Tuning and False Positive Management
- 10.5 Multi-Condition Correlated Detection
- 10.6 Detection Rule Testing and Validation
- Module Summary
- Check My Knowledge
Hypothesis-driven hunting methodology, MITRE ATT&CK hunting, behavioral hunting with baseline deviation and peer group analysis, IOC sweeps, and building a reusable hunting query library.
9 lessonsHide lessons
- 11.1 Hypothesis-Driven Hunting Methodology
- 11.2 MITRE ATT&CK-Aligned Hunting
- 11.3 Behavioral Hunting with Baselines and Peer Groups
- 11.4 IOC and Retroactive Sweeps
- 11.5 Hunt Management, Bookmarks, and Evidence
- 11.6 Building and Maintaining a Hunting Query Library
- Module Summary
- Check My Knowledge
- 11.9 Mini Capstone. The Live Hunt Exercise
KQL for Sentinel workbooks with parameterized queries, building the security operations dashboard, executive reporting queries, and automated report generation.
Phase 5: Capstone
Three complete hunting scenarios that test every skill from the course.
Phase 0: Course Resources
Seventy-four queries across ten subject-area sheets, each with the operators it turns on and what the result does not establish.
Five procedures for the recurring problems, worked against documented platform behavior: ingestion lag, table plans, memory and truncation limits, service limits on rules, and transformation constraints.
A Log Analytics workspace you build and populate yourself, free, with the activity each module's queries need and the verification that proves it holds data.
1 lessonsHide lessons
Ten investigations worked end to end with the output at every step, each turning on a failure that produces no error message: queries that return nothing, too few rows, or exactly the right answer to the wrong question.
10 lessonsHide lessons
- Building a Query From a Question
- When the Join Lies
- The Baseline That Learned the Attack
- The Query That Timed Out
- The Parse That Half Worked
- Reconstructing the Process Tree
- The Rule That Fired Four Thousand Times
- The Hunt That Proved Nothing
- The Dashboard That Improved
- Capstone: Spray to Business Email Compromise
Five query patterns by investigative question, each built on the function KQL actually provides for it, with the constraint that decides the design and the false positives it will produce.
Resources for practicing KQL and using it at work: the detection library, a free-run query console, guided investigations, response playbooks, and an open-source DFIR toolkit.
External sources this course draws on: Microsoft KQL documentation, the language reference, and community query material.
Course Completion
KQL for Detection and Threat Hunting end-of-course exam: a three-phase simulation testing whether you can apply the method to a situation the course did not walk through.
1 lessonsHide lessons
Course overview
The KQL for Detection and Threat Hunting course is the core training track for Security Engineers, Detection Engineers, and Threat Hunters who use KQL daily. You'll gain hands-on expertise to:
By the end, you'll have the confidence and fluency to use KQL as a powerful daily tool, dramatically improving your threat detection, hunting speed, and security operations effectiveness.
How this course works
KQL is a query language, and most people learn it as a set of examples to copy. This course teaches the execution model first, because every performance problem and every wrong answer downstream is a model problem.
1. Understand how the query is processed. Data flows left to right through operators. Where you filter decides both what you get and what it costs.
2. Filter before you shape. The cheapest query is the one that discards rows early. This is the single habit that separates a query that runs at scale from one that times out.
3. Aggregate to answer a question, not to summarize. A summarize with no hypothesis behind it produces a table nobody reads. Know what the number is for before computing it.
4. Join only when the answer needs two sources. Joins are the most expensive thing in the language and the most reached for. Most correlation problems are a filter and a lookup.
5. Turn the query into something that runs without you. A detection rule, a workbook or a scheduled hunt. A query that lives in somebody's notes is a query that runs once.
What this course assumes
No minimum experience and no prerequisite course. The language is built from the first query onward, and the course assumes no prior SQL.
What makes it go faster: access to a Sentinel workspace or Defender advanced hunting with real data. Not required, because every query in the course runs against the Practice Hub, which holds populated tables and known answers.
What this course does not cover: incident response process, detection engineering as a program, and SIEM administration. This is the query language, taught to the depth where you stop copying examples.
Who this course is for
You're a Security Engineer, Detection Engineer, or Threat Hunter who uses KQL daily and wants to move from functional to expert level. This course is built for you if you want to:
In short: if you're ready to become the go-to KQL expert on your team and significantly level up your threat detection and hunting capabilities, this course is for you.
What you'll learn
By the end of this KQL for Detection and Threat Hunting course you will be able to:
Key course takeaways
Things you need to know
What are the prerequisites for this course?
There are no prerequisites. The course teaches KQL from first principles. Familiarity with any query language (SQL, SPL, EQL) will help you move faster, but is not required. Every operator and function is explained at first use with security log examples.
What are the device requirements?
A device with a modern browser. Access to a Microsoft 365 E5 tenant (a developer subscription if you qualify for one, otherwise a 30-day E5 trial) or a Sentinel workspace for hands-on query execution. The course walks you through setup in Module 0.
How will the course benefit your career?
KQL is the query language that powers Microsoft Sentinel, Defender XDR, and Log Analytics. Every detection rule, hunting query, investigation pivot, and operational dashboard runs on KQL. This course gives you the fluency to write queries from scratch, debug them when they fail, and optimize them for production scale.
KQL proficiency is a prerequisite for detection engineering, threat hunting, and advanced security operations roles across the Microsoft ecosystem.
Usage rights and disclaimer
Course materials: Licensed for individual professional development. You may deploy queries, detection rules, and workbooks in your production environment. You may not redistribute course content or share account credentials.
Fictional environment: All scenarios use Northgate Engineering. Any resemblance to real organizations is coincidental.
Version and changelog
Current version: 1.1 | Last updated: June 2026
June 2026, v1.1: Course renamed to KQL for Detection and Threat Hunting.
June 2026, v1.0: Course page restructured. 14 modules from KQL fundamentals through production detection engineering, threat hunting, and the capstone hunting lab.
This course is actively maintained. Content is updated as the KQL language and Microsoft security data model evolve.
End of Course Exam
Complete the course, then prove your skills under time pressure. Pass mark: 70. Earn your certificate with CPE credits.
Requires 80% course completion. One random scenario per attempt. Certificate issued on pass.