|
| 1 | +--- |
| 2 | +title: Organize CockroachDB Cloud Resources Using Labels |
| 3 | +summary: Learn how to use labels to organize CockroachDB Cloud clusters and folders. |
| 4 | +toc: true |
| 5 | +docs_area: manage |
| 6 | +--- |
| 7 | + |
| 8 | +CockroachDB {{ site.data.products.cloud }} supports labels as a flexible way to categorize and manage your [clusters]({% link cockroachcloud/cluster-management.md %}) and [folders]({% link cockroachcloud/folders.md %}). Labels help you track usage, analyze [billing]({% link cockroachcloud/billing-management.md %}#view-credits-balance), automate operations, and streamline reporting across your organization. |
| 9 | + |
| 10 | +## What are labels? |
| 11 | + |
| 12 | +Labels are customizable key-value pairs that you can attach to CockroachDB {{ site.data.products.cloud }} resources. Unlike folders, which allow one-to-many relationships, labels support many-to-many relationships, ideal for complex environments which require a variety of tagging criteria. |
| 13 | + |
| 14 | +## Common use cases |
| 15 | + |
| 16 | +You can set labels for: |
| 17 | + |
| 18 | +- **Environment tracking**: Distinguish between stages like `environment:production`, `environment:staging`, or `environment:test` to simplify deployment workflows and access control. |
| 19 | +- **Cost allocation**: Use labels like `team:analytics` or `cost_center:finance` to track usage and spending across departments in billing exports. |
| 20 | +- **Ownership and accountability**: Assign operational responsibility with labels such as `team:order-management` or `owner:platform-engineering`. |
| 21 | +- **Automation and lifecycle management**: Automate actions using labels like `state:active`, `state:archive`, or `state:ready-to-delete` in scripts and infrastructure-as-code tools. |
| 22 | +- **Custom organization**: Apply labels based on application, region, or any other criteria relevant to your workflows, e.g. the application, workload, or region applicable to a cluster. |
| 23 | + |
| 24 | +These labels can then be used to: |
| 25 | + |
| 26 | +- Filter and group resources in the Console. |
| 27 | +- Power cost reports and analytics. |
| 28 | +- Drive automation through APIs or Terraform. |
| 29 | +- Provide consistent metadata across teams and environments. |
| 30 | + |
| 31 | +## Requirements for labels |
| 32 | + |
| 33 | +The labels applied to a resource must meet the following requirements: |
| 34 | + |
| 35 | +- Each resource can have up to 50 labels. |
| 36 | +- Label keys are required, and must start with a lowercase letter and can include lowercase letters, numbers, underscores, and dashes (up to 63 characters). |
| 37 | +- Label values can include only lowercase letters, numbers, dashes, and must be between 0 and 63 characters. |
| 38 | +- Keys are unique per resource. For example, if cluster A has a label `environment:production`, it cannot also have a label `environment:development`. |
| 39 | +- Across the organization, each key can have multiple values. For example, folder A can have a label `environment:development`, folder B can have a label `environment:testing`, and folder C can have a label `environment:production`. |
| 40 | +- Labels are visible across your organization once created. |
| 41 | + |
| 42 | +## Edit labels |
| 43 | + |
| 44 | +You can apply labels to your cluster or folder through the [CockroachDB {{ site.data.products.cloud }} Console](https://cockroachlabs.cloud/) or using the CockroachDB Cloud API (refer to the schema for creating a [cluster](https://www.cockroachlabs.com/docs/api/cloud/v1#post-/api/v1/clusters) or [folder](https://www.cockroachlabs.com/docs/api/cloud/v1#post-/api/v1/folders)) or [Terraform provider](https://registry.terraform.io/providers/cockroachdb/cockroach/latest/docs). |
| 45 | + |
| 46 | +Adding or deleting labels on a cluster requires the [Cluster Admin]({% link cockroachcloud/authorization.md %}#cluster-administrator) or [Cluster Operator]({% link cockroachcloud/authorization.md %}#cluster-operator) role. |
| 47 | + |
| 48 | +1. Navigate to the cluster on the [**Clusters** page]({% link cockroachcloud/cluster-management.md %}#view-clusters-page) and click the menu button in the **Action** column. Alternatively, navigate to the [**Overview** page]({% link cockroachcloud/cluster-management.md %}#view-cluster-overview) for the cluster and click **Actions** in the top right corner. |
| 49 | +1. In the dropdown menu, select **Edit cluster labels** to open the **Edit labels** window. |
| 50 | + |
| 51 | +Adding or deleting labels on a folder requires the [Folder Admin]({% link cockroachcloud/authorization.md %}#folder-admin) role. |
| 52 | + |
| 53 | +1. Navigate to the folder on the [**Clusters** page]({% link cockroachcloud/cluster-management.md %}#view-clusters-page) and click the menu button in the **Action** column. |
| 54 | +1. In the dropdown menu, select **Edit folder labels** to open the **Edit labels** window. |
| 55 | + |
| 56 | +### Add labels |
| 57 | + |
| 58 | +To add a label in the **Edit labels** window: |
| 59 | + |
| 60 | +1. Enter a label key and an optional label value. Autocomplete helps avoid typos and duplicates. |
| 61 | +1. Click **+ Add**. The label appears under **Labels applied**. |
| 62 | +1. Repeat steps 1 and 2 to add more labels. |
| 63 | +1. Click **Add/Update Labels** to apply the changes. A success or failure notification will appear at the top right. |
| 64 | + |
| 65 | +### Delete labels |
| 66 | + |
| 67 | +To delete a label in the **Edit labels** window: |
| 68 | + |
| 69 | +1. Under **Labels applied**, click the **X** on the right of the label you want to delete. |
| 70 | +1. Repeat step 1 to delete more labels. |
| 71 | +1. Click **Update Labels** to apply the changes. A success or failure notification will appear at the top right. |
| 72 | + |
| 73 | +To change a label, delete the existing label and add a new one. |
| 74 | + |
| 75 | +## Cost and billing integration |
| 76 | + |
| 77 | +Labels appear in invoices on the [**Billing** page]({% link cockroachcloud/billing-management.md %}#view-credits-balance). |
| 78 | + |
| 79 | +## Best Practices |
| 80 | + |
| 81 | +- Define a consistent labeling taxonomy (e.g., `team`, `env`, `app`) across your organization. |
| 82 | +- Use autocomplete in the console to prevent the duplication of keys. |
| 83 | +- Regularly review and remove unused or outdated labels. |
0 commit comments