SYSTEM$GET_DBT_LOG
functionsupportedContainer services & dev toolingReturns logs for the specified run for a dbt Projects on Snowflake. Use this function with the DBT_PROJECT_EXECUTION_HISTORY function to access dbt artifacts and logs programmatically.
Syntax
supportedpartialnot supportednot scored
SYSTEM$GET_DBT_LOG ( '<query_id>' [ , <max_num_lines> ] )
Parameters
| Name | Required | Description |
|---|---|---|
query_id | required | Query ID of the run that you want logs for. |
max_num_lines | required | Optional. Maximum number of lines to return from the end of the dbt.log file. Defaults to 1000. The combined size of the returned lines is capped at approximately 10 MB. If the lines you request exceed this limit, the function drops the oldest lines from the start of the result until it fits, so the output always reflects the most recent lines in the log. |
Returns
The function returns up to max_num_lines lines from the end of the dbt.log file (1,000 lines by default). For full logs, download the archive ZIP file. For more information and examples, see Access dbt artifacts and logs programmatically.
Usage notes
- This system function works only on dbt project objects and isn’t available for Workspaces.
- Query IDs generated from CREATE DBT PROJECT or ALTER DBT PROJECT … DEPLOY aren’t supported for this system function.
- Direct querying of file content (for example, Query examples) isn’t supported.
- If query_id is NULL or not a dbt execution, you’ll get an error.
- dbt project results are available for up to 14 days.
- Logs might be unavailable if a run times out, is canceled, or fails before files are uploaded. In such cases, runs appear as UNHANDLED ERROR in dbt history, and these entries might not include logs.
- You can’t use this function to get logs for runs that are in progress because the logs file is only available after the run is complete.
Access control requirements
This function can only be used with dbt project objects, not Workspaces, when you have one of the following privileges: - OWNERSHIP, USAGE, or MONITOR on the dbt project object For details about these privileges, see dbt project object privileges. Operating on an object in a schema requires at least one privilege on the parent database and at least one privilege on the parent schema. For instructions on creating a custom role with a specified set of privileges, see Creating custom roles. For general information about roles and privilege grants for performing SQL actions on securable objects, see Overview of Access Control.