finopsgcpdata-pipelinecost-allocation

Analyzing GCP cost with the BigQuery billing export

GCP's billing export streams detailed cost data straight into BigQuery, making SQL your cost analysis tool. It is powerful and easy to start, but the queries themselves can get expensive. Here is how to use it well.

The C3X Team··6 min read

Quick answer

GCP's Cloud Billing export streams detailed usage and cost data directly into a BigQuery dataset, so you analyze cost with SQL instead of a fixed dashboard. Enable the standard (and optionally detailed) export, then query cost by service, project, label, and SKU, join to your business tables for unit economics, and build allocation logic labels do not capture. The catch is that BigQuery charges for bytes scanned, so partition-filter every query on the export's date column and select only the columns you need, or your cost-analysis queries become a cost of their own. The payoff is that your entire GCP cost history is queryable with SQL, joinable to any data you have.

GCP takes a different approach to detailed billing data than AWS: instead of dropping files in a bucket for you to catalog, it streams cost data straight into BigQuery. Once the billing export is enabled, your cost data lands in a BigQuery dataset automatically, and SQL becomes your analysis tool. This is a genuinely powerful setup, your whole cost history queryable and joinable, but the ease of querying hides a trap: the queries themselves cost money, and a careless analyst can spend more analyzing cost than they save.

Enabling the export

In the Cloud Billing console you enable export to a BigQuery dataset. There are levels: the standard usage cost export covers cost by service, project, SKU, and labels, and is enough for most analysis. The detailed export adds resource-level granularity for finer attribution. There is also a pricing export for rate data. Start with the standard export, add detailed only if you need per-resource breakdowns, since more granularity means more data to scan and store. Once enabled, the data flows in continuously with no pipeline to maintain.

What you can query

DimensionUse
Service and SKUWhich products and specific meters drive cost
ProjectCost per project, GCP's natural cost boundary
LabelsTeam, environment, app attribution
CreditsCommitted use and sustained use discounts applied

The export lets you slice cost by service, project, SKU, and label, the GCP equivalents of the breakdowns you would tag for on AWS. Project is GCP's natural cost boundary (like an AWS account), so cost per project is a clean allocation with no label discipline required, echoing the account-structure logic. Labels give finer attribution within a project. The credits fields show committed-use and sustained-use discounts, so you can analyze effective versus list cost, key to commitment coverage.

The query-cost trap

BigQuery's on-demand pricing charges for bytes scanned, and the billing export grows continuously, so a query that scans the whole table gets more expensive every month and can quietly become a real cost. The billing export is partitioned by a usage date column, so the fix is simple and mandatory: filter every query on that partition column to scan only the days you need, and select only the columns you use rather thanSELECT *. A dashboard that re-queries the full history on every refresh is a classic self-inflicted cost, the GCP version of the BigQuery costpitfalls.

Joining to business data

The real advantage of cost data living in BigQuery is that your business data can live there too. Join the billing export to your customer, tenant, or request tables and compute unit economics directly, cost per customer, cost per tenant, cost per request, in SQL. This is the same payoff as an AWS CUR pipeline, but with less setup because the export and the join happen in the same warehouse. It is the analysis no packaged cost tool can do, because only your warehouse holds both your cost and your business metrics.

Making it durable

Turn the useful queries into scheduled views or materialized tables so teams consume pre-computed allocated cost rather than re-scanning the raw export, which both saves query cost and standardizes the numbers. Set a partition expiration if you do not need indefinite history, and watch the export dataset's own storage and query cost as part of your bill. Price the analysis infrastructure and any warehouse compute against the resource catalog, so your GCP cost-analysis setup is itself a known cost rather than an ironic surprise on the bill it is meant to explain.

FAQ

What is the GCP BigQuery billing export?

It is a Cloud Billing feature that streams detailed usage and cost data directly into a BigQuery dataset, so you analyze GCP cost with SQL instead of a fixed dashboard. You enable it in the billing console, choosing the standard export (cost by service, project, SKU, and label) or the detailed export (resource-level granularity). Once enabled, cost data flows in continuously with no pipeline to maintain, and your whole cost history becomes queryable.

What can I analyze with the billing export?

Cost sliced by service and SKU (which products and meters drive spend), by project (GCP's natural cost boundary, a clean allocation with no label discipline needed), and by label (team, environment, app attribution within a project). The credits fields show committed-use and sustained-use discounts, so you can compare effective versus list cost. Most powerfully, you can join the export to your own business tables for unit economics.

Why can BigQuery billing analysis get expensive?

Because BigQuery's on-demand pricing charges for bytes scanned, and the billing export grows continuously, so a query that scans the whole table gets more expensive every month. A dashboard that re-queries the full history on every refresh is a classic self-inflicted cost. The export is partitioned by a usage date column, so filtering every query on that partition and selecting only needed columns keeps scans, and cost, small.

How do I keep billing export queries cheap?

Filter every query on the export's usage date partition column so you scan only the days you need, and select only the columns you use rather than SELECT star. Turn frequently-used queries into scheduled views or materialized tables so teams consume pre-computed allocated cost instead of re-scanning the raw export. Set a partition expiration if you do not need indefinite history, and watch the export dataset's own storage and query cost.

Can I compute unit economics with the billing export?

Yes, and it is the main advantage. Because the cost data lives in BigQuery, your business data can live there too, so you can join the billing export to your customer, tenant, or request tables and compute cost per customer, cost per tenant, or cost per request directly in SQL. This is analysis no packaged cost tool can do, because only your warehouse holds both your cloud cost and your business metrics together.

How does C3X complement the BigQuery billing export?

The billing export analyzes GCP cost after it happens; C3X prices infrastructure from Terraform before it deploys. Together they cover both directions: the export gives allocated historical cost joinable to business metrics, and C3X gives the forward-looking cost of a change in the pull request. You can also price the analysis setup's own warehouse infrastructure with C3X, so the tool explaining your bill is itself a known cost.

What to do next

Pair historical GCP cost analysis with pre-deploy pricing. C3X reads your Terraform and prices your resources against a live catalog. Start with the quickstart.

Try C3X on your own Terraform

Free and open source. No API key required. One command to install, one command to estimate.