How to Allocate GCP Costs Without Perfect Tagging

Allocate GCP costs when labels are patchy: start from projects and folders in the BigQuery billing export, then add project labels and resource labels.

Xplorr team

The people who build Xplorr

Updated 7 min read
How to Allocate GCP Costs Without Perfect Tagging
In this post
  1. Why is GCP tagging never complete?
  2. Step 1: Turn on the billing export to BigQuery
  3. Step 2: Let projects and folders do the first pass
  4. Step 3: Label projects, not every resource
  5. Step 4: Use resource labels only in shared projects
  6. Step 5: Keep the remainder visible
  7. Catch cost anomalies per project
  8. How Xplorr handles GCP allocation

You can allocate most of a GCP bill without perfect labels, because the resource hierarchy is already in the billing data. Every usage row in the Cloud Billing export to BigQuery names the project that generated it (costs owned by the billing account, such as support, are the exception), and the project.ancestors field lists the folders and organization above that project. So allocate in this order: by project and folder first, then by project labels, then by resource labels only where several teams share one project. Whatever is left (support fees, untagged shared services) stays on its own “unallocated” line instead of being spread across teams.

A clean labeling policy is a poor thing to wait for. Labels are not retroactive, not every row carries them, and the policy changes every time the org chart does. The project and folder structure is already on every row.

Infographic titled Allocate GCP in this order, with the line Project first, labels last. A table of four layers from the Cloud Billing export to BigQuery. 1, Project: column project.id, gives team or app and environment, empty for billing account costs such as support. 2, Folder: column project.ancestors, gives business unit or department, full data from April 2022. 3, Project label: column project.labels, gives the owner of a whole project with one label, needed only where the project name is unclear. 4, Resource label: column labels, gives the team inside a shared project, counts usage only from the day it is applied. A box says: keep what no layer explains on its own unallocated line, never spread it silently across teams. Three figures: 64 labels per resource at most, 63 characters per label key or value, lowercase only, so Team is not a valid key.
Four layers in the GCP billing export, most reliable first. Source: Google Cloud Billing and Resource Manager docs, checked November 2026.

Why is GCP tagging never complete?

On Google Cloud, “tagging” usually means labels: key and value pairs on resources that Google forwards to the billing system. Three rules from Google’s own documentation explain why label coverage always has gaps.

  • Labels count only from the day they are applied. Google’s billing export docs give the example directly: add environment:dev to a VM on January 15 and any analysis of environment:dev includes that VM’s usage only from January 15. Labeling a resource today does not fix last quarter.
  • Labels have strict format rules. Each resource takes up to 64 labels, keys and values are at most 63 characters, and both can only contain lowercase letters, numbers, underscores and dashes (label requirements). A team that labels Team=Payments on AWS cannot copy that key to GCP as it is.
  • Some costs belong to no resource at all. Support costs are owned by the Cloud Billing account, not a project, and Google’s export docs show the taxes on them with empty project columns. No labeling effort will ever assign them to a team.

GCP also has a second system called tags (Resource Manager tags), which can be inherited down the hierarchy and show up in the export’s tags columns with an inherited flag. They are useful, but they only reach the billing data for a listed set of resource types, such as Compute Engine instances, Cloud Run services and Cloud Storage buckets, so they leave gaps too. The project is the only key on every usage row.

Step 1: Turn on the billing export to BigQuery

Every step below is a query against the Cloud Billing export, so turn it on first under Billing, Billing export, BigQuery export. Two details from Google’s docs decide how much history you get:

  • A multi-region dataset (US or EU) receives data from the start of the previous month when you first enable the export. The backfill can take up to five days.
  • A single-region dataset only receives data from the day you turn it on.

Pick the multi-region option unless you have a data residency reason not to. Enable the detailed usage cost export as well if you will ever allocate below the project level, because the standard export has no resource column.

Step 2: Let projects and folders do the first pass

Start with the project, because it is filled whether or not anyone labeled anything. If your projects already map to teams and environments (payments-prod, payments-staging, data-platform-prod), most of the allocation is done. Group by project for a closed invoice month:

SELECT
  project.id AS project,
  SUM(cost) + SUM(IFNULL((SELECT SUM(c.amount) FROM UNNEST(credits) c), 0)) AS net_cost
FROM `my-billing-project.billing_export.gcp_billing_export_v1_XXXXXX_XXXXXX_XXXXXX`
WHERE invoice.month = '202610'
GROUP BY project
ORDER BY net_cost DESC;

Filtering on invoice.month instead of usage timestamps keeps the totals aligned with the invoice. Adding credits back in gives net cost, the number a team will recognise.

Folders give you the next level up for free. project.ancestors lists each ancestor from node to root: the project, then its folders, then the organization. The entry at offset 1 is the folder directly above the project (or the organization, if the project sits at the top):

SELECT
  project.ancestors[SAFE_OFFSET(1)].display_name AS parent,
  SUM(cost) + SUM(IFNULL((SELECT SUM(c.amount) FROM UNNEST(credits) c), 0)) AS net_cost
FROM `my-billing-project.billing_export.gcp_billing_export_v1_XXXXXX_XXXXXX_XXXXXX`
WHERE invoice.month = '202610'
GROUP BY parent
ORDER BY net_cost DESC;

Two caveats. The project.ancestors field has full data from April 2022, so older months need project.ancestry_numbers. And ancestry is recorded at the time of usage: move a project to another folder and only new rows follow it, which is what you want for showback.

If one project serves three teams, that is the problem to fix next. Splitting a shared project into one project per team and environment is a one-time change that permanently removes the need to label most resources.

Step 3: Label projects, not every resource

When the project name alone does not say who owns it (legacy-api-2, sandbox-7), add a label to the project rather than to each resource inside it. The export carries project labels in project.labels, separate from resource labels in labels, and a project label applies to every usage row in that project, including services where resource labels are patchy.

Ten projects need ten labels. The same coverage from resource labels might need thousands, each applied before the usage you want to count. Read the project label in the same query:

SELECT
  project.id AS project,
  (SELECT value FROM UNNEST(project.labels) WHERE key = 'team') AS team,
  SUM(cost) + SUM(IFNULL((SELECT SUM(c.amount) FROM UNNEST(credits) c), 0)) AS net_cost
FROM `my-billing-project.billing_export.gcp_billing_export_v1_XXXXXX_XXXXXX_XXXXXX`
WHERE invoice.month = '202610'
GROUP BY project, team
ORDER BY net_cost DESC;

Keep the key list short. team, env and cost_center cover most showback questions, and every extra required key lowers compliance across the whole set (our guide to FinOps practices for engineering teams shows the arithmetic).

Step 4: Use resource labels only in shared projects

Some projects are shared on purpose: a GKE cluster that runs workloads for five teams, a data platform project with one BigQuery reservation, a networking host project. Here, and mostly only here, resource labels are worth enforcing. Put the labels in the Terraform or deployment code that creates the resources, so they exist from the first hour of usage.

For a cluster, labels on the node pool tell you very little, because one node serves many teams. Allocation inside Kubernetes needs namespace and workload data, which a cluster cost tool such as OpenCost provides.

Step 5: Keep the remainder visible

After projects, folders and labels, some cost is still unassigned: support, taxes on billing account costs, shared networking, and anything created before a label existed. Do not spread it across teams to make the report add up to 100%. Put it on its own “unallocated” line, then decide one of three things for each item:

  1. Leave it central. Support fees usually belong to the platform or finance budget.
  2. Split it by rule. Shared networking can be split in proportion to each team’s direct cost, or by fixed percentages agreed once.
  3. Fix the source. A large unallocated line in one project is a sign that the project should be split.

Report the unallocated share every month. If it falls, the structure is working. If it grows, a new shared project appeared and nobody owns it.

Catch cost anomalies per project

Allocation by project also makes GCP cost anomaly detection more useful. A spike in BigQuery across the whole billing account is hard to act on. The same spike in data-platform-prod has an owner who can answer for it the same day. Once each project maps to a team, send each team its own projects’ daily cost and an alert when one of them jumps.

How Xplorr handles GCP allocation

Xplorr reads GCP costs from the Cloud Billing export in BigQuery with a read-only service account; the cost sync needs only BigQuery Data Viewer and BigQuery Job User. One Xplorr cloud account is one GCP project: the project that holds the billing export dataset. The export covers every project on the billing account, so one connection gives the cost split for all of them. Recommendations and inventory, which includes resource labels, are read for the connected project only. Per-resource costs need the detailed usage cost export; with the standard export only, everything else works and per-resource costs stay empty. How that compares with Google’s own billing reports is on our Xplorr vs GCP billing page.

Cost allocation shows tagged, untagged and unattributed spend as separate figures. GCP labels come from Cloud Asset Inventory for each connected project. Where labels run out, cost categories assign spend with ordered rules on provider, sub account (the GCP project), service, region, usage type, resource name or label. The first matching rule wins, spend that no rule matches stays as Unallocated, and a shared pool such as networking can be split evenly, in proportion to direct cost, or by fixed percentages. A category can be used as a virtual tag, so budgets and reports can filter by team even for spend that carries no label in GCP. Rules are evaluated when you view the data, so changing a rule updates past periods without a re-sync.

Anomaly detection compares each account, service and region with its own recent baseline, and root cause reads GCP audit logs from the 48 hours before a spike.

If you also run AWS or Azure and need one set of keys across all three bills, see our guide to normalizing multi-cloud billing. For GCP discount pricing next to AWS and Azure, see the 2026 price comparison.

To see your GCP spend split by project without writing these queries, start on the free plan with one cloud account, no credit card.

ShareLinkedInX

Written by

Xplorr team

The people who build Xplorr

Written together by the engineers who build Xplorr: the AWS, Azure, GCP and Kubernetes collectors, the console, and the alerting behind them.

About Xplorr

Related posts

All articles

Free plan, no credit card

See your AWS, Azure and GCP spend in one place

Connect a cloud account and find what is driving the bill. Start on the Free plan for 1 cloud account, no credit card required.