Skip to main content

Labels

Exam guide§1

Projects and folders give you levels of segregation for resources, but sometimes you want more granularity than the hierarchy alone. Labels are the finer-grained tool: user-defined key-value pairs you attach to individual resources to organize, filter, and account for them.

What a label is

A label is a simple key:value string pair you attach to a resource. You can create and manage them from the Google Cloud console, gcloud, or the Resource Manager API, and they attach to resources like VMs, disks, snapshots, and images.

×Edit labelsInstances Selected (1): instance-1KeyValuedepartmentwebsite-deveengineeringdevelopmentownerbobzalmanprojectaccount-1569+ Add labelSaveCancel
Editing labels on a Compute Engine instance in the console: each row is one key-value pair. The same set can be applied with gcloud or the Resource Manager API.
NumbersLabel facts
  • Labels are key-value pairs, e.g. environment:production.
  • Each resource can carry up to 64 labels.
  • Manage them via the console, gcloud, or the Resource Manager API.
  • They propagate through billing, so you can break costs down by label in exports and reports.
  • Common uses: inventory (list all environment:production VMs), filtering resources, and scripts that analyze costs or run bulk operations across matching resources.

What to use labels for

Group resources along whatever dimension you need to report on or operate against. A few conventions worth knowing for the exam:

Team or cost centerteam:marketingteam:researchComponentscomponent:rediscomponent:frontendEnvironment or stageenvironment:prodenvironment:testOwner or contactowner:gauravcontact:opmStatestate:inusestate:readyfordeletion
Label conventions: pick a key that names the dimension (team, component, environment, owner, state) and a value that names the bucket.

Labels vs network tags

CompareDo not confuse labels with network tags

Both are user-defined strings, but they do different jobs.

LabelsKey-value pairs for organizing resources of many kinds; propagate through billing. Questions about billing or inventory want labels.
Network tagsPlain strings applied to instances only; drive networking - firewall rules and custom static routes. Questions about firewall rules or routes want network tags.
LabelsNetwork tagsFormatenv:prodweb-serverApplies toVMs, disks, snapshots, imagesInstances onlyUsed forOrganize · filter · cost accountingFirewall rules · routesBilling✓ Propagates through billing– No billing role
Labels vs network tags at a glance: key-value pairs on many resource types that feed billing, versus plain strings on instances only that drive networking.

See Firewall rules for how network tags target VMs in a rule's filter.