Monitor usage using tags

To monitor cost and accurately attribute Azure Databricks usage to your organization’s business units and teams (for chargebacks, for example), you can tag workspaces (resource groups) and compute resources. These tags propagate to detailed cost analysis reports that you can access in the Azure portal. Note: Tag data may be replicated globally. Do not use tag names or values that could compromise the security of your resources. For example, do not use tag names that contain personal or sensitive information. Here is a cost analysis invoice details report in the Azure portal that details cost by clusterid tag over a one-month period:

Cost analysis by cluster ID

Tagged objects and resources

Object Tagging interface (UI) Tagging interface (API)
Workspace Azure Portal Azure Resources API
Pool Pools UI in the Azure Databricks workspace Instance Pool API
All-purpose and job compute Compute UI in the Azure Databricks workspace Clusters API
SQL warehouse SQL warehouse UI in the Azure Databricks workspace Warehouses API

Warning

Do not assign a custom tag with the key Name to a cluster. Every cluster has a tag Name whose value is set by Azure Databricks. If you change the value associated with the key Name, the cluster can no longer be tracked by Azure Databricks. As a consequence, the cluster might not be terminated after becoming idle and will continue to incur usage costs.

Default tags

Azure Databricks adds the following default tags to all-purpose compute:

Tag key Value
Vendor Constant value: Databricks
ClusterId Azure Databricks internal ID of the cluster
ClusterName Name of the cluster
Creator Username (email address) of the user who created the cluster

On job clusters, Azure Databricks also applies the following default tags:

Tag key Value
RunName Job name
JobId Job ID

Azure Databricks adds the following default tags to all pools:

Tag key Value
Vendor Constant value: Databricks
DatabricksInstancePoolCreatorId Azure Databricks internal ID of the user who created the pool
DatabricksInstancePoolId Azure Databricks internal ID of the pool

On compute used by Lakehouse Monitoring, Azure Databricks also applies the following tags:

Tag key Value
LakehouseMonitoring true
LakehouseMonitoringTableId ID of the monitored table
LakehouseMonitoringWorkspaceId ID of the workspace where the monitor was created
LakehouseMonitoringMetastoreId ID of the metastore where the monitored table exists

Tag propagation

Workspace, pool, and cluster tags are aggregated by Azure Databricks and propagated to Azure VMs for cost analysis reporting. But pool and cluster tags are propagated differently from each other.

Databricks object tagging hierarchy

Workspace and pool tags are aggregated and assigned as resource tags of the Azure VMs that host the pools.

Workspace and cluster tags are aggregated and assigned as resource tags of the Azure VMs that host the clusters.

When clusters are created from pools, only workspace tags and pool tags are propagated to the VMs. Cluster tags are not propagated, in order to preserve pool cluster startup performance.

Tag conflict resolution

If a custom cluster tag, pool tag, or workspace tag has the same name as an Azure Databricks default cluster or pool tag, the custom tag is prefixed with an x_ when it is propagated.

For example, if a workspace is tagged with vendor = Azure Databricks, that tag will conflict with the default cluster tag vendor = Databricks. The tags will therefore be propagated as x_vendor = Azure Databricks and vendor = Databricks.

Limitations

  • It can take up to one hour for custom workspace tags to propagate to Azure Databricks after any change.
  • No more than 50 tags can be assigned to an Azure resource. If the overall count of aggregated tags exceeds this limit, x_-prefixed tags are evaluated in alphabetical order and those that exceed the limit are ignored. If all x_-prefixed tags are ignored and the count is till over the limit, the remaining tags are evaluated in alphabetical order and those that exceed the limit are ignored.
  • Tag keys and values can only contain letters, spaces, numbers, or the characters +, -, =, ., _, :, /, @. Tags containing other characters are invalid.
  • If you change tag key names or values, these changes apply only after cluster restart or pool expansion.
  • If the cluster’s custom tags conflict with a pool’s custom tags, the cluster can’t be created.

Tag enforcement with policies

You can enforce tags on clusters using compute policies. For more information, see Custom tag enforcement.