Skip to main content
Ensuring your source data is up-to-date is critical for reliable analytics. dbt’s source freshness checks allow you to monitor and verify when data was last loaded, helping your team maintain data quality and meet service level agreements (SLAs).

Why Test Source Freshness?

Source freshness checks serve several important purposes:

How Source Freshness Works

dbt’s source freshness checking works by:
  1. Examining a timestamp column in your source tables
  2. Comparing that timestamp to the current time
  3. Evaluating the difference against your defined thresholds
Example Freshness Check FailuresWhen data exceeds your freshness thresholds, dbt will report failures like these:

When data exceeds your freshness thresholds, dbt will report failures like these:The warnings and errors include the source name, how much data is missing, the timestamp of the most recent record, and your configured threshold.

Configuring Freshness Checks

To enable freshness checks, you need to add two key elements to your sources.yml file:
  1. A loaded_at_field that identifies the timestamp column
  2. A freshness configuration that defines your thresholds
Here’s a basic example:

Understanding the Configuration

  • loaded_at_field: The column containing the timestamp when data was loaded
  • warn_after: When to issue a warning about stale data
  • error_after: When to report an error about stale data (typically more lenient than warnings)
Valid Time Periods for Freshness ChecksWhen configuring source freshness thresholds, you must specify both a count and a time period. The time period can be:
  • minute - For data that updates very frequently (e.g., real-time systems)
  • hour - For data that updates throughout the day (e.g., transaction systems)
  • day - For data that updates daily or less frequently (e.g., batch uploads)
For example: warn_after: {count: 6, period: hour} would warn if data is more than 6 hours old.

Table-Specific Freshness Settings

You can override source-level freshness settings for specific tables:

Running Freshness Checks

To check the freshness of your source data, run:
This command:
  1. Queries each source table for the most recent loaded_at_field value
  2. Compares that timestamp against the current time
  3. Evaluates it against your thresholds
  4. Reports success, warning, or error for each source
Where Freshness Check Results AppearWhen you run dbt source freshness, the results appear in multiple places:
  1. Terminal Output: Warnings and errors are displayed in your command line interface immediately when running the command
  2. Log Files: Results are written to the log files in your project’s logs/ directory
  3. Artifacts: Detailed results are stored in the target/sources.json file
  4. dbt Cloud (if using): Results appear in the run history and can trigger notifications
  5. Paradime Interface (if using): Results are displayed in the Paradime UI with history tracking
These results can be consumed by monitoring tools, notification systems, or dashboards to provide visibility into your data pipeline health.

Example Output


Integrating Freshness Checks into Workflows

Freshness checks can be integrated into your data pipeline in several ways:

Scheduled Checks

Run freshness checks on a regular schedule to proactively monitor your data:

Pre-run Validation

Execute freshness checks before running models to prevent building on stale data:

CI/CD Pipeline Integration

Include freshness checks in your CI/CD workflows:

Optimizing Freshness Checks for Large Tables

For very large datasets, running freshness checks can be resource-intensive. You can optimize them using filters:
The filter clause limits the rows that dbt examines when checking freshness, improving performance for large tables.

Handling Different Data Loading Patterns

Different sources may have various data loading patterns that affect how you configure freshness:

Troubleshooting Freshness Issues

If your freshness checks are failing, consider these common issues:
  1. Incorrect timestamp column: Verify that loaded_at_field is the right column
  2. Timezone differences: Check if there are timezone discrepancies between source timestamps and dbt
  3. Data loading failures: Investigate upstream ETL/ELT processes
  4. Unrealistic expectations: Adjust thresholds to match actual data loading patterns

Best Practices


Automating Source Generation with DinoAIWith DinoAI (Paradime’s AI Agent), you can automatically generate source definitions with appropriate freshness configurations. See step by step instructions for more details.