Copyright (c) 2026 MindMesh Academy. All rights reserved. This content is proprietary and may not be reproduced or distributed without permission.

3.4.4. KQL for Real-Time Processing

💡 First Principle: KQL (Kusto Query Language) is optimized for time-series analysis, excelling at aggregating and analyzing streaming data with minimal latency. It's the native language for Real-Time Intelligence.

Common KQL Patterns
// Filter recent events
TemperatureReadings
| where timestamp > ago(1h)
| where temperature > 100

// Aggregate by time bucket
TemperatureReadings
| summarize AvgTemp = avg(temperature) by bin(timestamp, 5m), deviceId

// Detect anomalies
TemperatureReadings
| summarize AvgTemp = avg(temperature), StdDev = stdev(temperature) by deviceId
| where AvgTemp > 100 or StdDev > 20

Update Policies for Ingest-Time Transformations

  • Concept: Transform data automatically during ingestion
  • Benefit: Data lands pre-transformed, reducing query complexity
  • Use Case: Parsing JSON, calculating derived fields, filtering
  • Setup: create the source table (raw ingestion) → create the target table with the transformation's output schema → run .alter table Target policy update @'[{"IsEnabled": true, "Source": "Raw", "Query": "TransformRaw()"}]' (the query is usually a stored function) → ingest into the source and transformed rows appear in the target
Update Policy vs. Materialized View vs. Stored Function
FeatureWhat it doesPick it when
Update policyRuns a query over each newly ingested batch in the source table and writes the results to a target tableTransform, filter, or enrich data at ingestion time; it runs per batch, so it can't aggregate across batches
Materialized viewMaintains an aggregation (summarize) over a source table; queries always return fresh resultsAny aggregation kept up to date automatically, latest record per key (arg_max)
Stored functionSaved, reusable (optionally parameterized) query logic, evaluated against current data on every callShare standard filters or logic across queries and users

A materialized view is automatically disabled when a source-table change makes its query incompatible with the view's schema (for example, a retyped column, or arg_max(ts, *) over a changed schema); it stops updating until you fix it and re-enable it. Continuous export copies data out to external storage; it doesn't populate another KQL table.

KQL Operator Reference
Operator / functionWhat it doesNote
whereKeeps rows that match a predicateFilter before a project that drops the filtered column
projectSelects or renames columnsLike a SQL SELECT list
extendAdds a computed column to every row (row count unchanged)summarize instead collapses rows into groups
summarize ... byOne row per group with aggregatescount() output is named count_; countif(pred) counts matching rows
top N by col descSorts and keeps N rowsUse after summarize for "top 10 devices"
take NReturns N arbitrary rows, unorderedQuick preview only
arg_min(ts, *) / arg_max(ts, *)Whole row with the min/max value per groupFirst or latest event per device
ago(1h)Current time minus a timespanwhere ts > ago(24h)
parse_json(col)Turns a JSON string into dynamic for .property accessNested JSON fields
parse col with 'User ' email ' logged in from ' ipExtracts values between literal textStructured log lines
prev(col) / next(col)Value from the previous/next rowNeeds an ordered (serialized) row set, e.g. after order by
make-series + series_fir()Builds a time series, then applies a moving-average filterRolling/moving averages
joinCombines two tables on a keyLike SQL JOIN

Queries read left to right: each | passes the previous result to the next operator, instead of SQL's inside-out nested subqueries.

⚠️ Exam Trap: KQL databases use KQL, not T-SQL. T-SQL is for the Fabric Data Warehouse. Questions about "Eventhouse transformations" or "KQL database queries" require KQL syntax, not SQL.

See how it connects
Alvin Varughese
Written byAlvin Varughese
Founder•20 professional certifications