---
title: Use tags to attribute and track usage
description: Learn how to add custom tags to resources to monitor cost and accurately attribute Databricks usage to your organization's business units and teams (for example, for chargebacks).
canonical_url: https://docs.databricks.com/aws/en/admin/account-settings/usage-detail-tags
---

# Use tags to attribute and track usage

This article explains how to use tags to attribute compute usage to specific workspaces, teams, projects, or users to support cost tracking and budgeting.

Account and workspace admins can see how much spend is tagged on the [Cost page](https://docs.databricks.com/aws/en/admin/governance-hub/cost.md) in Governance Hub.

There are two types of tags:

* Default tags: Automatically applied by Databricks to cloud-deployed resources. These provide basic metadata like vendor, cluster ID, and creator.
* Custom tags: User-defined tags that you can add to compute resources and serverless workloads. These allow for granular tracking, reporting, and budgeting.

> [!WARNING]
>
> Tag data is stored as plain text and may be replicated globally. Do not use tag names, values, or descriptors that could compromise the security of your resources. For example, do not use tag names, values or descriptors that contain personal or sensitive information.

## Default tags

Databricks automatically adds default tags to compute resources it deploys in your cloud account. These tags attribute the usage to Databricks and provide basic information about the resource, such as its name, ID, and creator.

Default tags automatically propagate to AWS EC2 and AWS EBS instances for cost analysis.

### Default tag keys and values

Databricks applies default tags to compute resources. The exact tag keys depend on the resource type.

#### All-purpose and jobs compute

Databricks adds the following default tags to classic all-purpose and jobs compute:

| Tag key       | Value                                                                                                                                             |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Vendor`      | Constant value: `Databricks`                                                                                                                      |
| `ClusterId`   | Databricks internal ID of the cluster                                                                                                             |
| `ClusterName` | Name of the cluster                                                                                                                               |
| `Creator`     | Username (email address) of the user who created the cluster                                                                                      |
| `RunName`     | Job name (only propagates on jobs compute). If you use the Jobs API 2.0, this is equivalent to `run_name`. In Jobs API 2.1, it is the `task_key`. |
| `JobId`       | Job ID (only propagates on jobs compute)                                                                                                          |

Compute used by data profiling includes these additional 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 |

#### SQL warehouses

Databricks adds the following default tags to SQL warehouses.

| Tag key         | Value                                                          |
| --------------- | -------------------------------------------------------------- |
| `Vendor`        | Constant value: `Databricks`                                   |
| `ClusterId`     | Databricks internal ID of the underlying cluster               |
| `SqlEndpointId` | Databricks internal ID of the SQL warehouse                    |
| `Creator`       | Username (email address) of the user who created the warehouse |

#### Pools

Databricks adds the following default tags to pools and the compute resources created by pools.

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

## Custom tags

Custom tags let you attribute compute usage to specific teams, projects, or cost centers with more granularity than default tags. These tags are applied by users or admins and propagate to both your account's usage logs and applicable cloud resources. These tags are also used to create and monitor budgets in your Databricks account.

### Supported resources for custom tags

You can add custom tags for the following objects managed by Databricks:

| Object                       | Tagging interface (UI)                           | Tagging interface (API)                                                                 |
| ---------------------------- | ------------------------------------------------ | --------------------------------------------------------------------------------------- |
| Workspace                    | N/A                                              | [Account API](https://docs.databricks.com/api/account/introduction)                     |
| Pool                         | Pools UI in the Databricks workspace             | [Instance Pool API](https://docs.databricks.com/api/workspace/instancepools)            |
| All-purpose and job compute  | Compute UI in the Databricks workspace           | [Clusters API](https://docs.databricks.com/api/workspace/clusters)                      |
| SQL warehouse                | SQL warehouse UI in the Databricks workspace     | [Warehouses API](https://docs.databricks.com/api/workspace/warehouses)                  |
| Database instance            | Database instance UI in the Databricks workspace | [Database instances API](https://docs.databricks.com/api/database/v1/database-instance) |
| Lakebase Autoscaling project | Lakebase App in the Databricks workspace         | [Postgres API](https://docs.databricks.com/api/postgres/v1/postgres)                    |

> [!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 Databricks. If you change the value associated with the key `Name`, the cluster can no longer be tracked by Databricks. As a consequence, the cluster might not be terminated after becoming idle and will continue to incur usage costs.

### Tag serverless compute workloads

> [!NOTE]
> **Preview**
>
> This feature is in [Public Preview](https://docs.databricks.com/aws/en/release-notes/release-types.md).

To attribute serverless compute usage to users, groups, or projects, you can use serverless usage policies. When a user is assigned a serverless usage policy, their serverless usage is automatically tagged with their policy's custom tags. Serverless usage policies can be applied to serverless notebooks, jobs, pipelines, and model serving endpoints.

> [!NOTE]
>
> Serverless compute usage is logged in your account's [billable usage system table](https://docs.databricks.com/aws/en/admin/system-tables/billing.md). The legacy [DBU usage reports](https://docs.databricks.com/aws/en/admin/account-settings/usage.md) do not include serverless usage or serverless usage policy tags.

See [Attribute usage with serverless usage policies](https://docs.databricks.com/aws/en/admin/usage/budget-policies.md).

## <a id="tag-propagation" />Tag propagation

Tags are propagated to AWS EC2 instances differently depending on whether or not the cluster was created from a pool.

If a cluster is created from a pool, its EC2 instances inherit only the custom and default workspace tags and pool tags, not the cluster tags. Therefore if you want to create clusters from a pool, make sure to assign all of the custom cluster tags you need to the workspace or pool.

Cluster and pool tags both propagate to [DBU usage reports](https://docs.databricks.com/aws/en/admin/account-settings/usage.md), even if the cluster was created from a pool.

### Tag conflict resolution

When a custom tag (workspace, cluster, or pool tag) has the same key name as a Databricks default tag, the custom tag is automatically prefixed with `x_` during propagation. The default Databricks tag retains its original key name.

For example, Databricks applies a default cluster tag `vendor = Databricks` to all clusters. If you add a custom workspace tag `vendor = AWS Databricks`, this conflicts with the default `vendor` tag. When propagated to AWS usage reports, the custom workspace tag becomes `x_vendor = AWS Databricks`, while the default cluster tag remains `vendor = Databricks`.

> [!WARNING]
>
> Conflicting custom tags added through compute policies do not auto-resolve with the `x_` prefix, causing the cluster or pool to fail with an invalid settings error. Ensure your compute policies do not add any tag keys that conflict with Databricks default tag keys.

### Tag enforcement

To enforce the use of specific custom tags, you can use compute policies. See [Custom tag enforcement](https://docs.databricks.com/aws/en/admin/clusters/policy-definition.md#enforce-tags). To enforce custom tags on serverless compute workloads, use [serverless usage policies](https://docs.databricks.com/aws/en/admin/usage/budget-policies.md).

To ensure that certain tags are always populated when compute resources are created across a workspace, you can apply a specific IAM policy to your workspace's primary IAM role (the one created during workspace setup; contact your AWS administrator if you need access). The IAM policy should include explicit [Deny statements](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_evaluation-logic.html#AccessPolicyLanguage_Interplay) for mandatory tag keys and optional values. *Cluster creation will fail* if required tags with one of the allowed values aren't provided.

For example, if you want to enforce `Department` and `Project` tags, with only specified values allowed for the former and a free-form non-empty value for the latter, you could apply an IAM policy like this one:

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "MandateLaunchWithTag1",
      "Effect": "Deny",
      "Action": ["ec2:RunInstances", "ec2:CreateTags"],
      "Resource": "arn:aws:ec2:region:accountId:instance/*",
      "Condition": {
        "StringNotEqualsIgnoreCase": {
          "aws:RequestTag/Department": ["Deptt1", "Deptt2", "Deptt3"]
        }
      }
    },
    {
      "Sid": "MandateLaunchWithTag2",
      "Effect": "Deny",
      "Action": ["ec2:RunInstances", "ec2:CreateTags"],
      "Resource": "arn:aws:ec2:region:accountId:instance/*",
      "Condition": {
        "StringNotLike": {
          "aws:RequestTag/Project": "?*"
        }
      }
    }
  ]
}
```

Both `ec2:RunInstances` and `ec2:CreateTags` actions are required for each tag for effective coverage of scenarios in which there are clusters that have only on-demand instances, only spot instances, or both.

> [!TIP]
>
> Databricks recommends that you add a separate policy statement for each tag. The overall policy might become long, but it is easier to debug. See the [IAM Policy Condition Operators Reference](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html) for a list of operators that can be used in a policy.

Cluster creation errors due to an IAM policy show an `encoded error message`, starting with:

```console
Cloud Provider Launch Failure: A cloud provider error was encountered while setting up the cluster.
```

The message is encoded because the details of the authorization status can constitute privileged information that the user who requested the action should not see. See [DecodeAuthorizationMessage API](https://docs.aws.amazon.com/STS/latest/APIReference/API_DecodeAuthorizationMessage.html) (or [CLI](https://docs.aws.amazon.com/cli/latest/reference/sts/decode-authorization-message.html)) for information about how to decode such messages.

## Limitations

* Tag keys and values can only contain letters, numbers, or the characters `+`, `-`, `=`, `.`, `,`, `_`, `:`, `@`. Tag keys and values cannot contain spaces or `/`. Tag keys cannot consist only of `.` (one period), `..` (two periods), or `_index`. Tags that do not meet these requirements are invalid. These character restrictions are set by AWS.
* If you change tag keys 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.
* It can take up to one hour for custom workspace tags to propagate after any change.
* No more than 20 tags can be assigned to a workspace resource.
