Properly attributing Databricks costs requires three things to come together: consistent tagging, effective use of usage logs, and automated chargeback calculation. This article walks through custom_tags design principles, SQL aggregation against system.billing.usage, tag enforcement via Cluster Policy, and how to choose a chargeback model — all grounded in real-world practice.
Attribution is the mechanism that makes it transparent which organization or project bears which DBU cost. In Databricks, in addition to DBU (Databricks Unit) consumption, cloud infrastructure costs (VMs and storage) are also subject to allocation.
The standard approach is to split costs into platform costs (operational cost of the shared foundation) and product costs (compute consumption tied to individual projects), allocating the former across the company and chargingback the latter via tags.
Tags are the foreign key of cost attribution. Align the custom_tags set on Databricks clusters, job clusters, pools, and SQL Warehouses with the cloud-side billing tags (AWS Cost Allocation Tags / Azure Tags / GCP Labels).
Keep keys few and high-signal, and manage values in a master table. Avoid high-cardinality values (ticket numbers, ephemeral IDs); adopt only stable keys.
| Tag Key | Purpose | Example Values | Governance Policy |
|---|---|---|---|
| cost_center | Identify the bearing department | CC-100, CC-200, CC-999 | Pre-registered via ledger PR |
| env | Environment classification | dev, stg, prod | Fixed 3 values |
| product | Product identification | recommendation, fraud-detection | Pre-registered via ledger PR |
| owner | Owner | team-data-eng, team-ml | Team-level (avoid personal names) |
Standardize naming on lowercase letters, digits, and hyphens only, and conform to each cloud's tag constraints (Azure: 512-char tag name / 256-char value; GCP: 63-char label key). Define fallback values for unknowns (such as CC-999), and operate by issuing monthly correction requests.
To structurally prevent missing tags, make custom_tags required via Cluster Policy and restrict values with an allowlist. Applying the same keys uniformly across job clusters, all-purpose clusters, and SQL Warehouses guarantees that values are recorded in the tags field of the Billable Usage log.
{
"custom_tags.cost_center": {
"type": "allowlist",
"values": ["CC-100", "CC-200", "CC-300", "CC-999"],
"defaultValue": "CC-999"
},
"custom_tags.env": {
"type": "allowlist",
"values": ["dev", "stg", "prod"],
"defaultValue": "dev"
},
"custom_tags.product": {
"type": "allowlist",
"values": ["recommendation", "fraud-detection", "analytics", "platform"],
"defaultValue": "platform"
},
"autotermination_minutes": {
"type": "range",
"minValue": 10,
"maxValue": 120,
"defaultValue": 30
}
}Once this policy is assigned to users/groups, clusters cannot be created without selecting tags. Grant the Unrestricted Policy to administrators only, and always apply a tag-bearing policy to regular users.
The system.billing.usage table in Unity Catalog's system schema records DBU consumption by workspace, SKU, and tag. By writing SQL against it, you can run tag-based cost aggregation directly.
Here is an example SQL that aggregates monthly DBU consumption by cost center.
SELECT
usage_metadata.workspace_id,
custom_tags.cost_center AS cost_center,
sku_name,
usage_date,
SUM(usage_quantity) AS total_dbu
FROM system.billing.usage
WHERE usage_date >= '2026-03-01'
AND usage_date < '2026-04-01'
GROUP BY 1, 2, 3, 4
ORDER BY total_dbu DESCHere is an example cross-aggregation by product and environment for detecting bloated dev environments.
SELECT
custom_tags.product AS product,
custom_tags.env AS env,
SUM(usage_quantity) AS total_dbu,
ROUND(SUM(usage_quantity) * 0.07, 2) AS estimated_cost_usd
FROM system.billing.usage
WHERE usage_date >= DATE_SUB(CURRENT_DATE(), 30)
GROUP BY 1, 2
HAVING total_dbu > 1000
ORDER BY total_dbu DESCThe estimated_cost_usd above is a rough estimate at list price (for example, Jobs Compute at $0.07/DBU). If your contracted price differs, join a separate unit-price master table.
Here is a sample query that detects usage on untagged resources and corrects it monthly.
SELECT
usage_metadata.workspace_id,
usage_metadata.cluster_id,
sku_name,
SUM(usage_quantity) AS untagged_dbu
FROM system.billing.usage
WHERE usage_date >= DATE_SUB(CURRENT_DATE(), 30)
AND (custom_tags.cost_center IS NULL
OR custom_tags.cost_center = 'CC-999')
GROUP BY 1, 2, 3
ORDER BY untagged_dbu DESCUsage that has been pooled under CC-999 (the fallback value) is reallocated to the correct cost center during the monthly inventory. Wiring this query result into a SQL alert and sending a Slack notification when a threshold is exceeded works well in practice.
Allocation methods involve a tradeoff between accuracy and operational burden. The table below compares representative patterns.
| Allocation Method | Granularity | Pros | Caveats |
|---|---|---|---|
| DBU x tag direct allocation | Cluster/Job/SQL Warehouse | Most accurate; self-contained within system.billing.usage | Requires 100% tag coverage |
| Workspace split allocation | Workspaces separated by organization | Simple, no tags needed | Operational burden grows as workspaces proliferate |
| Shared cluster proration | User/job execution-time ratio | Fair for shared environments | Requires aggregating extra metrics |
| Cloud billing x billing tags | VM/disk/network | Provides the full picture including non-DB costs | Tag coverage is limited under Serverless |
In practice, a hybrid approach is most stable: anchor on "DBU x tag direct allocation," pool tag-missing usage in CC-999 and reallocate monthly, prorate shared resources by execution time ratio, and complement infrastructure costs via cloud billing with shared tags.
Here is the end-to-end flow for tag-based allocation. Automating each step minimizes the effort required for monthly reporting.
[Cluster Policy]
└─ Enforce custom_tags (cost_center, env, product)
│
v
[Resource execution] → Cluster / Job / SQL Warehouse
│ tags auto-recorded
v
[system.billing.usage]
│
├─ SQL aggregation → DBU by cost center
├─ Tag-missing detection → CC-999 report
└─ JOIN unit-price master → Convert to currency
│
v
[Attribution table (Delta)]
│
├─ Monthly snapshot
├─ Adjustment journal rows
└─ Dashboard / GL integrationManage the tag ledger (the master for cost_center, product, etc.) in a Git repository and gate value additions through PR review. This prevents duplicates and typos from creeping in, and keeps the Policy definitions and ledger in sync.
Manage the attribution table as Delta so that if changes occur after monthly close, Time Travel can be used to reference the snapshot at close time.
Administration / Data Engineer
問題 1
A data platform team is building a chargeback mechanism that allocates DBU consumption across all projects by cost center. They need cost_center tags to be reliably recorded on both clusters and job clusters, and to run SQL aggregation monthly. Which is the most appropriate approach?
正解: A
Enforcing tags via a Cluster Policy allowlist structurally prevents missing input, and SQL against system.billing.usage automates tag-based aggregation. Documentation requests alone lack enforcement and lead to omissions. Unity Catalog catalog tags are for data governance and are not a valid basis for DBU allocation. Cloud Billing alone has limited tag coverage for Serverless resources.
How long is data retained in system.billing.usage?
The system.billing.usage table retains the last 365 days of data at the account level. For long-term analysis, schedule periodic exports to a Delta table. You can also download usage as CSV, but writing SQL directly against the system table gives far more flexibility for filtering and aggregation, and makes it easier to automate tag-based or SKU-based attribution.
If I change a tag later, does it apply retroactively to past usage data?
No. Tags are recorded in Billable Usage as a snapshot at the time of resource execution. Past records cannot be re-tagged, so the practical approach for errors discovered after monthly close is to add adjustment journal rows to the attribution table. The best safeguard is to enforce tags via Cluster Policy so omissions are prevented structurally at recording time.
Can I do tag-based chargeback for Serverless SQL Warehouse too?
Yes. DBU usage for Serverless resources is also recorded in system.billing.usage and includes metadata such as custom_tags and workspace_id. However, the underlying cloud infrastructure (VMs and storage) is managed by Databricks, so tag-level breakdowns on the cloud billing side are limited. A design that anchors attribution on DBU usage is the most stable approach.
Practice with certification-focused question sets
無料で問題を解いてみるNicheeLab Editorial Team
NicheeLab editorial team focused on data engineering and cloud certification learning. Content is structured around practical study needs and official exam domains.
Databricks Certifications: All 7 Exams, Difficulty & Study Plan (2026)
Complete guide to all 7 Databricks certifications — Data Eng...
Databricks Exam Difficulty Ranking: All 7 Certs Compared (2026)
Every Databricks certification ranked by difficulty, with st...
Databricks Study Guide: Fastest Pass Route & Time Estimates (2026)
How to pass Databricks certifications efficiently. Official ...
Databricks Data Engineer Associate: Complete Guide (2026)
Domain-by-domain breakdown of the Databricks Certified Data ...
Databricks Data Engineer Professional: Complete Guide (2026)
Tactics for the Databricks Certified Data Engineer Professio...