Back to Blog
gcp
billing-export
bigquery
cost-optimization
tutorial

GCP Billing Export to BigQuery: Complete Setup Guide (2026)

Step-by-step guide to enable GCP billing export to BigQuery. Learn setup, export types, your first queries, and common troubleshooting tips.

Matias Coca|
9 min read

Billing export to BigQuery is the foundation of GCP cost optimization. Without it, you're limited to summary views in the Console. With it, you can analyze every dollar spent, build custom dashboards, and catch cost anomalies.

Critical: Billing export has limited retroactive data. If you use a multi-region dataset (US or EU), you get data for the current and previous month. Regional datasets only get data from the day you enable export. Either way, every month you wait is historical data lost forever.

This guide walks you through setup, explains the export types, and gives you queries to start analyzing immediately.


Why Enable Billing Export?

Before we start, here's why this matters:

Without ExportWith Export
Summary views onlyLine-item detail
Can't query costsFull SQL analysis
Manual trackingAutomated dashboards
Hard to spot anomaliesCustom alerts possible
One billing account at a timeAggregate with queries
Time to setup: 15-30 minutes Cost: Minimal (BigQuery storage, typically cents/month) Difficulty: Easy

Step 1: Create a BigQuery Dataset

First, create a dataset to store your billing data.

In the Console

  1. Go to BigQuery in the Console
  2. In the Explorer panel, click your project
  3. Click Create dataset
  4. Configure:
    • Dataset ID: billing_export (or any name you prefer)
    • Data location: Select US or EU multi-region (recommended by Google)
    • Default table expiration: Leave blank (you want to keep this data)
    • Encryption: Google-managed key (default)
  5. Click Create dataset
Important: Choose your dataset location carefully. Once created, it cannot be changed. If your organization has data residency requirements, consider this now.

Recommendation: Google recommends selecting a multi-region location (US or EU). Multi-region datasets get a retroactive backfill of the current and previous month's data. Regional datasets only capture data from the day you enable export—no backfill.


Step 2: Enable Billing Export

  1. Go to Billing in the Console
  2. Select your billing account
  3. Click Billing export in the left menu

Enable Each Export Type

Google offers four export types. Enable the ones you need:

What it includes: Daily cost data at the SKU level
Table name: gcp_billing_export_v1_<BILLING_ACCOUNT_ID>
Best for: General cost analysis, trend tracking

To enable:

  1. Click Edit settings under "Standard usage cost"
  2. Select your project and dataset
  3. Click Save

What it includes: Resource-level detail (individual VMs, disks, etc.)
Table name: gcp_billing_export_resource_v1_<BILLING_ACCOUNT_ID>
Best for: Finding specific expensive resources, per-resource analysis

To enable:

  1. Click Edit settings under "Detailed usage cost"
  2. Select your project and dataset
  3. Click Save

3. Pricing Export

What it includes: SKU prices for your billing account
Table name: cloud_pricing_export
Best for: Price comparison, forecasting, rate card analysis

To enable:

  1. Click Edit settings under "Pricing"
  2. Select your project and dataset
  3. Click Save

4. CUD Metadata (If you use CUDs)

What it includes: Commitment details, utilization data
Best for: Monitoring CUD usage


Step 3: Wait for Data

After enabling export, data doesn't appear immediately.

Timeline:

  • Initial data: 24-48 hours
  • Backfill (if applicable): Up to 5 days for recent data
  • Ongoing: Updates throughout the day

To check if data is flowing:

SELECT COUNT(*) as row_count, MIN(export_time) as earliest, MAX(export_time) as latest
FROM your-project.billing_export.gcp_billing_export_v1_XXXXXX

If you get results, export is working.


Understanding the Schema

Key Columns in Standard Export

ColumnDescriptionExample
billing_account_idYour billing account01A2B3-C4D5E6-F7G8H9
service.descriptionGCP service nameCompute Engine
sku.descriptionSpecific product/SKUN2 Instance Core
project.idProject IDmy-production-project
usage_start_timeWhen usage started2025-01-15 08:00:00 UTC
usage_end_timeWhen usage ended2025-01-15 09:00:00 UTC
costCost in billing currency1.23
creditsApplied credits-0.50
labelsResource labels[{key: "env", value: "prod"}]
location.regionGCP regionus-east1

Key Columns in Detailed Export (Additional)

ColumnDescriptionExample
resource.nameSpecific resource nameinstance-1
resource.global_nameFull resource path//compute.googleapis.com/...

Your First Queries

Once data is flowing, try these queries to start analyzing.

Query 1: Total Cost by Service (This Month)

SELECT
  service.description AS service,
  ROUND(SUM(cost), 2) AS total_cost,
  ROUND(SUM(IFNULL((SELECT SUM(c.amount) FROM UNNEST(credits) c), 0)), 2) AS credits,
  ROUND(SUM(cost) + SUM(IFNULL((SELECT SUM(c.amount) FROM UNNEST(credits) c), 0)), 2) AS net_cost
FROM your-project.billing_export.gcp_billing_export_v1_XXXXXX
WHERE invoice.month = FORMAT_DATE('%Y%m', CURRENT_DATE())
GROUP BY service
ORDER BY net_cost DESC

Query 2: Daily Cost Trend (Last 30 Days)

SELECT
  DATE(usage_start_time) AS date,
  ROUND(SUM(cost), 2) AS daily_cost
FROM your-project.billing_export.gcp_billing_export_v1_XXXXXX
WHERE usage_start_time >= DATE_SUB(CURRENT_DATE(), INTERVAL 30 DAY)
GROUP BY date
ORDER BY date

Query 3: Cost by Project

SELECT
  project.id AS project,
  ROUND(SUM(cost), 2) AS total_cost
FROM your-project.billing_export.gcp_billing_export_v1_XXXXXX
WHERE invoice.month = FORMAT_DATE('%Y%m', CURRENT_DATE())
GROUP BY project
ORDER BY total_cost DESC

Query 4: Top 10 Most Expensive SKUs

SELECT
  service.description AS service,
  sku.description AS sku,
  ROUND(SUM(cost), 2) AS total_cost
FROM your-project.billing_export.gcp_billing_export_v1_XXXXXX
WHERE invoice.month = FORMAT_DATE('%Y%m', CURRENT_DATE())
GROUP BY service, sku
ORDER BY total_cost DESC
LIMIT 10

Query 5: Cost by Label (if you use labels)

SELECT
  (SELECT value FROM UNNEST(labels) WHERE key = 'environment') AS environment,
  ROUND(SUM(cost), 2) AS total_cost
FROM your-project.billing_export.gcp_billing_export_v1_XXXXXX
WHERE invoice.month = FORMAT_DATE('%Y%m', CURRENT_DATE())
GROUP BY environment
ORDER BY total_cost DESC

Query 6: Find Specific Resource Costs (Detailed Export)

SELECT
  resource.name AS resource_name,
  service.description AS service,
  ROUND(SUM(cost), 2) AS total_cost
FROM your-project.billing_export.gcp_billing_export_resource_v1_XXXXXX
WHERE invoice.month = FORMAT_DATE('%Y%m', CURRENT_DATE())
  AND resource.name IS NOT NULL
GROUP BY resource_name, service
ORDER BY total_cost DESC
LIMIT 20

Building a Simple Dashboard

Once you have data, you can build dashboards in Looker Studio (formerly Data Studio).

Quick Dashboard Setup

  1. Go to Looker Studio
  2. Click CreateData source
  3. Select BigQuery
  4. Choose your billing export table
  5. Click Connect
  6. Create a new report with these charts:
    • Scorecard: Total monthly cost
    • Time series: Daily cost trend
    • Pie chart: Cost by service
    • Table: Cost by project

Pre-Built Dashboard Templates

Google provides templates at the Cloud Billing documentation.


Common Issues and Troubleshooting

"No data in my table"

Causes:

  • Export just enabled (wait 24-48 hours)
  • Wrong dataset selected
  • Billing account has no spend

Fix: Verify in Billing → Billing export that status shows "Enabled"

"Data seems incomplete"

Causes:

  • Initial backfill still processing
  • Querying wrong date range

Fix: Wait up to 5 days for full backfill. Check export_time to see data freshness.

"I need historical data"

Good news (limited): If your dataset uses a multi-region location (US or EU), you get retroactive data for the current and previous month. This backfill happens automatically but can take up to 5 days.

Bad news: You cannot recover data older than one month before enabling export. Regional datasets get no backfill at all.

Partial solution: For older history, you can use the Billing Reports export (CSV) for historical summaries, but it won't have the line-item detail of BigQuery export.

"Table names are confusing"

Tables follow this pattern:

  • Standard: gcp_billing_export_v1_<BILLING_ACCOUNT_ID>
  • Detailed: gcp_billing_export_resource_v1_<BILLING_ACCOUNT_ID>

Where <BILLING_ACCOUNT_ID> is your billing account ID with dashes replaced by underscores.

Example: If your billing account is 01A2B3-C4D5E6-F7G8H9, your table is:
gcp_billing_export_v1_01A2B3_C4D5E6_F7G8H9

"BigQuery costs are adding up"

Causes:

  • Scanning large tables repeatedly
  • No partitioning in queries

Fix: Always filter by date columns to reduce data scanned:
WHERE usage_start_time >= '2025-01-01'


Best Practices

1. Enable Both Standard and Detailed Exports

Standard gives you SKU-level analysis. Detailed gives you resource-level. You'll want both eventually.

2. Use Scheduled Queries for Regular Reports

Instead of running queries manually, schedule them:

  1. Write your query in BigQuery
  2. Click ScheduleCreate new scheduled query
  3. Set frequency and destination table

3. Set Up Cost Alerts

Use BigQuery scheduled queries + Cloud Monitoring to alert on:

  • Daily spend exceeds threshold
  • Week-over-week increase above X%
  • Specific service costs spike

4. Document Your Table Names

Billing account IDs in table names are hard to remember. Create a view with a friendly name:

CREATE VIEW your-project.billing_export.billing_standard AS
SELECT * FROM your-project.billing_export.gcp_billing_export_v1_01A2B3_C4D5E6_F7G8H9

5. Consider Data Retention

Billing export tables grow over time. Decide how much history you need and consider:

  • Archiving old data to cheaper storage
  • Creating summary tables for long-term trends

6. Prepare for Schema Changes (CUD Users)

If you use spend-based Committed Use Discounts (CUDs), be aware that Google is updating the billing export schema on January 21, 2026. Key changes:

  • CUD discounts move from credits to a new consumption_model field
  • New fields: price.list_price, price.effective_price_default, consumption_model struct
  • Two rows per CUD SKU instead of one (separating overage from discounted usage)
If you have dashboards or queries that parse CUD credits, you'll need to update them. See Google's CUD data model documentation for details.

What's Next After Setup?

Now that you have billing data in BigQuery, you can:

  1. Build custom dashboards for your team
  2. Set up anomaly alerts for unexpected cost spikes
  3. Analyze optimization opportunities like idle resources
  4. Track CUD utilization if using committed discounts
  5. Allocate costs by team/project using labels
Or, if you'd rather skip building all this yourself, cost optimization tools can connect to your billing data and surface insights automatically.

Key Takeaways

  1. Enable billing export today—data is not retroactive
  2. Enable both standard and detailed exports
  3. Wait 24-48 hours for initial data, up to 5 days for backfill
  4. Use date filters in queries to control BigQuery costs
  5. Build on this foundation with dashboards, alerts, or third-party tools
Your billing export is the raw material for all GCP cost optimization. Everything else—whether native tools, third-party solutions, or custom scripts—builds on this data.

Want to skip the dashboard building? GCP FinOps by Brain Agents AI connects to your billing data and provides ready-to-use cost insights and recommendations.


Related Articles:

Written by Matias Coca

Building GCP cost optimization tools for growing companies. Questions or feedback? Let's connect.

Ready to optimize your GCP costs?

See exactly where your cloud spend goes with our cost optimization dashboard.