Granular Usage Attribution for dbt Pipelines with Query Tags

· Source: Databricks · Field: Technology & Digital — Data Science & Analytics, Software Development & Engineering, Cloud Computing & IT Infrastructure · Depth: Intermediate, medium

Summary

Databricks has introduced Query Tags, now in Public Preview, for dbt pipelines, enabling granular usage attribution and performance monitoring. The dbt-databricks adapter (version 1.11+) natively supports these tags, which are recorded in system.query.history. Tags can be auto-injected, providing metadata like "@@dbt_model_name" and "@@dbt_materialized" without configuration. Users can also define custom tags at the profile level (e.g., team, cost_center, project_name, env) or model level for more specific attribution. This functionality allows data teams to perform cost attribution, debug performance, and monitor workloads using simple SQL queries. A complete open-source dbt project demonstrates end-to-end configuration and dashboarding for these tags, revealing insights like specific mart tables consuming 92% of compute time in a reference project.

Key takeaway

For MLOps Engineers or Data Engineers managing dbt pipelines on Databricks, implementing Query Tags is crucial for gaining visibility into warehouse costs and performance. You can quickly identify which models or teams consume the most resources, enabling targeted optimization efforts and accurate financial attribution. Start by configuring profile-level tags for broad coverage and leverage auto-injected tags for immediate model-level insights, then explore the provided GitHub repository for a deployable self-monitoring dashboard.

Key insights

Databricks Query Tags provide granular cost and performance attribution for dbt pipelines via auto-injected and custom metadata.

Principles

Method

Configure "query_tags" in "profiles.yml" for project-wide application or in "dbt_project.yml" or model SQL for specific models. Query "system.query.history" using map access syntax to analyze tagged data.

In practice

Topics

Code references

Best for: Data Engineer, Analytics Engineer, MLOps Engineer

Related on AIssential

Open in AIssential →

Editorial summary, takeaway, and curation by AIssential. Original article published by Databricks.