Processing streaming data with KQL

By Hatnest · Reviewed by Saurav Raj Joshi · Updated Nov 30, 2026

An eventhouse stores streaming events in KQL database tables, and Kusto Query Language is how you shape and query them. Events usually arrive from an eventstream, either as-is (direct ingestion) or after processing in the stream. Once rows are in a table, you have three tools for processing them: ad hoc queries, update policies, and materialized views. Choosing among them is the exam skill.

Ad hoc queries over recent data

Streaming questions are nearly always "what happened in the last N minutes". Filter by time first so the engine reads less, then bucket and aggregate.

Telemetry
| where Timestamp > ago(1h)
| summarize AvgTemp = avg(Temp), Readings = count() by DeviceId, bin(Timestamp, 5m)
| order by Timestamp asc

ago() gives a time relative to now, and bin(Timestamp, 5m) rounds each timestamp down to its five-minute bucket, which is how you build fixed windows in KQL (see the windowing article). To get the latest row per device use arg_max:

Telemetry | summarize arg_max(Timestamp, *) by DeviceId

Transform on arrival: update policies

An update policy is attached to a target table and fires when new data lands in a source table. It runs a query, over the newly ingested data only, and writes the result into the target table. No external orchestration is needed.

Typical uses:

  • Parse a raw free-text or JSON column into typed columns (with parse, parse_json or extend).
  • Enrich with a dimension table using lookup.
  • Filter or route rows into separate tables, each with its own schema and retention.

One source can feed several target tables. Because the policy runs per ingestion batch, it can only aggregate within that batch. Update policies can affect ingestion performance, so test the query on realistic batches.

Fresh aggregates: materialized views

A materialized view exposes a single summarize query over a source table. It has a materialized part (already aggregated, one row per group) and a delta (newly ingested rows not yet processed). A query on the view merges both, so the answer is always up to date and cheaper than re-aggregating the source.

.create async materialized-view with (backfill=true) DeviceLatest on table Telemetry
{
    Telemetry | summarize arg_max(Timestamp, *) by DeviceId
}

For dashboards that tolerate slight staleness, the materialized_view() function reads only the materialized part, which is faster.

Update policy or materialized view?

  • Aggregation across batches or deduplication to latest state: materialized view.
  • Reshaping, parsing, filtering, enrichment inside one batch: update policy.
  • Update policies run in the ingestion pipeline; materialized views run in the background afterwards.
  • Joins are risky in both when the matching row may not have been ingested yet.

Time series

make-series builds a regular series (an array of values along a time axis) with a default for missing steps, which you can then feed to series functions such as series_decompose_anomalies for anomaly detection and forecasting. Use summarize with bin() when you want rows, and make-series when you want gap-filled arrays.

Telemetry
| make-series Avg = avg(Temp) default=0 on Timestamp from ago(1d) to now() step 10m by DeviceId

Making queries on streams efficient

Filter on time and on selective columns early, project only the columns you need, and aggregate in a materialized view when the same summary is requested repeatedly. Data can be made available to other engines by turning on OneLake availability on the database.

Common mistakes

  • Expecting an update policy to compute running totals across batches.
  • Aggregating by raw timestamps instead of bin() buckets.
  • Using arg_max(Timestamp, *) in a view whose source schema changes, without handling schema updates.
  • Querying a whole table when a time filter would limit the scan.

For the exam

  • bin() plus summarize creates fixed time buckets; ago() limits the window to recent data.
  • Update policy: transform per ingestion batch, at ingest time, into another table.
  • Materialized view: single summarize query, always fresh, good for latest state and aggregates.
  • make-series creates gap-filled time series for anomaly detection and forecasting.
  • Eventstream "event processing before ingestion" versus KQL-side processing is a design choice.

Sources