Defining Labeling strategy in GCP for gaining granularity into cloud costs

Riya Shrivastava
Google Cloud - Community
4 min readApr 6, 2023

This blog describes the steps to create a labelling strategy for your organization in order to gain better visibility into cloud costs.
A label is a key-value pair which helps you organize your Google Cloud resources. In GCP, each resource can have up to a maximum of 64 labels. Most of the services support labels including Pub/Sub, Cloud Run, Dataproc, Filestore, Vertex AI, Artifact Registry and many more.
Labels act as metadata which lets you filter resources in Cloud Billing console. It’s important to note that labels and tags hold different meanings in GCP, refer this to know more. This blog focuses on creating labelling strategies in GCP to gain insights from Cloud Billing reports.

Structure the resource hierarchy

A typical best practice is to utilize projects in GCP to divide out the main essential divisions and afterward use labels to burrow down further into those projects to gain fine-grained visibility. GCP has an additional layer for allocation of projects called folders which helps organizing the projects.

In the diagram below, the organization, “Company”, has folders representing two departments, “Department X” and “Department Y”, and a folder, “Shared Infrastructure,’ for items that might be common to both departments. Under “Department Y”, they have organized into two teams, and within the team folders, they further organize by products. The folder for “Product 1” further contains three projects, each with the resources needed for the project. This provides them with a high degree of flexibility in assigning IAM policies and Organization Policies at the right level of granularity.

Google Cloud Resource Hierarchy

Placing the correct set of labels

Once resources are placed in an organized manner, next step is to place the correct set of labels. Labels and tags provide functionality to define metadata in the form of key/value pairs which are associated with the resources in a cloud account. Labels are merely a set of characters to the CSPs with no semantic meaning but holds a great value to the customer. Labelling allow customers to group the costs by different dimensions to identify which items in their cloud bill are accreditable to the business’s services.
A labelling standard shouldn’t compel groups to apply a large number of labels. You ought to continuously remember the inquiries you want to respond to, and the amount of information you really want is provided by your resource hierarchy. It’s ideal to place labels just for the core metadata needs.
If you unsure where to start with the labelling standard, here are some example labels which are usually implemented:

A business unit/cost center label lets you distinguish and divide the costs on the basis of team or cost center (for example, team:research)

A service or component label that defines the workload or the business service that resource belongs to enabling the organization to differentiate among the services that teams are running (for example, component:frontend, service:ingest)

A environment or stage label which defines the environment like production, test etc.

Similarly, you can create your own set of labels in place as per the requirement.

Maintaining Labels

It’s important to maintain the health of labels in order to gain intended and accurate cost insights from billing data. The key points to remember while creating a label are:

  1. Labels are case sensitive which means the value “Enterprise” and “enterprise” hold different meanings.
  2. Resources labelled as “Production” and “Prod” will be grouped differently.
  3. Keys must begin with a lowercase letter or international character.
  4. Key must be unique within a resource, however multiple resources can share the same key.

Enabling Automation

The best practice suggests to create labels using automation in order to avoid human errors. Infrastructure automation tools like Ansible, Terraform and CloudFormation can help ensuring uniformity and consistency.

However, there’s a possibility of resources left unlabelled or being incorrectly labelled. To solve or track the issue, various third party services are designed to remove or stop the resources in near time after the creation. This helps to reduce the number of unallocated or unexplained costs in the cloud billing report.

Gathering Insights using Labels

You can now measure the performance of labelling strategy effectively by the amount of cloud spend with the labels vs without. It’s important to note that not all resources can be labelled in CSPs which is why pragmatically you should have a target of 95% and define a process to allocate remaining 5% untaggable resources. By keeping a track of resources which aren’t matching your labelling standards, you can determine whether your organization is getting better at applying and following the labelling strategy.

Conclusion

A labelling strategy in place helps you define a structure of resources and enable to group costs. It is important for your organization to understand the importance of labelling and automate the process to avoid any human errors. Insights on costs allocation will help the organization understand their cloud spend and take further actions to improve the efficiency and accountability.

In the next article, we’ll be looking into tags and how they can be used, along with the differences between labelling and tagging.

Incase you have any questions, feel free to reach out here..
Keep Learning!

--

--