I want to store output of "dbt source freshness" command result in database or send email of freshness test for warning and error records only.
I want to store output of "dbt source freshness" command result in database or send email of freshness test for warning and error records only.
You can either use this package to store audit logs in your db: dbt-event-logging
Add to your dbt project yml:
# dbt_project.yml
...
models:
...
pre-hook: "{{ logging.log_model_start_event() }}"
post-hook: "{{ logging.log_model_end_event() }}"
I imagine you can alter the sources: attribute in a similar way – though I am not 100% sure...
Alternatively, you can create your own post-hook event – usage becomes complex really quickly: https://docs.getdbt.com/reference/resource-configs/pre-hook-post-hook