Sub topic 12
Monitoring with the pipeline event log
This chapter assumes you can build a pipeline with streaming tables, materialized views and expectations, and that you can write basic SQL against Unity Catalog tables. Every pipeline records what it does in an event log. Reading that log is the main way to see update progress, errors, and data quality results.
What the event log holds
The event log is a Delta table that the pipeline writes to as it runs. Each row is one event. Events cover update lifecycle, flow progress, dataset definitions, cluster resources, and data quality.
| Column | Meaning |
|---|---|
| `timestamp` | When the event happened |
| `event_type` | Kind of event, such as `flow_progress` or `update_progress` |
| `level` | `INFO`, `WARN`, or `ERROR` |
| `message` | Human-readable text |
| `details` | JSON string with event-specific fields |
| `origin` | Which pipeline, update, and flow produced the event |
The details column is where most of the useful numbers live. For example, flow_progress events carry row counts and expectation results inside it.
Querying the log
The event_log table-valued function takes a table that belongs to a pipeline and returns the log of the pipeline that owns it. You don't need to know where the log is stored.
SELECT timestamp, event_type, message
FROM event_log(TABLE(main.demo.orders_silver))
WHERE event_type = 'flow_progress'
ORDER BY timestamp DESC
LIMIT 20;The query returns the 20 most recent flow progress events for the pipeline that produces orders_silver. You must have permission to query that table, and the table must be one the pipeline publishes to Unity Catalog.
Reading data quality results
Expectations report their results in flow_progress events. The details JSON holds a flow_progress.data_quality.expectations array. Each entry has the expectation name, the dataset, the number of rows that passed, and the number that failed.
The query below extracts those values for the most recent update.
WITH events AS (
SELECT timestamp, origin.update_id AS update_id, details
FROM event_log(TABLE(main.demo.orders_silver))
WHERE event_type = 'flow_progress'
),
latest AS (
SELECT update_id FROM events ORDER BY timestamp DESC LIMIT 1
)
SELECT
exp.dataset,
exp.name,
SUM(exp.passed_records) AS passed,
SUM(exp.failed_records) AS failed
FROM events
JOIN latest USING (update_id)
LATERAL VIEW explode(
from_json(
details:flow_progress.data_quality.expectations,
'array<struct<name:string,dataset:string,passed_records:int,failed_records:int>>'
)
) t AS exp
GROUP BY exp.dataset, exp.name;For orders_silver, you would see valid_order_id and positive_amount. A rising failed count on positive_amount is a signal that upstream data has changed. Rows failing valid_order_id are dropped, so that count also tells you how many rows were lost.
Following an update
Use the event types in this order when you investigate a problem:
update_progressshows whether the update ran, finished, failed or was canceled.- Events with
level = 'ERROR'give the failure message and, indetails, the exception. flow_progressshows which flow was running and how many rows it processed.flow_definitionshows how each dataset was defined for that update, which helps when a change in code changes behavior.
A query for failures:
SELECT timestamp, origin.flow_name, message
FROM event_log(TABLE(main.demo.orders_silver))
WHERE level = 'ERROR'
ORDER BY timestamp DESC;Common errors
- No rows returned. The table has never been updated by a pipeline, or you passed a table the pipeline does not own. Check the table name and run an update first.
- Permission denied. Querying the event log requires access to the table you pass in. Ask the pipeline owner for
SELECTon it. - Empty
detailsfields.detailsis a JSON string. Extract values with the:operator orfrom_json, not by treating it as a struct. - Mixing updates. The log holds every update. Filter on
origin.update_idor on a time range, otherwise counts add up across runs.
Exercise
You want to know how many rows valid_order_id dropped in the latest update of the orders pipeline. Which event type do you query, and which part of the event holds the number?
Show answer
Query flow_progress events through event_log(TABLE(main.demo.orders_silver)). The count is failed_records for the valid_order_id entry in the data_quality.expectations array inside details. Filter to the latest origin.update_id so you don't sum across updates.