This page shows you how to use labels with your Filestore instances. It also describes how to add, update, and delete the labels for an instance. Labels let you group related instances and store metadata about an instance.
What are labels?
A label is a key-value pair that you can assign to Google Cloud Filestore instances. They help you organize these resources and manage your costs at scale, with the granularity you need. 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 that allows you to break down your billed charges by label. With built-in billing reports, you can filter and group costs by resource labels. You can also use labels to query billing data exports.
Requirements for labels
The labels applied to a resource must meet the following requirements:
- Each resource can have up to 64 labels.
- 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. Keys must start with a lowercase letter or international character.
- The key portion of a label must be unique within a single resource. However, you can use the same key with multiple resources.
These limits apply to the key and value for each label, and to the individual Google Cloud resources that have labels. There is no limit on how many labels you can apply across all resources within a project.
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 Filestore instances owned by different teams (for example,
team:analytics). You can use this type of label for cost accounting or budgeting.
Component labels: For example,
Environment or stage labels: For example,
State labels: For example,
Ownership labels: Used to identify the teams that are responsible for operations, for example:
We do not recommend creating large numbers of unique labels, such as for timestamps or individual values for every API call. The problem with this approach is that when the values change frequently or with keys that clutter the catalog, this makes it difficult to effectively filter and report on resources.
Labels and tags
Labels can be used as queryable annotations for resources, but can't be used to set conditions on policies. Tags provide a way to conditionally allow or deny policies based on whether a resource has a specific tag, by providing fine-grained control over policies. For more information, see the Tags overview.
Adding or updating an instance's labels
You can add labels to a Filestore instance when you create the instance. After an instance is created, you can add more labels to the instance, as well as update or delete existing labels.
In the Google Cloud console, go to the Filestore Instances page.
Select the checkbox next to each instance whose labels you want to modify.
Click Show info panel.
Add and update labels as needed:
Operation Instructions Add a label Click Add label and type the key and value for the label. Update a label Update the Value field. You cannot update the Key of an existing label. Delete a label Click Delete item delete next to the label.
Click Save to save your changes once you are finished with your updates.
You can edit the labels of a Filestore instance's by running the
instances update command.
To add new labels or change the values of existing labels, use the
--update-labels flag. To delete one or more labels, use the
--clear-labels flag removes all labels from an instance.
gcloud filestore instances update instance-id \ --project=project-id \ --zone=zone \ --update-labels key=value,[key=value,…] \ --remove-labels key,[key,…] \ --clear-labels
- instance-id is the instance ID of the instance you want to edit.
project-id is the project ID of the Google Cloud project that contains the Filestore instance. You can skip this flag if the Filestore instance is in the
gclouddefault project. You can set the default project by running:
gcloud config set project project-id
zone is the zone where the Filestore instance resides. Run the
gcloud filestore zones listcommand to get a list of supported zones. You can skip this flag if the Filestore instance is in the
gclouddefault zone. You can set the default zone by running:
gcloud config set filestore/zone zone
key is a new label, or an existing label you want to change or remove.
value is the value for a label.
The following example updates the nfs-server instance by adding the status label, updating the dept label value, and removing the admin label.
gcloud filestore instances update nfs-server \ --project=myproject \ --zone=us-central1-c \ --update-labels status=active \ --update-labels dept=accounting \ --remove-labels admin
Services currently supporting labels
The following Google Cloud services support labels today:
- AI Platform
- App Engine (both Flexible and Standard environments)
- Artifact Registry
- Certificate Authority Service
- Cloud Composer
- Cloud Bigtable
- Cloud Deployment Manager
- Cloud Functions
- Cloud Healthcare API
- Cloud Key Management Service
- Cloud Run
- Cloud Spanner
- Cloud SQL
- Cloud Storage
- Compute Engine
- Google Kubernetes Engine
- Resource Manager (projects only)
Learn how to edit other properties of a Filestore instance.