Instrumenting a Pipeline E2E
Concepts covered: Pipeline Monitoring
Take orders_daily as it stood before this lesson: 6 tasks on a daily schedule, failure emails to a shared inbox, no metrics or lineage, and no tags or CI. Instrumenting all of it in 1 project takes a quarter and pays nothing until the end. Sequencing it so each step works on its own gives the team a better pipeline every week, and a point to stop at whenever priorities shift.
7 steps, each useful alone
| Week | Step | Value on its own | Builds on |
|---|---|---|---|
| 1 | Freshness and row-count check on `agg_daily_revenue` at 07:00 UTC, paging the owner | The team hears about a late or short load before Finance's 08:00 UTC review | Nothing |
| 2 | `run_id` on every log line from every task | A single search returns a failed run's whole story | The week 1 page links to the run |
| 3 | Duration and row metrics per task, labelled `pipeline` and `task` | Shows which task slowed down or shrank, and since when | `run_id` links a metric spike to the run's logs |
| 4 | Quality gates at the `stg_payments` and `stg_orders` boundaries | Bad batches stop before they reach `fct_orders` | Week 3 metrics: block below 50% of the trailing average, tighten after a few weeks |
| 5 | Lineage from parsed code and 30 days of query logs | Every page names the downstream nodes and their owners | Week 1 pages now carry the blast radius |
| 6 | Query tags on every task | Cost per run and per task on the monthly rollup | Week 2 `run_id` joins a costly query to its run's logs |
| 7 | Slim CI with the 4 test layers | Broken changes stop at the pull request | Week 5 lineage picks the build set; week 4 gates run in layer 3 |
The order follows the questions an incident raises: is something wrong, where, who is affected, what is it costing, and how do we stop the next one. Detection goes first because every later step assumes the team knows a failure happened. CI comes last here even though it prevents incidents, because slim selection needs lineage and layer 3 needs the gates.
- extract_payments (transform, orchestrator); retries: 3; backoff: exponential, 30s base
- extract_orders (transform, orchestrator); retries: 3; backoff: exponential, 30s base
- stg_payments (transform, orchestrator); idempotency: overwrite date partition
- stg_orders (transform, orchestrator); idempotency: overwrite date partition
- staging_gate (quality gate, orchestrator); on error: block downstream, page owner
- build_fct_orders (transform, orchestrator); parallelism: 32 partitions; backfill: rebuild by date in lineage order
- build_agg_daily_revenue (transform, orchestrator); freshness: ready by 07:00 UTC; alerting: page payments-data if late or short
- Revenue dashboard (consumer, Finance)
- extract_payments -> stg_payments
- extract_orders -> stg_orders
- stg_payments -> staging_gate
- stg_orders -> staging_gate
- staging_gate -> build_fct_orders
- build_fct_orders -> build_agg_daily_revenue
- build_agg_daily_revenue -> Revenue dashboard
- Do
- Ship each step to prod before starting the next
- Alert on the output table first and on task failures second
- Reuse run_id as the key that joins logs to tags, and to pages too
- Set gate thresholds from the metric history you already collect
- Avoid
- Start with CI on a pipeline whose failures nobody sees
- Label metrics with run_id or order_id, or with partition_date
- Rely on engineers to type query tags by hand in each task
- Roll out all 7 steps as 1 change at the end of the quarter
Another team asks for help instrumenting clickstream_sessions, the $11,800-a-month hourly pipeline with 3 readers. Failures are rare; the bill is the complaint. Which first 2 steps fit?
- Tag every query with pipeline and task, then register lineage from query logs to see who the 3 readers are and how often they read.
- Build slim CI with all 4 layers, since preventing bad merges protects every step that comes after it.
- Add a session_id label to the duration and row metrics, then set gate thresholds from their history.
- Copy the orders_daily plan step for step, starting with the freshness page and run_id logging in weeks 1 and 2.
Practice across all 5 sections
In week 9 the 07:00 UTC check pages: agg_daily_revenue has no partition for 2026-10-23. The page links run orders_daily__2026-10-23T06:00. The staging gate passed, and logs show build_fct_orders still running at 50 minutes, against the 12 its duration metric shows on a normal day. Its tagged queries have already cost 3 times a normal run, and the only change since the last good run is a merge on 2026-10-22. Which response uses the instrumentation best?
- Raise build_fct_orders to 5 retries with backoff so the task recovers on its own, and check the dashboard after lunch.
- Walk backward lineage to raw.payments and raw.orders first, since an incident's origin is always a source table.
- Add run_id as a label on the duration metric so the next slow run appears as its own series on the dashboard.
- Revert the 2026-10-22 merge, rerun from build_fct_orders forward, and warn the owners the page lists that revenue will be late.
About this lesson
This section is part of the Pipeline Operations: Intermediate lesson on DataDriven, the home of data engineering. Lessons cover SQL, Python, Spark, data modeling and pipeline architecture, and each section pairs its explanation with worked examples and practice you run as you go.