<@U088WCP3B4P> I have this DAG in airflow: ```dbt_...
# ask-elementary-ai
y
@kapa.ai I have this DAG in airflow:
Copy code
dbt_freshness = dbt_task_factory.get_task(
        dag_id="freshness_run",
        arguments=[
            "dbt",
            "source",
            "freshness",
        ],
        pool="dbt",
        extra_env_vars=extra_env_vars,
    )
if the freshness test fails on some models, will there be any alerts?
k
Running
dbt source freshness
alone is not enough to trigger Elementary alerts. You need additional steps after the freshness run. What's Missing Elementary does not automatically capture
dbt source freshness
results unless you take one of the following approaches: Option 1: dbt 1.8+ (recommended) Add this flag to your
dbt_project.yml
to enable automatic collection via on-run-end hooks:
Copy code
flags:
  source_freshness_run_project_hooks: True
Then run
edr monitor
after the freshness command. [Collect source freshness] Option 2: dbt < 1.8 (or as a fallback) You must manually upload the results before monitoring:
Copy code
dbt source freshness
edr run-operation upload-source-freshness --project-dir <path to your project>
edr monitor
[Collect source freshness] Updated Airflow DAG Your DAG should be extended to include the upload and monitor steps, for example:
Copy code
dbt_freshness >> upload_source_freshness >> edr_monitor
Where: •
upload_source_freshness
runs
edr run-operation upload-source-freshness --project-dir <path>
•
edr_monitor
runs
edr monitor
with your Slack/Teams configuration > Note:
dbt source freshness
and
upload-source-freshness
must run on the same machine. [Teams alerts guide] Also, by default Elementary only alerts on errors, not warnings. If you want warning-level freshness alerts too, add this to your `dbt_project.yml`:
Copy code
vars:
  disable_warn_alerts: false
šŸ‘ 0 button šŸ‘Ž 0 button ā„¹ļø Tip: Mention @elementary.ai in the thread for follow-ups or DM the app for 1-to-1 help.
y
@kapa.ai how to run
edr monitor
after the freshness command exactly?
k
Here's how to add the
edr monitor
step after your freshness task in Airflow, using `BashOperator`:
Copy code
from airflow.operators.bash_operator import BashOperator

upload_source_freshness = BashOperator(
    task_id='upload_source_freshness',
    bash_command=f"edr run-operation upload-source-freshness --project-dir {os.getenv('DBT_PROJECT_DIR')}"
)

edr_monitor = BashOperator(
    task_id='elementary_monitor',
    bash_command=f"edr monitor --profiles-dir {os.getenv('DBT_PROFILES_DIR')} --slack-token {os.getenv('SLACK_TOKEN')} --slack-channel-name {os.getenv('EDR_SLACK_CHANNEL')}"
)

dbt_freshness >> upload_source_freshness >> edr_monitor
The order matters: [Collect source freshness] 1.
dbt source freshness
— runs the freshness checks 2.
edr run-operation upload-source-freshness
— uploads the results to Elementary's tables 3.
edr monitor
— reads the uploaded results and sends alerts > Note: Steps 1 and 2 must run on the same machine. [Teams alerts guide] Also make sure
edr
is installed in your Airflow worker environment:
Copy code
pip install 'elementary-data[<your-warehouse>]'
[Airflow integration] šŸ‘ 0 button šŸ‘Ž 0 button ā„¹ļø Tip: Mention @elementary.ai in the thread for follow-ups or DM the app for 1-to-1 help.