Learn Kusto (KQL)

The query language of Microsoft Sentinel, Defender XDR and Azure Data Explorer. One page per operator or function, each with examples you can run.

Start with where, project, summarize · From SQL: KQL vs SQL · On one page: cheat sheet

Filter rows

whereKeep only the rows that match a condition
== vs =~Compare strings with exact case (==) or ignoring case (=~)
in / !in / in~Check whether a value is one of a list of values
betweenCheck whether a number or time is inside a range
isempty / isnotempty / isnullFind missing values: empty strings and nulls

Choose and shape columns

project / project-away / project-renamePick, rename, compute or drop columns
extendAdd a computed column and keep all the others
distinctList the unique values or combinations of columns

Aggregate with summarize

summarizeGroup rows and count, sum or average them
count / count() / countif()Count rows, in total, per group, or only those that match
dcount() / dcountif()Count how many different values there are
sum() / avg() / min() / max()Totals, averages, smallest and largest values per group
arg_max() / arg_min()The whole row with the largest or smallest value per group
make_set() / make_list()Collect the values of a group into one list

Sort and limit

sort by / order byOrder rows; descending unless you say asc
topThe first N rows by a column, descending by default
take / limitReturn some rows, with no order guaranteed

Combine tables

joinCombine rows from two tables that share a key
unionStack the rows of several tables into one result
letGive a name to a value or a sub-query, then reuse it

Strings and text

has vs containsWhole-term match (has) versus any substring (contains)
startswith / endswithCheck the beginning or the end of a string
matches regexMatch a string against a regular expression
extract()Pull part of a string out with a regular expression
split() / array_length()Cut a string into a list at a separator
strcat() / tolower() / toupper()Join strings together and change their case

Dates and times

ago() / now()Times relative to the current moment
datetime and timespanDate literals, time spans, date math and datetime_part()
bin() / floor()Round times or numbers down to an interval, for grouping

Logic and conversion

iff() / iif()Choose between two values based on a condition
case()Pick a value from several conditions, with a default
tostring() / toint() / todouble()Convert values between strings and numbers

Dynamic (JSON) data

dynamic columns and parse_json()Read properties and list items from JSON columns

Not supported yet: mv-expand, make-series, parse and more. The editor says so when you use them.