Kusto Query Language (KQL) is a read-only query language developed by Microsoft for analyzing large volumes of structured, semi-structured, and unstructured data. Named after oceanographer Jacques Cousteau, it powers Azure Data Explorer, Azure Monitor Logs, Microsoft Sentinel, Microsoft 365 Defender, and Application Insights. KQL is optimized for telemetry, metrics, logs, and time-series analysis, providing powerful operators for aggregation, filtering, visualization, and machine learning directly in the query layer. Unlike SQL, KQL uses a pipe-based syntax that flows data transformations left-to-right, making queries readable and composable. Understanding KQL's tabular operators, scalar functions, graph semantics, and query optimization patterns is essential for security analysts, data engineers, and cloud practitioners working with Microsoft's data analytics ecosystem.
What This Cheat Sheet Covers
This topic spans 26 focused tables and 214 indexed concepts, 146 flashcards. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
A jump-to index of every table row in this cheat sheet.
An interactive map of every table and concept in this topic.
Table 1: Basic Query Structure
Every KQL query begins with a table name and pipes data through a chain of operators that filter, shape, and trim the result left-to-right. These are the building blocks you reach for constantly β where to cut rows, project to pick columns, take/top to cap output β and ordering them well (filter early, project early) is the difference between a snappy query and one that scans everything.
| Operator | Example | Description | |
|---|---|---|---|
SecurityEvent | Returns all records from a table β the starting point for every KQL query. | ||
SecurityEvent | where TimeGenerated > ago(1d) | β’ Chains operators together β’ data flows left-to-right through transformations. | ||
T | where EventID == 4625 | β’ Filters rows based on a boolean predicate β’ always apply early for performance. | ||
T | project TimeGenerated, Account | β’ Selects specific columns to include β’ reduces output width and improves query speed. | ||
T | project-away TenantId, _ResourceId | β’ Excludes specified columns from output β’ inverse of project β keeps all except the listed columns. | ||
T | project-keep Time*, Computer | β’ Keeps specified columns (supports wildcards) β’ unlike project, preserves original column order. | ||
T | project-rename Device = Computer | Renames columns without dropping or reordering any other columns. | ||
T | project-reorder TimeGenerated, Computer, * | β’ Moves specified columns to the front β’ * fills in the remaining columns in original order. | ||
T | extend Duration = EndTime - StartTime | Creates calculated columns without removing existing ones. | ||
search in (SecurityEvent, Heartbeat) "error" | β’ Searches for a term across all columns in specified tables β’ useful for exploration, slower than where. | ||
T | take 100 | β’ Returns N rows (order not guaranteed) β’ limit is an alias with identical behavior. | ||
T | top 10 by EventCount desc | β’ Returns the top N rows by a sorted column β’ more efficient than sort + take. | ||
T | sort by TimeGenerated desc | β’ Orders rows β’ order by is an alias with identical behavior. | ||
T | distinct ComputerName | β’ Returns unique combinations of specified columns β’ removes duplicate rows. | ||
T | count | Returns the total row count as a single value. | ||
T | getschema | β’ Returns the column names and data types of a table β’ useful for exploration and debugging. |