Organize resources with tags
Add key-value tags to virtual machines when you create them or later, and use them to group the cost of your instances in Cost Explorer.
Tags are key-value pairs that you attach to an instance, such as team=web or env=production. Use them to organize your instances and to break down their cost in Cost Explorer. This article covers tags on virtual machines.
Before you begin
- To edit an instance's tags, you need the Owner or Contributor role, or a custom role with Manage access to Compute / Instances, on the subscription or on the project.
- To group costs by tag in Cost Explorer, you need any role with Read access to Billing & Cost.
Tag rules
- A key is required and has 1 to 128 characters.
- A value can be empty and has up to 256 characters.
- Use each key only once per instance. When you edit tags, a duplicate key is refused.
Add tags when you create an instance
In the creation wizard, go to the Tags step.
Select Add tag, and enter a key and a value. Repeat for each tag.
Rows without a key are ignored when you create the instance.
Edit the tags of an instance
In the console, go to ComputeInstances, and select the instance.
Select the Tags tab, and select Edit.
Change the tags: select Add tag to add one, edit a key or a value, or select × next to a tag to remove it.
Select Save.
Saving replaces the instance's whole tag set with the tags in the editor.
Group costs by tag
In Cost Explorer, you can group costs by a tag key. Costs are grouped by the key's values, shown as key=value, and usage without the key appears as Untagged. For the steps, see Choose what to show.
Keep these rules in mind when you read the result:
- What carries the tags. An instance's compute usage carries its tags, and so do the add-ons and licenses attached to it. The instance's disks, its Floating IP, and its monitoring don't carry the instance's tags, so their cost appears as Untagged.
- When a change applies. A tag change applies to usage from the current hour onward. Earlier usage keeps the tags it was billed with.
Note
Budgets don't filter by tag. A budget counts all usage of its project or subscription. See Create budgets and threshold alerts.