
From billing row to engineering action
- Export detailed billing to BigQuery and label every project and resource.
- Five SQL queries on the export show cost by service, team, SKU and day.
- Use the Recommender for idle VMs, disks, IPs and rightsizing.
- Spot VMs, schedules and the right machine family cut compute costs.
- Partitioning, clustering and query quotas keep BigQuery under control.
- Committed use discounts come last, for the proven baseline.
Establish the ownership model first
Projects are useful cost boundaries, but a shared platform project can conceal several products and environments. Decide how project hierarchy, resource labels and shared-cost rules fit together. Keep an unallocated category visible rather than distributing it arbitrarily to make a chart add up.
- Export billing to BigQuery. Turn on the detailed (resource-level) Cloud Billing export. It is the foundation for every report and allocation.
- Label resources and projects. Use a small, enforced set of labels (team, product, environment), and use the project hierarchy to separate owners.
- Set budgets and alerts. Budgets per project or label, with alerts to the owning team, not only to finance.
- Read the Recommender. Google's Recommender and the Active Assist hub list idle VMs, idle disks, unused IP addresses and rightsizing suggestions.
Five queries, five different management questions
Once the export is on, every line of your bill lands in a BigQuery table named like gcp_billing_export_v1_XXXXXX_XXXXXX_XXXXXX (the standard export) or gcp_billing_export_resource_v1_… (the detailed, resource-level export). Each row is one SKU for one project over a short usage window. The columns you will use most are:
service.descriptionandsku.description: what you paid for.project.id,labelsandproject.labels: who it belongs to.cost: the cost before credits, andcredits: an array of discounts, such as sustained use and committed use credits, as negative amounts.usage_start_timeandinvoice.month: when it was used and which invoice it lands on.
Replace the table identifier and reporting month with your own. These are exploratory queries, not a complete invoice reconciliation. Usage-date reporting and invoice-month reporting answer different questions; late adjustments can separate them. Date filters alone do not guarantee low scan cost: use a dry run and appropriate partition filters for your table.
1. Net cost by service for the last 30 days
SELECT
service.description AS service,
ROUND(SUM(cost), 2) AS gross_cost,
ROUND(SUM(IFNULL((SELECT SUM(c.amount) FROM UNNEST(credits) AS c), 0)), 2) AS credits,
ROUND(SUM(cost) + SUM(IFNULL((SELECT SUM(c.amount) FROM UNNEST(credits) AS c), 0)), 2) AS net_cost
FROM `my-project.billing.gcp_billing_export_v1_XXXXXX_XXXXXX_XXXXXX`
WHERE usage_start_time >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 30 DAY)
GROUP BY service
ORDER BY net_cost DESC;
Use net service cost to choose where to investigate, then distinguish a usage change from a credit change. A service can appear cheaper because a temporary credit arrived, even when its resource consumption rose.
2. Cost by team label, for one invoice month
SELECT
IFNULL((SELECT value FROM UNNEST(labels) WHERE key = 'team'), '(no team label)') AS team,
ROUND(SUM(cost), 2) AS cost
FROM `my-project.billing.gcp_billing_export_v1_XXXXXX_XXXXXX_XXXXXX`
WHERE invoice.month = '202611'
GROUP BY team
ORDER BY cost DESC;
The “(no team label)” row identifies charges without that resource label; it does not prove they have no owner. Resolve them through project ownership or a shared-cost rule where resource labels are unavailable. This query shows gross cost, unlike the net service view above, so do not compare the totals as if they were identical measures.
3. The 20 most expensive SKUs
SELECT
service.description AS service,
sku.description AS sku,
ROUND(SUM(cost), 2) AS cost
FROM `my-project.billing.gcp_billing_export_v1_XXXXXX_XXXXXX_XXXXXX`
WHERE invoice.month = '202611'
GROUP BY service, sku
ORDER BY cost DESC
LIMIT 20;
Ask what unit the SKU charges for before proposing a fix. Cross-region egress requires a traffic investigation; premium disk capacity requires a performance investigation. Similar totals do not imply similar remedies.
4. Daily spend, to spot anomalies
SELECT
DATE(usage_start_time) AS day,
ROUND(SUM(cost), 2) AS cost
FROM `my-project.billing.gcp_billing_export_v1_XXXXXX_XXXXXX_XXXXXX`
WHERE usage_start_time >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 60 DAY)
GROUP BY day
ORDER BY day;
Annotate the daily series with deployments, traffic events and scheduled jobs. Compare like days and allow for export latency. A gross-cost spike is a prompt for investigation, not proof of waste or an incident.
5. Share of spend with no labels
SELECT
ROUND(100 * SUM(IF(ARRAY_LENGTH(labels) = 0, cost, 0)) / SUM(cost), 1) AS pct_unlabeled
FROM `my-project.billing.gcp_billing_export_v1_XXXXXX_XXXXXX_XXXXXX`
WHERE invoice.month = '202611';
This measures rows with no resource labels, not the share missing a particular required key. Pair it with the team-label view and project mapping. If the selected period has zero total cost, handle the undefined percentage in your reporting rather than presenting it as zero.
Compute Engine: buy the shape the workload needs
Validate recommendations against memory, I/O, network and known peaks before resizing. A custom shape can reduce surplus memory or CPU, but only a workload benchmark establishes the better cost per completed job. Separate deletion candidates from resources deliberately held for recovery.
- Remove idle VMs and disks. Stopped VMs still pay for their persistent disks and reserved static IPs.
- Rightsize with custom machine types. Compute Engine lets you choose vCPU and memory separately, so you can match real usage instead of the nearest predefined shape.
- Use the right machine family. E2 for general-purpose cost efficiency, newer general-purpose and compute-optimized families for performance per dollar, and Arm-based options where your software supports them. Benchmark before switching.
- Use Spot VMs for interruptible work. Google quotes discounts of 60–91% versus on-demand prices for batch jobs, CI and fault-tolerant workers.
- Schedule non-production VMs. Instance schedules start and stop development VMs on a timetable.
- Choose the right disk type. Balanced persistent disks suit most workloads; reserve SSD and extreme options for databases that need them.
Discounts exchange flexibility for a different rate
| Discount | How it works | Best for |
|---|---|---|
| Sustained use discounts | Applied automatically to eligible machine families that run for a large part of the month | Steady VMs on eligible families, with no commitment |
| Resource-based committed use discounts | Commit to a quantity of vCPU, memory, GPUs or local SSD in a region for 1 or 3 years | Predictable, long-running Compute Engine capacity |
| Spend-based (flexible) committed use discounts | Commit to an hourly spend that applies across eligible services and machine families | Steady spend that moves between machine types or services |
| Spot VMs | Deep discounts in exchange for possible preemption | Batch, CI and stateless workloads |
Read eligibility, region and sharing rules before modeling a commitment. Discount mechanisms are not necessarily additive. Calculate the incremental benefit against what you would otherwise pay, then test the purchase against lower-demand and migration scenarios.
GKE: distinguish pod efficiency from cluster efficiency
Reducing a pod request does not automatically remove a node. Placement rules, disruption budgets and spare capacity can prevent consolidation. Check whether a change reduces billed capacity while preserving service behavior; namespace allocation alone cannot answer that.
- Enable GKE cost allocation to see cost by namespace and label.
- Set realistic CPU and memory requests; over-requested pods waste node capacity even when they are idle.
- Use the cluster autoscaler and node auto-provisioning, or Autopilot, where you pay for pod requests rather than whole nodes.
- Run fault-tolerant workloads on Spot node pools.
BigQuery: control the query before choosing the pricing model
Trace expensive jobs to their user or scheduled pipeline. Check scanned bytes, repeated transformations and partition pruning before comparing on-demand with capacity pricing. A capacity commitment is not a substitute for finding a dashboard that repeatedly scans unnecessary history.
- Partition and cluster tables so queries scan only the data they need, and require a partition filter on large tables.
- Avoid
SELECT *; on-demand pricing charges by bytes scanned, so select only the columns you use. - Compare on-demand with capacity (editions) pricing once spend is steady, and set per-user and per-project query quotas.
- Check storage billing. Long-term storage (tables unchanged for 90 days) is cheaper automatically; compare logical with physical storage billing for compressible data.
Data services: price access and recovery, not just storage
Test retention decisions against restore time and investigation needs. Storage class transitions can introduce retrieval and minimum-duration charges. Logging exclusions can remove evidence permanently. Have the data or security owner approve those trade-offs before automating them.
- Cloud Storage: use lifecycle rules or Autoclass to move objects to Nearline, Coldline or Archive, and delete what you no longer need.
- Cloud Logging: add exclusion filters for noisy, low-value logs and set retention on log buckets.
- Network: keep services that talk a lot in the same region, use Cloud CDN for static content, and watch Cloud NAT and internet egress charges.
- Cloud SQL: rightsize instances and stop non-production instances outside working hours.
Use a downside scenario to size commitments
Historical usage is evidence, not a promise. Remove workloads scheduled for retirement and account for existing commitments before selecting a baseline. Use the steps below, then ask whether the purchase remains useful if demand falls or a planned migration happens earlier.
- Finish rightsizing first, so you do not commit to capacity you are about to remove.
- Look at hourly vCPU and memory usage per region and machine family over the last 60 to 90 days.
- Take a conservative baseline, such as the level usage rarely drops below, rather than the average.
- Cover that baseline with resource-based commitments where the machine family is stable, and use spend-based (flexible) commitments where workloads move between families or services.
- Review coverage and utilization monthly, and add commitments in small steps as the baseline grows.
Record the utilization assumption and a named purchase owner. Under-coverage leaves some usage at a higher rate; unused commitment creates a fixed cost without useful work. Revisit both measures rather than optimizing coverage alone.
Serverless still needs a capacity and retry policy
Measure cost per request alongside latency and failure rate. Higher concurrency may improve utilization until memory pressure or contention causes more failures. Warm capacity is a service-level decision; retries need a ceiling and a dead-letter or escalation path.
- Check minimum instances. Minimum instances keep containers warm and remove cold starts, but they bill while idle. Use them only on latency-sensitive services.
- Choose how CPU is billed. Request-based billing charges only while a request is handled; instance-based billing suits services with background work. Pick per service, not by default.
- Raise concurrency where your code allows it, so each instance serves more requests at once.
- Right-size memory and CPU per service using real usage, as you would for a VM.
- Watch Cloud Functions and Pub/Sub retries. Failing messages that retry endlessly are a common source of silent spend.
AI workloads need a useful-result denominator
Separate experiments, training and serving because their interruption tolerance and utilization patterns differ. Compare cost per accepted training run or prediction at a defined quality level. Cheap accelerator hours do not help if a workload spends them waiting for data.
- Separate training from serving. Training jobs are bursty and often interruptible, so they suit Spot capacity and scheduled runs. Serving needs steady capacity and is the place for commitments.
- Watch idle accelerators. A GPU VM or notebook left running over a weekend can cost more than a month of ordinary VMs. Set idle shutdown on Vertex AI Workbench instances and schedules on GPU VMs.
- Match the accelerator to the job. The newest, largest GPU is rarely the cheapest per result. Benchmark cost per training run or per thousand predictions, not cost per hour.
- Track model API spend separately. Calls to hosted models are billed per token or per request. Label projects by feature so the billing export shows which product feature drives the cost, and see our guide to tracking and cutting LLM costs.
- Set budgets on AI projects first. Experiments grow quickly; a budget alert at 50% and 90% of the monthly plan catches runaway jobs early.
Close the review with decisions, not screenshots
Use a short report to connect the bill to actions. Give finance a consistent cost basis and engineering enough context to validate the proposed changes. Separate estimated opportunities from changes already verified in billing.
- What did we spend, and why did it change? Net cost by service and by team, compared with last month, with a one-line reason for every large movement.
- Who owns it? The share of spend with no team label, and the plan to reduce it.
- What did we save? Savings from rightsizing, deletions and commitments, measured on the bill rather than estimated.
- What is next? The top three open recommendations, each with an owner, an expected saving and a date.
Include one unit-cost measure with a stable definition. If customer count grows while cost per customer falls, a larger bill may be consistent with better efficiency. If the denominator changes definition, explain it before comparing periods.
Keep an action register after the cleanup
Each recommendation needs an owner, change date and verification period. Keep rejected recommendations too, with their rationale: deliberate redundancy should not be rediscovered as waste every month. Use three recurring habits:
- A monthly cost review with engineering and finance, using the queries above, the Recommender and your budget alerts.
- Guardrails through organization policies, for example limiting which regions resources can be created in, so expensive mistakes are prevented rather than found later.
- Unit economics: cost per customer, per transaction or per thousand requests, so growth in spend is judged against growth in the business.
If you run more than one cloud, export billing in the FOCUS format from each provider so Google Cloud, AWS and Azure costs sit in one report. See our Azure cost optimization playbook and 25 ways to reduce your AWS bill.
A first month that builds a repeatable practice
| Week | Focus |
|---|---|
| 1 | Billing export to BigQuery, labels, budgets and alerts |
| 2 | Idle VMs, disks and IPs; schedules for non-production |
| 3 | Rightsizing, machine families, GKE requests, BigQuery partitioning |
| 4 | Committed use discounts for the proven baseline; monthly review cadence |
Discount levels and features change; check the Google Cloud pricing pages and documentation before committing.
Frequently asked questions
What is the difference between sustained use and committed use discounts?
Sustained use discounts apply automatically to eligible VMs that run much of the month. Committed use discounts require a 1- or 3-year commitment and give larger discounts.
Is BigQuery on-demand or capacity pricing cheaper?
It depends on how steady your query volume is. Compare the two using your own billing export before switching.
Does GKE Autopilot save money?
Often, for clusters with poor bin-packing, because you pay for pod requests rather than whole nodes. Busy, well-packed clusters may be cheaper on Standard.
Can CloudLens analyze Google Cloud?
Yes. CloudLens supports Google Cloud, AWS and Azure with read-only access. See CloudLens.
More questions? See all FAQs →