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 Export | With Export |
|---|---|
| Summary views only | Line-item detail |
| Can't query costs | Full SQL analysis |
| Manual tracking | Automated dashboards |
| Hard to spot anomalies | Custom alerts possible |
| One billing account at a time | Aggregate with queries |
Step 1: Create a BigQuery Dataset
First, create a dataset to store your billing data.
In the Console
- Go to BigQuery in the Console
- In the Explorer panel, click your project
- Click Create dataset
- 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)
- Dataset ID:
- Click Create dataset
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
Navigate to Billing Export
- Go to Billing in the Console
- Select your billing account
- Click Billing export in the left menu
Enable Each Export Type
Google offers four export types. Enable the ones you need:
1. Standard Usage Cost (Recommended)
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:
- Click Edit settings under "Standard usage cost"
- Select your project and dataset
- Click Save
2. Detailed Usage Cost (Recommended)
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:
- Click Edit settings under "Detailed usage cost"
- Select your project and dataset
- 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:
- Click Edit settings under "Pricing"
- Select your project and dataset
- 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
| Column | Description | Example |
|---|---|---|
billing_account_id | Your billing account | 01A2B3-C4D5E6-F7G8H9 |
service.description | GCP service name | Compute Engine |
sku.description | Specific product/SKU | N2 Instance Core |
project.id | Project ID | my-production-project |
usage_start_time | When usage started | 2025-01-15 08:00:00 UTC |
usage_end_time | When usage ended | 2025-01-15 09:00:00 UTC |
cost | Cost in billing currency | 1.23 |
credits | Applied credits | -0.50 |
labels | Resource labels | [{key: "env", value: "prod"}] |
location.region | GCP region | us-east1 |
Key Columns in Detailed Export (Additional)
| Column | Description | Example |
|---|---|---|
resource.name | Specific resource name | instance-1 |
resource.global_name | Full 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
- Go to Looker Studio
- Click Create → Data source
- Select BigQuery
- Choose your billing export table
- Click Connect
- 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:
- Write your query in BigQuery
- Click Schedule → Create new scheduled query
- 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
creditsto a newconsumption_modelfield - New fields:
price.list_price,price.effective_price_default,consumption_modelstruct - Two rows per CUD SKU instead of one (separating overage from discounted usage)
What's Next After Setup?
Now that you have billing data in BigQuery, you can:
- Build custom dashboards for your team
- Set up anomaly alerts for unexpected cost spikes
- Analyze optimization opportunities like idle resources
- Track CUD utilization if using committed discounts
- Allocate costs by team/project using labels
Key Takeaways
- Enable billing export today—data is not retroactive
- Enable both standard and detailed exports
- Wait 24-48 hours for initial data, up to 5 days for backfill
- Use date filters in queries to control BigQuery costs
- Build on this foundation with dashboards, alerts, or third-party tools
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: