SHA-256 with RSA :👈 👉:Deployment Rings

Kusto Query Keywords

Complete KQL (Kusto Query Language) Keywords and Operators

KQL stands for Kusto Query Language. Kusto’s official name is Azure Data Explorer or ADE. The short way to write ADE is ADX.
It is used in:

  • Azure Data Explorer
  • Azure Monitor
  • Log Analytics
  • Application Insights
  • Microsoft Sentinel
  • Microsoft Fabric (Real-Time Intelligence)

KQL is case-sensitive for everything - table names, table column names, operators, functions, and so on. Keywords can be used as identifiers by enclosing them in brackets and quotes ([' and '] or [" and "]). For example, ['where'].

KQL has several categories of language elements:

  • Query operators – where, project, summarize, extend.
  • Logical operators – and, or, not.
  • Comparison operators – ==, !=, contains, in.
  • Scalar functions – iff(), ago(), case(), now().
  • Aggregation functions – count(), sum(), avg().
  • Management commands – .create, .show, .alter.

1. Tabular Query Operators

A. Filtering and Searching

OperatorPurposeExample
whereFilters rows based on a condition| where Age > 20
filterAlias for filtering| filter Age > 20
searchSearches across columns or tablessearch "Azure"
findSearches across specified tablesfind in (Table1) "Azure"
takeReturns a specified number of rows| take 10
limitAlias for take| limit 10
sampleReturns a random sample| sample 100
getschemaReturns the schema of the input| getschema

B. Selecting and Modifying Columns

OperatorPurposeExample
projectSelects specific columns| project Name, Age
project-awayRemoves specified columns| project-away Password
project-keepKeeps specified columns| project-keep Name, Age
project-renameRenames columns| project-rename UserName = Name
project-reorderChanges column order| project-reorder Age, Name
extendCreates calculated columns| extend Total = Price * Quantity
evaluateInvokes a plugin or query extension| evaluate bag_unpack(Data)
serializeMarks rows as serialized| serialize

C. Sorting and Ranking

OperatorPurposeExample
sortSorts rows| sort by Age asc
orderAlias for sorting| order by Age desc
topReturns top N rows| top 10 by Score desc
top-hittersReturns most frequent values using an approximate algorithm| top-hitters 10 of UserId
top-nestedReturns top values in hierarchical groups| top-nested 3 of Category by count()
partitionExecutes a subquery for each partition| partition by Region (...)

D. Grouping and Aggregation

OperatorPurposeExample
summarizeGroups and aggregates records| summarize count() by Country
countCounts rows| count
distinctReturns unique values| distinct Country
make-seriesCreates time-series data| make-series count() on Timestamp
scanPerforms stateful row-by-row calculations| scan declare (...) with (...)

E. Joining and Combining Tables

OperatorPurposeExample
joinCombines two tables based on matching columnsT1 | join kind=inner T2 on UserId
lookupEnriches a table using a lookup tableT1 | lookup T2 on UserId
unionCombines rows from multiple tablesunion Table1, Table2
asAssigns a name to a tabular expressionT1 | as MyTable

F. Expanding and Restructuring Data

OperatorPurposeExample
mv-expandExpands arrays into multiple rows| mv-expand Items
mv-applyApplies a subquery to array elements| mv-apply Items on (...)
parseExtracts values using a parsing pattern| parse Message with * "ID=" Id
parse-whereParses and retains successfully matched rows| parse-where Message with ...
reduceCombines similar string values into patterns| reduce by Message

G. Set Operations

OperatorPurpose
unionCombines records from multiple datasets
intersectReturns common elements
exceptReturns elements present in one set but not another

H. Other Useful Operators

OperatorPurpose
printCreates a table from scalar expressions
datatableCreates an inline table with specified columns and values
rangeGenerates a sequence of values
externaldataReads data from an external source
invokeInvokes a function on tabular input
forkCreates multiple branches from the same input
consumeConsumes input without returning its rows

2. Comparison Operators

OperatorMeaningExample
==Equal toAge == 25
!=Not equal toAge != 25
<>Not equal toAge <> 25
>Greater thanAge > 25
<Less thanAge < 25
>=Greater than or equalAge >= 25
<=Less than or equalAge <= 25
=~Case-insensitive equalityName =~ "john"
!~Case-insensitive inequalityName !~ "john"
inMatches any value in a listStatus in ("Active", "Pending")
!inDoes not match values in a listStatus !in ("Failed", "Error")
in~Case-insensitive membershipName in~ ("john", "peter")
!in~Case-insensitive exclusionName !in~ ("john", "peter")
betweenChecks an inclusive rangeAge between (20 .. 30)
!betweenChecks outside a rangeAge !between (20 .. 30)
containsContains a substring, case-insensitiveName contains "john"
!containsDoes not contain a substringName !contains "john"
contains_csCase-sensitive substring searchName contains_cs "John"
hasContains a complete termMessage has "error"
!hasDoes not contain a complete termMessage !has "error"
has_csCase-sensitive term matchingMessage has_cs "Error"
startswithStarts with textName startswith "A"
!startswithDoes not start with textName !startswith "A"
startswith_csCase-sensitive starts withName startswith_cs "A"
endswithEnds with textName endswith ".NET"
!endswithDoes not end with textName !endswith ".NET"
endswith_csCase-sensitive ends withName endswith_cs ".NET"
matches regexMatches a regular expressionName matches regex @"^[A-Z]"
has_anyContains any specified termMessage has_any ("error", "failed")
has_allContains all specified termsMessage has_all ("error", "timeout")
contains_anyContains any specified substringMessage contains_any ("err", "fail")

Difference Between contains and has

// Finds the substring "err"
Logs
| where Message contains "err"
// Finds the complete term "error"
Logs
| where Message has "error"

Important: has is generally more efficient when searching for complete terms because it can use the term index.

3. Logical Operators

OperatorMeaningExample
andBoth conditions must be trueAge > 18 and Age < 60
orAt least one condition must be trueStatus == "Active" or Status == "Pending"
notNegates a conditionnot(Status == "Failed")
!Logical NOT!IsActive

Example based on SSR:

TableName
| where DeploymentMode !contains "Halt"
    and DeploymentMode !contains "SkipSDP"

Both conditions must be satisfied.

4. Arithmetic Operators

OperatorMeaningExample
+AdditionPrice + Tax
-SubtractionPrice - Discount
*MultiplicationPrice * Quantity
/DivisionTotal / Count
%Modulus (remainder)Number % 2

Example:

Products
| extend TotalPrice = Price * Quantity
| extend FinalPrice = TotalPrice - Discount

5. Assignment and Column Definition Symbols

SymbolPurposeExample
=Assigns a value or defines a calculated columnextend Total = 100
==Compares two valuesAge == 25
:Separates column names and data types in schemasName:string
,Separates expressions or columnsproject Name, Age
;Separates query statementslet x = 10; print x
|Passes output to the next operatorTable | where Age > 20
()Groups expressions or supplies function argumentsago(5d)
[]Accesses dynamic properties or array elementsData["Name"]
{}Defines function bodies and query blocksFunction body
..Defines a rangebetween (1 .. 10)
*Wildcard in supported contextsproject *

6. Conditional and Control-Flow Functions

FunctionPurposeExample
iff()Returns a value based on a conditioniff(Age > 18, "Adult", "Minor")
iif()Alternative name for conditional evaluationiif(Age > 18, "Adult", "Minor")
case()Evaluates multiple conditionscase(Age > 60, "Senior", Age > 18, "Adult", "Other")
coalesce()Returns the first non-null valuecoalesce(Value1, Value2, 0)
isnull()Checks whether a value is nullisnull(Name)
isnotnull()Checks whether a value is not nullisnotnull(Name)
isempty()Checks whether a string is emptyisempty(Name)
isnotempty()Checks whether a string is not emptyisnotempty(Name)
isblank()Checks whether a string is empty or whitespaceisblank(Name)
isnotblank()Checks whether a string is not empty or whitespaceisnotblank(Name)
toscalar()Converts a one-value tabular result into a scalartoscalar(T | count)
typeof()Returns the type of an expressiontypeof(123)

7. String Functions

FunctionPurposeExample
strcat()Concatenates stringsstrcat("Hello", " World")
strcat_delim()Joins strings with a delimiterstrcat_delim("-", A, B)
strlen()Returns string lengthstrlen(Name)
substring()Extracts part of a stringsubstring(Name, 0, 5)
tolower()Converts to lowercasetolower(Name)
toupper()Converts to uppercasetoupper(Name)
trim()Removes specified characters at both endstrim(" ", Name)
replace_string()Replaces a substringreplace_string(Text, "old", "new")
replace_regex()Replaces text using regexreplace_regex(Text, @"\d+", "")
split()Splits a string into an arraysplit(Name, ",")
extract()Extracts text using regexextract(@"ID=(\d+)", 1, Text)
extract_all()Extracts all regex matchesextract_all(@"[0-9]+", Text)
parse_json()Parses JSON textparse_json(JsonText)
parse_url()Parses a URLparse_url(Url)
indexof()Finds the position of a substringindexof(Name, "abc")
reverse()Reverses a stringreverse(Name)
translate()Replaces individual characterstranslate("abc", "ab", "xy")
url_encode()URL-encodes a stringurl_encode(Name)
url_decode()Decodes a URL-encoded stringurl_decode(Name)

8. Date and Time Functions

FunctionPurposeExample
now()Current UTC date and timenow()
ago()Date/time in the pastago(30d)
datetime()Creates a datetime valuedatetime(2026-11-16)
datetime_add()Adds a time intervaldatetime_add("day", 5, Date)
datetime_diff()Calculates difference between datesdatetime_diff("day", End, Start)
datetime_part()Extracts a date/time componentdatetime_part("year", Date)
dayofmonth()Gets day of monthdayofmonth(Date)
dayofweek()Gets day of weekdayofweek(Date)
dayofyear()Gets day of yeardayofyear(Date)
getyear()Gets yeargetyear(Date)
getmonth()Gets monthgetmonth(Date)
hourofday()Gets hourhourofday(Date)
startofday()Beginning of daystartofday(now())
endofday()End of dayendofday(now())
startofweek()Beginning of weekstartofweek(now())
endofweek()End of weekendofweek(now())
startofmonth()Beginning of monthstartofmonth(now())
endofmonth()End of monthendofmonth(now())
startofyear()Beginning of yearstartofyear(now())
endofyear()End of yearendofyear(now())
format_datetime()Formats datetime as textformat_datetime(now(), "yyyy-MM-dd")
todatetime()Converts value to datetimetodatetime(DateText)
totimespan()Converts value to timespantotimespan("5.00:00:00")
unixtime_seconds_todatetime()Converts Unix seconds to datetimeunixtime_seconds_todatetime(UnixTime)
datetime_utc_to_local()Converts UTC to local timedatetime_utc_to_local(Date, "India Standard Time")

Example based on SSR:

TableName
| where ValidFrom > ago(30d)
| extend DaysElapsed = datetime_diff("day", now(), ValidFrom)
| where DaysElapsed > 9

9. Aggregation Functions

FunctionPurposeExample
count()Counts recordssummarize count()
countif()Counts records matching a conditionsummarize countif(Age > 18)
sum()Calculates totalsummarize sum(Amount)
sumif()Calculates conditional totalsummarize sumif(Amount, Status == "Success")
avg()Calculates averagesummarize avg(Price)
min()Finds minimumsummarize min(Price)
max()Finds maximumsummarize max(Price)
dcount()Estimates distinct countsummarize dcount(UserId)
dcountif()Estimates conditional distinct countsummarize dcountif(UserId, Active)
make_set()Creates an array of distinct valuessummarize make_set(Name)
make_list()Creates an array of valuessummarize make_list(Name)
make_bag()Creates a property bagsummarize make_bag(pack("id", Id))
percentile()Calculates a percentilesummarize percentile(Duration, 95)
percentiles()Calculates multiple percentilessummarize percentiles(Duration, 50, 95)
stdev()Calculates standard deviationsummarize stdev(Price)
variance()Calculates variancesummarize variance(Price)
arg_max()Returns the row with maximum valuesummarize arg_max(Timestamp, *) by UserId
arg_min()Returns the row with minimum valuesummarize arg_min(Timestamp, *) by UserId
any()Returns an arbitrary valuesummarize any(Name)
take_any()Returns arbitrary recordssummarize take_any(*) by UserId
count_distinct()Counts distinct values exactly, where supportedsummarize count_distinct(UserId)

Example:

Orders
| summarize
    TotalOrders = count(),
    TotalAmount = sum(Amount),
    AverageAmount = avg(Amount),
    MaximumAmount = max(Amount)
    by CustomerId

10. Data Conversion Functions

FunctionConverts Value Into
tostring()String
toint()Integer
tolong()Long integer
toreal()Real number
todouble()Double
todecimal()Decimal
tobool()Boolean
todatetime()Date/time
totimespan()Time interval
toguid()GUID
parse_json()Dynamic JSON object
dynamic()Dynamic value

Example:

TableName
| extend AgeNumber = toint(AgeText)
| extend IsActiveBoolean = tobool(Status)

11. Dynamic Data and JSON Functions

FunctionPurpose
parse_json()Parses JSON
parse_xml()Parses XML
pack()Creates a property bag
pack_array()Creates an array
bag_pack()Creates a property bag
bag_keys()Returns property names
bag_has_key()Checks whether a property exists
bag_remove_keys()Removes specified properties
bag_set_key()Sets a property value
bag_unpack()Expands property bag fields into columns
array_length()Gets array length
array_concat()Combines arrays
array_slice()Extracts an array section
array_sort_asc()Sorts an array ascending
array_sort_desc()Sorts an array descending
set_union()Combines distinct set elements
set_difference()Finds elements in one set but not another
set_intersect()Finds common elements
zip()Combines arrays element by element

Example:

TableName
| extend JsonData = parse_json(JsonColumn)
| extend UserName = tostring(JsonData.name)
| extend UserAge = toint(JsonData.age)
| project UserName, UserAge

12. Mathematical Functions

FunctionPurpose
abs()Absolute value
round()Rounds a number
ceiling()Rounds up
floor()Rounds down
sqrt()Square root
pow()Power
log()Natural logarithm
log10()Base-10 logarithm
log2()Base-2 logarithm
exp()Exponential
exp2()Power of 2
exp10()Power of 10
sin()Sine
cos()Cosine
tan()Tangent
asin()Inverse sine
acos()Inverse cosine
atan()Inverse tangent
pi()Returns Ο€
sign()Returns sign of number
bin()Rounds values down to a bin boundary
bin_at()Bins values using specified alignment

Example:

TableName
| extend RoundedPrice = round(Price, 2)
| extend AbsoluteValue = abs(Amount)

13. Query Statements and Declarations

KeywordPurposeExample
letDefines a variable or reusable expressionlet x = 10;
setSets a query optionset query_take_max_records = 1000;
declareDeclares parameters in supported contextsdeclare query_parameters(p:string);
query_parametersDeclares query parametersdeclare query_parameters(id:string);

Example: let

let MinimumAge = 18;
Users
| where Age >= MinimumAge

Example: let with datetime

let StartDate = ago(30d);
Orders
| where CreatedDate > StartDate

Example: Query Parameters

declare query_parameters(UserId:string);
Users
| where Id == UserId

14. Management Commands

Management commands generally begin with a dot (.). They are used to create, modify, inspect and manage Kusto objects.

A. Create Commands

CommandPurpose
.createCreates an object
.create-or-alterCreates or modifies an object
.create-mergeCreates or merges an object
.create-or-replaceCreates or replaces an object

B. Alter Commands

CommandPurpose
.alterModifies an existing object
.alter-mergeMerges changes into an existing object
.alter-asyncPerforms an asynchronous alteration, where supported

C. Show Commands

CommandPurpose
.showDisplays metadata or information
.show tablesLists tables
.show databasesLists databases
.show functionsLists stored functions
.show functionDisplays a specific function
.show schemaDisplays schema information
.show commandsDisplays management command history
.show queriesDisplays query history
.show diagnosticsDisplays diagnostic information, where supported

D. Drop and Delete Commands

CommandPurpose
.dropRemoves an object
.drop tableRemoves a table
.drop functionRemoves a function
.drop databaseRemoves a database
.deleteDeletes records using supported management operations

E. Ingestion and Data Management Commands

CommandPurpose
.ingestIngests data
.setCreates or sets a table from query results
.set-or-replaceCreates or replaces table data
.set-or-appendCreates a table or appends data
.appendAppends data to a table
.moveMoves supported data or metadata
.renameRenames supported objects

Important: Not every management command is supported in every KQL environment. Azure Monitor Logs, Microsoft Sentinel and Azure Data Explorer have different command capabilities. Management commands can modify data or metadata, so use them carefully.

Example: Create or Alter Function

.create-or-alter function
with (
    docstring = "SSRProblemDetection",
    skipvalidation = "true"
)
SSRProblemDetection()
{
    // Function body
}

This command creates the function if it does not exist, or updates it if it already exists.

15. Frequently Used KQL Keywords – Quick Reference

PriorityKeywordPurpose
1whereFilter records
2projectSelect columns
3extendCreate calculated columns
4summarizeGroup and aggregate
5joinCombine tables
6unionCombine datasets
7distinctGet unique records
8sortSort records
9takeLimit results
10countCount records
11containsSearch text
12hasSearch complete terms
13inMatch multiple values
14betweenCheck ranges
15iff()Conditional expression
16case()Multiple conditions
17ago()Calculate past time
18now()Current time
19datetime_diff()Calculate date differences
20arg_max()Get latest record
21parseExtract information
22mv-expandExpand arrays
23make_set()Create unique-value arrays
24letDeclare variables
25evaluateExecute query extensions

16. Official Microsoft KQL Documentation

Recommended Learning Order

For Azure monitoring and SSR troubleshooting, learn these topics in the following order:

  1. Basic query structure and pipe operator.
  2. where, project, extend and distinct.
  3. Comparison and logical operators.
  4. contains, has, in and regex.
  5. iff(), case() and coalesce().
  6. Date and time functions.
  7. summarize and aggregation functions.
  8. join and union.
  9. parse and dynamic JSON operations.
  10. let statements and reusable functions.
  11. Management commands.
  12. Advanced KQL: window functions, partition, scan and performance optimization.

Note: This is a practical reference covering commonly used KQL operators, functions and commands, not an exhaustive list of every built-in KQL function or reserved identifier. Refer to Microsoft Learn for the complete and current language reference.

πŸ”™
SHA-256 with RSA :👈 👉:Deployment Rings