Reading a GCP bill like an architect
Turn the Cloud Billing export into five queries that explain a Google Cloud invoice: what is fixed, what scales, what is a credit, and who owns each line.
Sorting the cost report by the biggest number finds the largest line, not the line that changed and not the line that will keep growing. Reading a bill as an architect means separating four things: what is fixed, what scales with traffic, what is hidden behind a credit that will expire, and which line has an owner who can act on it. The tool for that is the Cloud Billing export to BigQuery, and this walkthrough runs five queries against it in the order I would run them, each answering one question. It is written for engineers on small teams who own a Google Cloud bill without a finance function, and it is about making every line explainable in a sentence, which has to come before reducing anything safely.
Pick the export and turn it on early#
The console Reports page is fine for a quick look, and the cost table report reconciles a single invoice, but neither gives you joins, saved queries or a history you control. The BigQuery export does. There are two variants: the standard usage cost export (service, SKU, project, labels, credits) and the detailed one, which adds resource-level rows. I enable the standard export on every billing account on day one and the detailed one only when a single service dominates and I need to know which resource inside it. Both are described on the export overview.
Timing is the one thing you cannot fix later. For multi-region datasets (US or EU), data from the start of the previous month is backfilled when you enable the export; for regional datasets collection starts on the day you enable it, and the pricing export is never backfilled.
In the console, open the billing account, go to the Billing export page and enable the standard usage cost export into a new BigQuery dataset. Per the setup guide you need Billing Account Costs Manager or Billing Account Administrator on the billing account and BigQuery User on the project that holds the dataset. The dataset location cannot be changed afterwards, so choose deliberately, and use the same location for any later billing exports so you can join them.
The table is named gcp_billing_export_v1_ followed by the billing account ID with underscores in place of dashes. Below I write it as billing.gcp_billing_export_v1_XXXXXX_XXXXXX_XXXXXX; copy the real name from your dataset. Check that rows are arriving (exports run through the day, and a first backfill can take several days):
bq query --use_legacy_sql=false \
'SELECT MIN(usage_start_time) AS first_usage, MAX(usage_start_time) AS last_usage, COUNT(*) AS rows_total
FROM `my-billing-project.billing.gcp_billing_export_v1_XXXXXX_XXXXXX_XXXXXX`'The five questions, each a query, each ending in a decision:
What is the net total, and how did it move?#
Credits sit in a repeated credits field with negative amounts, so net is cost plus the sum of credits, which is the shape the official query examples use. I split it into gross, credits and net so the three sit side by side:
SELECT
invoice.month AS invoice_month,
SUM(CAST(cost AS NUMERIC)) AS gross,
SUM(IFNULL((SELECT SUM(CAST(c.amount AS NUMERIC)) FROM UNNEST(credits) AS c), 0)) AS credits,
SUM(CAST(cost AS NUMERIC))
+ SUM(IFNULL((SELECT SUM(CAST(c.amount AS NUMERIC)) FROM UNNEST(credits) AS c), 0)) AS net
FROM `my-billing-project.billing.gcp_billing_export_v1_XXXXXX_XXXXXX_XXXXXX`
GROUP BY invoice_month
ORDER BY invoice_month;A word on what "gross" means here. The cost column is the cost per your account's consumption model, including any negotiated discounts, before credits. It is not necessarily list price; the column reference has a separate cost_at_list column for that. Use cost_at_list when you want to know what an architecture costs before any account-specific pricing.
Read the three columns in order. Gross is what the architecture costs at your prices, credits is how much of that someone else is paying, and net is what you owe. A bill that looks stable because a promotional credit absorbs growth is stable only until the credit ends, so the figure to forecast with is gross minus the discounts that are permanent.
Two details trip people up. The invoice month can differ from the usage month, because some charges are invoiced later. And cost_type separates regular usage from tax, adjustments and rounding errors, so when comparing months filter cost_type = 'regular' or you will mistake a tax change for an architecture change. If you are billed in a currency other than USD, currency_conversion_rate is the exchange rate from USD, and cost divided by it gives the USD amount; do not sum across billing accounts in different currencies without it.
Which services and projects make it up?#
For the invoice month you care about, break the net down by service, then by project:
SELECT
service.description AS service,
project.id AS project,
SUM(CAST(cost AS NUMERIC))
+ SUM(IFNULL((SELECT SUM(CAST(c.amount AS NUMERIC)) FROM UNNEST(credits) AS c), 0)) AS net
FROM `my-billing-project.billing.gcp_billing_export_v1_XXXXXX_XXXXXX_XXXXXX`
WHERE invoice.month = '202610'
AND cost_type = 'regular'
GROUP BY service, project
HAVING net > 0.5
ORDER BY net DESC;The HAVING clause drops lines worth a few cents. For each row that remains, write one sentence: "this is the API's compute", "this is log ingestion", "this is the database". A line you cannot describe in a sentence is the first thing to investigate, because it usually means something is running that you did not know about.
Which charges run every single day?#
This query separates fixed from variable cost, and it is the one I would keep if I could keep only one. A SKU charged on every day of the month with little day-to-day variation is an always-on cost; one that appears on a few days or swings by an order of magnitude is traffic-driven.
WITH daily AS (
SELECT
service.description AS service,
sku.description AS sku,
DATE(usage_start_time) AS day,
SUM(CAST(cost AS NUMERIC)) AS cost
FROM `my-billing-project.billing.gcp_billing_export_v1_XXXXXX_XXXXXX_XXXXXX`
WHERE invoice.month = '202610'
AND cost_type = 'regular'
GROUP BY service, sku, day
)
SELECT
service,
sku,
COUNT(DISTINCT day) AS days_charged,
ROUND(SUM(cost), 2) AS month_cost,
ROUND(STDDEV(cost) / NULLIF(AVG(cost), 0), 2) AS variation
FROM daily
GROUP BY service, sku
HAVING SUM(cost) > 0.5
ORDER BY days_charged DESC, month_cost DESC;Rows where days_charged equals the number of days so far and variation is near zero are fixed costs. Both thresholds are a heuristic: a steadily busy API also draws a flat line. The query gives you a list to walk down while asking "does this need to exist when there is no traffic?". Day boundaries here follow usage_start_time, which is UTC, while console reports and budgets use Pacific time, so daily totals will not match the console exactly. Compare months, not single days.
Some rows will be recognisable from their descriptions. Each of these is documented on its own pricing page, so I link rather than quote prices:
| What the row looks like | What it means | Check |
|---|---|---|
| IP address SKUs charged daily | A reserved static external IP not attached to a resource is charged at a higher rate than one in use (network pricing) | gcloud compute addresses list, release reservations with status RESERVED |
| A Cloud NAT gateway SKU on every day | Hourly gateway charge plus per-GiB processing, whether or not anything uses it (Cloud NAT pricing) | Does a named integration still need a fixed egress IP? |
| Idle time on Cloud Run | Minimum instances bill at an idle rate even with no requests (Cloud Run pricing) | Is each one still earning its place? See Cloud Run cold starts |
| Log ingestion on a flat line | Cloud Logging charges ingestion beyond a free allotment, scaling with log volume, not traffic (pricing) | A chatty debug line; see structured logging on a budget |
None of these is wrong by definition. Each has a reason you can state, or it goes.
Which part is a credit, and when does it end?#
Break credits down by type to see which are permanent:
SELECT
invoice.month AS invoice_month,
c.type AS credit_type,
c.name AS credit_name,
SUM(CAST(c.amount AS NUMERIC)) AS amount
FROM `my-billing-project.billing.gcp_billing_export_v1_XXXXXX_XXXXXX_XXXXXX`,
UNNEST(credits) AS c
GROUP BY invoice_month, credit_type, credit_name
ORDER BY invoice_month, amount;FREE_TIER credits are the free allotments, which change with usage and with Google's terms. SUSTAINED_USAGE_DISCOUNT and the committed-use types are tied to Compute Engine usage and commitments you made. PROMOTION is trial or promotional money with an expiry. Only the promotion has a date that matters for planning: find it in the billing console, put the end date in a calendar, and use the gross column from the first query as the real forecast.
Who owns what is left?#
Labels on resources appear in the export as a repeated key-value field. Group the net by the value of one key to see how much of the bill is attributable:
SELECT
IFNULL(l.value, '(unlabelled)') AS environment,
SUM(CAST(cost AS NUMERIC))
+ SUM(IFNULL((SELECT SUM(CAST(c.amount AS NUMERIC)) FROM UNNEST(credits) AS c), 0)) AS net
FROM `my-billing-project.billing.gcp_billing_export_v1_XXXXXX_XXXXXX_XXXXXX`
LEFT JOIN UNNEST(labels) AS l ON l.key = 'environment'
WHERE invoice.month = '202610' AND cost_type = 'regular'
GROUP BY environment
ORDER BY net DESC;The left join keeps costs that lack the label, which is the point: the size of the (unlabelled) row is your attribution gap. Some charges cannot carry a label at all (support, taxes) and others, such as network traffic, may be attributed to a different resource than you expect, so aim for a number you can explain, not zero. Labels are forward-only: adding one today does not rewrite last month. When one service dominates and you need the resource behind the line, enable the detailed export; the detailed table reference shows which columns identify resources, usually resource.name and resource.global_name.
Close the loop with an alert#
A budget with a forecast threshold turns this monthly review into something that tells you when to look early. Budgets do not cap spend and they lag actual usage, so treat them as a smoke alarm; budget alerts that page you covers thresholds, routing and silence detection.
What the analysis costs#
The export has no separate charge, but the dataset is billed as BigQuery storage and every query as BigQuery compute, as the setup guide notes. A small team's standard export is a small table and BigQuery has a free usage tier (pricing). The queries select only the columns they need to keep scanned bytes down; if you start querying daily from a dashboard, materialise a monthly summary table instead of rescanning raw rows.
If the bill is a few euros a month and a free-tier credit absorbs it, a monthly query ritual is more machinery than the problem deserves: group the console Reports page by service once a quarter, and enable the export anyway so the history exists later. If finance or a FinOps team already owns the bill, use the same export they do and agree what net and gross mean before building a second view.
Related articles
All articles →Start with a budget that emails a monitored channel, then add a Pub/Sub relay, usage alerts and a heartbeat that notices silence when that is worth building.
10 min
Batch work behaves badly behind an HTTP endpoint. Compare Cloud Run jobs and services on retries, parallelism and exit codes, and shard work across tasks.
12 min
A static bundle in Cloud Storage is cheap to run and easy to get wrong: which Cache-Control values to set, how to upload them, and how Cloud CDN behaves.
8 min