extend
extend adds one or more columns to every row. The new column is computed from the row’s other
columns, and all existing columns stay as they are.
SecurityEvent
| extend IsFailure = EventID == 4625
You can add several columns in one extend, separated by commas. A column added there can be used by
the next operator, for example in a where, a summarize ... by, or a later extend.
Naming
- Always give the column a name:
extend Domain = .... Without a name, Kusto invents one (likeColumn1), which is hard to work with. This site only accepts unnamed columns in one case:extend ExistingColumn, which changes nothing. - If the name already exists, the column is replaced with the new value, in the same position.
This is a handy way to normalise a value, e.g.
extend UserPrincipalName = tolower(UserPrincipalName).
What you can compute
Anything that gives one value per row: arithmetic (Bytes / 1024), string functions
(strcat, extract, split), date math
(TimeGenerated - ago(1d)), conditions (iff, case) and reads from
dynamic columns.
Aggregations such as count() or dcount() do not belong in extend; they need
summarize, because they combine many rows into one.
Examples
DeviceNetworkEvents
| where RemotePort == 445
| extend Endpoint = strcat(RemoteIP, ":", tostring(RemotePort))
| summarize Connections = count() by DeviceName, Endpoint
| where Connections >= 6SigninLogs
| where ResultType != "0"
| extend HourUtc = datetime_part("hour", TimeGenerated)
| summarize Failures = count() by HourUtc
| sort by HourUtc ascSigninLogs
| extend UserPrincipalName = tolower(UserPrincipalName)
| summarize SignIns = count() by UserPrincipalName
| top 3 by SignInsGiving the new column the name of an existing one replaces that column.
Practice it
None of the free exercises needs this one yet.
+ 9 in the full SC-200 set · all exercises