As of dbt-event-logging
0.6.0
, the only customisation that can be done to it is to redefine the schema where the dbt_audit_log
table is put into (see readme). If you want to further customise the columns that get's recorded in the dbt_audit_log
table itself, for example adding dbt_cloud_run_id
, you will have to get knee deep into the source macros.
To make thing's easier, we can just copy most of the code in the source audit.sql
macro, put it in your macros folder (i.e. macros/audit.sql
) and make some tweaks to it - this also means that you do not need to install the dbt-event-logging
package via specifying it in your packages.yml
file since the macro is part of our project.
The example audit.sql
file in this gist shows how to add 2 additional columns that contain some special environment values which are available during a dbt Cloud run job.
Then in our dbt_project.yml
file, we can call those macros like so:
...
on-run-start:
- "{{ create_audit_schema() }}"
- "{{ create_audit_log_table() }}"
- "{{ log_run_start_event() }}"
on-run-end:
- "{{ log_run_end_event() }}"
models:
my_project_name:
+pre-hook: "{{ log_model_start_event() }}"
+post-hook: "{{ log_model_end_event() }}"
...