What's the best way to monitor my data ingestion steps?
Summary
- Monitor ingestion at five points: did the run succeed, did the expected volume arrive, is the data fresh, did the schema change, and are the values valid. A green run status alone can hide a half-loaded file or a column of nulls.
- On Databricks, run outcomes are recorded in the
system.lakeflowsystem tables, and per-flow row counts and data quality results are recorded in the pipeline event log, so both are queryable with SQL. - Declare quality rules as expectations (warn, drop, or fail) and use Auto Loader's schema evolution modes and
_rescued_datacolumn to catch schema drift. - Route problems to people with Lakeflow Jobs notifications or Databricks SQL alerts. Anomaly detection (Public Preview) adds learned freshness and completeness checks across a schema's tables.
What's the best way to monitor my data ingestion steps?
Monitor five things, not one: whether the run finished, whether the expected volume landed, whether the data arrived on time, whether the schema changed, and whether the values are valid. A run can succeed and still load a partial extract. On Databricks you can read each signal from built-in sources (the pipeline event log, the system.lakeflow tables, and expectations) and alert on it through built-in notifications.
What should I monitor during ingestion?
| Signal | What goes wrong | Where to read it on Databricks |
|---|---|---|
| Run outcome | A connection, credential, or source failure stops the run | The pipeline UI, system.lakeflow.pipeline_update_timeline (result_state is COMPLETED, FAILED, or CANCELED), and system.lakeflow.job_run_timeline for jobs |
| Row volume | Row counts fall or spike far outside the usual range | flow_progress events in the pipeline event log (num_output_rows) |
| Freshness | A table is not updated when expected | Anomaly detection (Public Preview) marks a table stale when a commit is unusually late |
| Schema drift | A new column or a different type shows up upstream | Auto Loader cloudFiles.schemaEvolutionMode and the _rescued_data column |
| Data quality | Nulls, out-of-range values, broken keys | Expectations, with passed_records, failed_records, and dropped_records in the event log |
How do I implement ingestion monitoring on Databricks?
Query the event log. Every Lakeflow Pipelines pipeline has an event log that holds audit logs, data quality checks, pipeline progress, and lineage. Read it with event_log(<pipelineId>), or publish it and put a view on top before you widen access. This query totals the rows each flow wrote per update:
SELECT
origin.update_id,
origin.flow_name,
SUM(COALESCE(TRY_CAST(details:flow_progress.metrics.num_output_rows AS BIGINT), 0)) AS output_rows
FROM event_log(<pipelineId>)
WHERE event_type = 'flow_progress'
GROUP BY origin.update_id, origin.flow_name;
For Lakeflow Connect gateways, flow_progress events report per-table row and byte counters.
Declare expectations. An expectation checks every record that passes through a streaming table or materialized view:
CREATE OR REFRESH STREAMING TABLE customers(
CONSTRAINT valid_customer_age EXPECT (age BETWEEN 0 AND 120)
) AS SELECT * FROM STREAM(datasets.samples.raw_customers);
The default action keeps violating rows and counts them. Add ON VIOLATION DROP ROW to drop them, or ON VIOLATION FAIL UPDATE to stop the update (the fail action records no metrics, because the update fails).
Send alerts. Lakeflow Jobs can notify you on start, success, failure, or a duration warning, by email or through system destinations such as Slack or a webhook (an admin configures those). Job-level notifications are not sent when failed tasks are retried, so use task notifications to hear about every failed attempt. A pipeline on its own schedule takes notifications directly. Databricks SQL alerts run a query on a schedule and notify you when a condition you define is met, which suits a custom check such as a row count below your floor.
How do I set alert thresholds?
Compare each run with earlier runs of the same flow. The system.lakeflow tables keep 365 days of history, and the runs list in the UI keeps 60. If volume follows a weekly cycle, compare against the same weekday.
Anomaly detection (Public Preview) does this for you at the table level. A background job builds a per-table model of commit times and expected row counts, marks a table stale when a commit is unusually late, and marks it incomplete when the last 24 hours of rows fall below the expected range. You enable it from a schema's Details tab and need the MANAGE privilege on the schema or catalog.
What are the common pitfalls?
Trusting a green run. The default expectation action writes bad rows to the target. Use drop or fail for rules that must hold.
Missing schema drift. In Auto Loader's default addNewColumns mode (used when you don't provide a schema), the stream stops with an UnknownFieldException after adding new columns, and a restart resumes with the updated schema. In rescue mode the stream keeps running and records new columns in _rescued_data, so you must watch that column.
FAQs
How often should I check ingestion status?
On every run, not on a clock. Failure notifications fire when a run fails. Use scheduled SQL alerts for conditions that need a periodic look, such as freshness.
What if my ingestion volume varies by day?
Use anomaly detection for table-level patterns. For custom checks, compare each run with earlier runs on the same weekday instead of one fixed threshold.
Should I retry failed ingestions automatically?
Yes for transient failures, with a cap. Lakeflow Jobs lets you set a retry policy on each task, and continuous jobs use exponential backoff. Pipelines also retry transient failures progressively, from the Spark task to the flow to the whole pipeline.
Can I monitor ingestion without writing SQL?
Partly. The pipeline monitoring UI shows the graph by status, per-table row counts, data quality metrics, and update history, and you switch on anomaly detection from the schema page. Expectations are declared in SQL or Python, and custom alerts are SQL queries.
The information provided herein is for general informational purposes only and may not reflect the most current product capabilities or configurations.