Kusto Query Language (KQL) – quick reference

It is for the new KQL engineer to quick reference only.

KQL Work Flow

Quick reference

Operator/FunctionDescriptionSyntax
Filter/Search/ConditionFind relevant data by filtering or searching
whereFilters on a specific predicateT | where Predicate
where contains/hasContains: Looks for any substring match
Has: Looks for a specific word (better performance)
T | where col1 contains/has "[search term]"
searchSearches all columns in the table for the value[TabularSource |] search [kind=CaseSensitivity] [in (TableSources)] SearchPredicate
takeReturns the specified number of records. Use to test a query
Notetake and limit are synonyms.
T | take NumberOfRows
caseAdds a condition statement, similar to if/then/elseif in other systems.case(predicate_1, then_1, predicate_2, then_2, predicate_3, then_3, else)
distinctProduces a table with the distinct combination of the provided columns of the input tabledistinct [ColumnName], [ColumnName]
Date/TimeOperations that use date and time functions
agoReturns the time offset relative to the time the query executes. For example, ago(1h) is one hour before the current clock’s reading.ago(a_timespan)
format_datetimeReturns data in various date formats.format_datetime(datetime , format)
binRounds all values in a timeframe and groups thembin(value,roundTo)
Create/Remove ColumnsAdd or remove columns in a table
printOutputs a single row with one or more scalar expressionsprint [ColumnName =] ScalarExpression [',' ...]
projectSelects the columns to include in the order specifiedT | project ColumnName [= Expression] [, ...]
Or
T | project [ColumnName | (ColumnName[,]) =] Expression [, ...]
project-awaySelects the columns to exclude from the outputT | project-away ColumnNameOrPattern [, ...]
project-keepSelects the columns to keep in the outputT | project-keep ColumnNameOrPattern [, ...]
project-renameRenames columns in the result outputT | project-rename new_column_name = column_name
project-reorderReorders columns in the result outputT | project-reorder Col2, Col1, Col* asc
extendCreates a calculated column and adds it to the result setT | extend [ColumnName | (ColumnName[, ...]) =] Expression [, ...]
Sort and Aggregate DatasetRestructure the data by sorting or grouping them in meaningful ways
sort operatorSort the rows of the input table by one or more columns in ascending or descending orderT | sort by expression1 [asc|desc], expression2 [asc|desc], …
topReturns the first N rows of the dataset when the dataset is sorted using byT | top numberOfRows by expression [asc|desc] [nulls first|last]
summarizeGroups the rows according to the by group columns, and calculates aggregations over each groupT | summarize [[Column =] Aggregation [, ...]] [by [Column =] GroupExpression [, ...]]
countCounts records in the input table (for example, T)
This operator is shorthand for summarize count()
T | count
joinMerges the rows of two tables to form a new table by matching values of the specified column(s) from each table. Supports a full range of join types: fullouterinnerinneruniqueleftantileftantisemileftouterleftsemirightantirightantisemirightouterrightsemiLeftTable | join [JoinParameters] ( RightTable ) on Attributes
unionTakes two or more tables and returns all their rows[T1] | union [T2], [T3], …
rangeGenerates a table with an arithmetic series of valuesrange columnName from start to stop step step
Format DataRestructure the data to output in a useful way
lookupExtends the columns of a fact table with values looked-up in a dimension tableT1 | lookup [kind = (leftouter|inner)] ( T2 ) on Attributes
mv-expandTurns dynamic arrays into rows (multi-value expansion)T | mv-expand Column
parseEvaluates a string expression and parses its value into one or more calculated columns. Use for structuring unstructured data.T | parse [kind=regex [flags=regex_flags] |simple|relaxed] Expression with * (StringConstant ColumnName [: ColumnType]) *...
make-seriesCreates series of specified aggregated values along a specified axisT | make-series [MakeSeriesParamters] [Column =] Aggregation [default = DefaultValue] [, ...] on AxisColumn from start to end step step [by [Column =] GroupExpression [, ...]]
letBinds a name to expressions that can refer to its bound value. Values can be lambda expressions to create query-defined functions as part of the query. Use let to create expressions over tables whose results look like a new table.let Name = ScalarExpression | TabularExpression | FunctionDefinitionExpression
GeneralMiscellaneous operations and function
invokeRuns the function on the table that it receives as input.T | invoke function([param1, param2])
evaluate pluginNameEvaluates query language extensions (plugins)[T |] evaluate [ evaluateParameters ] PluginName ( [PluginArg1 [, PluginArg2]... )
VisualizationOperations that display the data in a graphical format
renderRenders results as a graphical outputT | render Visualization [with (PropertyName = PropertyValue [, ...] )]