Kusto Query Language (KQL)
Kusto Query Language (KQL) is a read-only query language for searching and aggregating log and telemetry data in Azure Monitor, Application Insights, Microsoft Sentinel, and Azure Data Explorer. It chains operators with the pipe character, so each step transforms the output of the previous one.
Kusto Query Language (KQL)
A KQL query starts with a table name and pipes it through operators such as where, project, summarize, and order by, reading naturally from left to right. It is built for time-series and event data, with native support for time bucketing, string parsing, and visualisations. It cannot modify data, which makes it safe for broad access.
How Do You Write a Basic KQL Query?
Filter by time first, then narrow, then aggregate. This query counts server errors per service in the last hour.
AppRequests| where TimeGenerated > ago(1h)| where ResultCode startswith "5"| summarize ErrorCount = count() by AppRoleName| order by ErrorCount descWhich KQL Operators Should You Learn First?
- where: Filters rows by a condition.
- project: Chooses and renames columns.
- extend: Adds a calculated column.
- summarize: Aggregates, such as count() or avg(), with optional grouping.
- bin(): Buckets timestamps, for example into 5-minute intervals.
- render: Draws a chart such as a timechart.
Why It Matters in Production
An on-call engineer at a company like Swiggy can save the query above and run it during an incident to see which service is failing in seconds, instead of searching raw logs by hand.
TipPut the
TimeGeneratedfilter first and filter on columns before joining. This lets the engine skip data and makes queries faster and cheaper to run.
Common MistakeRunning unbounded
search *queries across a large workspace. They scan everything and are slow, so name the table and a time range.
Frequently Asked Questions
Is KQL the same as SQL?
No. KQL uses a pipe-based flow and is read-only, while SQL uses nested clauses and can modify data. KQL has built-in operators for time series, parsing, and anomaly detection that SQL lacks.
Where can I run KQL queries?
In the Logs blade of a Log Analytics workspace or Application Insights, in Microsoft Sentinel, and in Azure Data Explorer. The tables differ but the language is the same.
Why is my KQL query slow?
Usually a missing or late time filter, a wide join, or too many columns carried through. Filter early and use project to keep only the columns you need.