Creating and Managing Labels

This page gives a brief overview of labels and explains how to create and manage labels using the Google Cloud Resource Manager API and the Google Cloud Platform Console.

What are labels?

A label is a key-value pair that helps you organize your Google Cloud Platform resources, such as instances. You can attach a label to each resource, then filter the resources based on their labels. Information about labels is forwarded to the billing system, so you can break down your billing charges by label.

Common uses of labels

Here are some common use cases for labels:

  • Team or cost center labels: Add labels based on team or cost center to distinguish instances owned by different teams (for example, team:research and team:analytics). You can use this type of label for cost accounting or budgeting.

  • Component labels: For example, component:redis, component:frontend, component:ingest, and component:dashboard.

  • Environment or stage labels: For example, environment:production and environment:test.

  • Owner or contact labels: Add labels based on the owner or a primary contact for instances.

  • State labels: For example, state:active, state:readytodelete, and state:archive.

  • Virtual machine labels: A label can be attached to a virtual machine. Virtual machine tags that you defined in the past will appear as a label without a value.

Requirements for labels

The labels applied to a resource must meet the following requirements:

  • Each resource can have multiple labels, up to a maximum of 64.
  • Each label must be a key-value pair.
  • Keys have a minimum length of 1 character and a maximum length of 63 characters, and cannot be empty. Values can be empty, and have a maximum length of 63 characters.
  • Keys and values can contain only lowercase letters, numeric characters, underscores, and dashes. All characters must use UTF-8 encoding, and international characters are allowed.
  • The key portion of a label must be unique. However, you can use the same key with multiple resources.
  • Keys must start with a lowercase letter or international character.

For a given reporting service and project, the number of distinct key-value pair combinations that will be preserved within a one-hour window is 1,000. For example, the Compute Engine service reports metrics on virtual machine (VM) instances. If you deploy a project with 2,000 VMs, each with a distinct label, the service reports metrics are preserved for only the first 1,000 labels that exist within the one-hour window.

Creating and managing labels using the Resource Manager API

To create a new project with a label, set the label field when you create the project.




 "labels": {
  "color": "red"
 "name": "myproject",
 "projectId": "our-project-123"

 "projectNumber": "333197460082",
 "projectId": "our-project-123",
 "lifecycleState": "ACTIVE",
 "name": "myproject",
 "labels": {
  "color": "red"
 "createTime": "2016-01-12T22:18:28.633Z",



  project = crm.projects().create(
        'project_id': flags.projectId,
        'name': 'myproject',
        labels.color: "red"


To add labels for existing projects:

  • Get the project using the get() method.
  • Modify the label field.
  • Update the project using the update() method.

For details about updating a project's labels, see Updating a Project.

For details about using labels to filter projects, see Listing Projects.

Creating and managing labels using the GCP Console

To add labels to a single project:

  1. Open the Labels page in the GCP Console.
    Open the Labels page
  2. Select your project from the Select a project drop-down.
  3. To add a new label entry, click + Add label and enter a label key and value for each label you want to add.
  4. When you're finished adding labels, click Save.

To add labels for more than one project at the same time:

  1. Open the Manage resources page in the GCP Console.
    Open the Manage resources page
  2. On the Manage resources page, select the organization and projects for which you want to add labels.
  3. On the right side panel, in the Labels tab, click + Add label and enter a label key and value for each label you want to add.
  4. When you're finished adding labels, click Save.

After you add labels, you can filter projects by typing a label key or value in the filter box above the projects list. The filter box will suggest keys and values so you can preview results.

Services currently supporting labels

The following GCP services support labels today:

  • Cloud Functions
  • Networking
  • Cloud SQL
  • Compute Engine
  • Deployment Manager
  • Kubernetes Engine
  • Cloud Storage
  • Cloud Dataproc
  • Cloud Spanner
  • Cloud Dataflow
  • BigQuery
  • Resource Manager
  • Cloud Bigtable

Send feedback about...

Google Cloud Resource Manager Documentation