Search code examples
loggingjinja2monitoringdbt

Printing dbt invocation_command in the logs


So I'm using dbt core with snowflake data warehouse. I'm using dbt in some Kubeflow components in a pipeline.. and when the components run, I want to be able to see which dbt command it has been invoked to run this component. I know I can show the input parameters for a pipeline.. but my main question how can I print what invocation_command was triggered for dbt. I have read many documentation webpages and I found this invocation_command variable that has the value, but I could not find how I can get its value and then print it in the logs that dbt usually prints.

Thanks in advance

I have tried dbt --debug run but then the log is too too long.. I only want the regular logs, with the invocation_command value.


Solution

  • This can be accomplished by running some Jinja in on-run-start. This will print the invocation command in the log.

    on-run-start: "{{ log('invocation_command: ' ~ flags.INVOCATION_COMMAND, info=true) }}"