Configure labels for services Stay organized with collections Save and categorize content based on your preferences.
Cloud Run labels are key-value pairs that are applied toCloud Run service and revisions. This page shows how to set, modify, anddelete labels on your Cloud Run service and revisions.Note that when you set a label on a Cloud Runservice, a new revision with this label is created for thisservice; the label is not applied to older revisions.
Possible uses include:
- Cost allocation and billing breakdowns.
- Identify resources used by individual teams or cost centers.
- Distinguish deployment environments (prod, staging, qa, or test).
- Identify owners and state labels.
- Filter logs in Logging.
Labels usage rules
The following rule applies to the use of labels set on aCloud Run service:
Onlyvalid Google Cloud labels can be used on Cloud Run.
Required roles
To get the permissions that you need to configure and deploy Cloud Run services, ask your administrator to grant you the following IAM roles:
- Cloud Run Developer (
roles/run.developer) on the Cloud Run service - Service Account User (
roles/iam.serviceAccountUser) on the service identity
If you are deploying aserviceorfunction from source code, youmust also have additional roles granted to you on your project andCloud Build service account.
For a list of IAM roles and permissions that are associated withCloud Run, seeCloud Run IAM rolesandCloud Run IAM permissions.If your Cloud Run service interfaces withGoogle Cloud APIs, such as Cloud Client Libraries, see theservice identity configuration guide.For more information about granting roles, seedeployment permissionsandmanage access.
Set or modify labels
Any configuration change leads to thecreation of a new revision. Subsequent revisions will also automatically getthis configuration setting unless you make explicit updates to change it.
Labels you previously set for your Cloud Run functions using eithergcloud functions commands or the Cloud Functions v2 API propagate to Cloud Run when youdeploy your functions in Cloud Run.
You can set or modify labels using the Google Cloud console, the Google Cloud CLI,or a YAML file when youdeploy a new revision.
Console
In the Google Cloud console, go to the Cloud RunServices page:
Check the checkbox at the left of the service you are setting the labelon.
Make sure theInfo Panel at the far right is toggled on(Show Info Panel).
ClickLabels to display the labels pane.

To edit an existing label key value, locate the label and change theValue.
To set a new label on the service, clickAdd Label and supply the keyand the value.
ClickSave
gcloud
You can update labels for a service using the command:
gcloudrunservicesupdateSERVICE--update-labelsKEY=VALUE
To update more than one label, supply a comma delimited list of key-value pairs. Note that theupdate-labels command sets a new value for the label key if the label already exists, otherwise it creates a new label.
Replace the following:
- SERVICE: the name of your Cloud Run service
- KEY: the name of your label key
- VALUE: the value for the key
You can also set labels duringdeployment:
gcloudrundeploySERVICE--imageIMAGE--labelsKEY=VALUE
To create more than one label during deployment, supply a comma delimitedlist of key-value pairs.
YAML
If you are creating a new service, skip this step.If you are updating an existing service, download itsYAML configuration:
gcloudrunservicesdescribeSERVICE--formatexport>service.yamlUpdate the
labelsattributes in two places:apiVersion:serving.knative.dev/v1kind:Servicemetadata:name:SERVICElabels:LABEL:VALUEspec:template:metadata:labels:LABEL:VALUEname:REVISION
Replace the following:
- SERVICE: the name of your Cloud Run service
- LABEL: the name of the label
- VALUE: the required value
- REVISION with a new revision name or delete it (if present). If you supply a new revision name, itmust meet the following criteria:
- Starts with
SERVICE- - Contains only lowercase letters, numbers and
- - Does not end with a
- - Does not exceed 63 characters
- Starts with
metadata.labelssets labels on the service object, whilespec.template.metadata.labelsets labels on the created revision.Only labels set on the revision are passed to logs and billing.Create or update the service using the following command:
gcloudrunservicesreplaceservice.yaml
Terraform
To learn how to apply or remove a Terraform configuration, seeBasic Terraform commands.
Add the following to agoogle_cloud_run_v2_service resource in your Terraform configuration:resource"google_cloud_run_v2_service""default"{name="cloudrun-service-labels"location="us-central1"deletion_protection=false # set to "true" in productiontemplate{containers{image="us-docker.pkg.dev/cloudrun/container/hello"} # Labelslabels={foo:"bar"baz:"quux"}}}The preceding snippet adds two labels,foo (whose value isbar) andbaz(whose value isquux), to your Cloud Run instance.
Adding the labels undertemplate sets the labels for the revision: onlylabels set for the revision are passed to logs and billing. If you add thelabels to a location other than undertemplate, the label is set for theservice not the revision.
Replace the following:
name: the name of your service.location: the location used for your service.image: your container image.fooandbaz: your own label names.barandquux: your own label values.
List services by label
You can list services by label using aGoogle Cloud CLI filter:
gcloudrunserviceslist--filtermetadata.labels.LABEL=VALUEReplace the following:
- LABEL: the name of the label
- VALUE: the value to include in your filtered list
Delete a label on a service
You can use the console or the command line delete labels on a service.
Console
In the Google Cloud console, go to the Cloud RunServices page:
Check the checkbox at the left of the service you are deleting the labelfrom.
Make sure theInfo Panel at the far right is toggled on(Show Info Panel).
ClickLabels to display the labels pane.
Locate the label you want to delete.
Hover your cursor to the right of theValue textbox for the label todisplay the trash icon, and click the trash icon.
ClickSave.
gcloud
To clear all labels from a service:
gcloudrunservicesupdateSERVICE--clear-labels
To delete specific labels from a service, supply a comma delimited list ofkeys:
gcloudrunservicesupdateSERVICE--remove-labelsLABEL
Replace the following:
- SERVICE: the name of your Cloud Run service
- LABEL: the name of your label
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-02-19 UTC.