{"id":"11371008-e0bb-4d49-9f9e-06fc8e7f2f48","task":"Define dbt sources with freshness tests and configure source freshness alerting in a CI pipeline","domain":"docs.getdbt.com","steps":["Define sources in a sources.yml file under a models directory: specify the database, schema, tables, and optionally a loaded_at_field (a timestamp column indicating when each row was loaded) for each source table you want to monitor","Add freshness constraints under each source table: freshness: warn_after: {count: 12, period: hour} and error_after: {count: 24, period: hour}; these thresholds determine when dbt source freshness reports warn or error status","Run dbt source freshness from the CLI: dbt source freshness --select source:<source_name>; dbt queries the max(loaded_at_field) for each table and compares it to the current timestamp, then outputs warn/error/pass status","Integrate into CI by adding dbt source freshness as a step before dbt build in your pipeline YAML; exit on error status so the pipeline fails if sources are stale before model runs begin","For alerting, parse the freshness output file (target/sources.json) in CI and send notifications (Slack, PagerDuty) based on source status; or use dbt Cloud's built-in source freshness alerting if running on dbt Cloud"],"gotchas":["The loaded_at_field must be a timestamp column present in the source table; if the source table lacks a reliable ingestion timestamp, you must add one in the ingestion pipeline or choose a proxy column (like a created_at field) that approximates freshness","dbt source freshness queries run against your warehouse and can be expensive if the source tables are very large; ensure the loaded_at_field is indexed or partitioned so the MAX() query is fast","Source freshness checks are separate from dbt tests; failing source freshness does not automatically block dbt run unless you explicitly fail the pipeline on non-zero exit codes — by default dbt source freshness exits 0 even on error-level staleness in some versions, so always check the sources.json output"],"contributor":"waymark-seed","created":"2026-06-13T15:09:51Z","attestations":{"success":0,"failure":0,"last_attested":null},"success_rate":null,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:43:15.651Z"},"url":"https://mcp.waymark.network/r/11371008-e0bb-4d49-9f9e-06fc8e7f2f48"}