Google Cloud Billing Export Guide: BigQuery Setup for Cost Analysis

Google Cloud Billing Export to BigQuery is one of the most useful foundations for FinOps on GCP. It gives you detailed, queryable billing data so you can build custom reports, track trends, and understand which services and projects drive spend. This guide covers setup steps, schema basics, and common queries.

Analyze Billing Data with InfraPilot

Why Export Google Cloud Billing to BigQuery?

Cost note: Exporting billing data doesn’t add an “export fee.” BigQuery storage and query usage may incur costs depending on dataset size and how you query it.

Prerequisites

Step-by-Step Setup Guide

1Create a BigQuery Dataset

  1. Open the BigQuery console
  2. Select a project to host billing data (can be a dedicated billing project)
  3. Create a dataset (choose a location, and avoid table expiration)

2Enable Billing Export

  1. Go to Billing → Billing export
  2. Enable Detailed usage cost export to your dataset
  3. Save settings

Note: It can take up to 24–48 hours for the first data to appear in BigQuery. Export is not retroactive by default.

3(Optional) Enable Pricing Export

Pricing export can help with what-if analysis and rate lookups. It’s optional for many teams; detailed usage cost export is usually enough to start.

4Configure Permissions

Understanding the Billing Export Schema

Billing export typically creates a table named like gcp_billing_export_v1_<BILLING_ACCOUNT_ID>. Common fields include:

Common BigQuery Billing Queries

Total Cost by Service (Last 30 Days)

SELECT
  service.description AS service,
  SUM(cost) AS total_cost,
  currency
FROM `project-id.billing_export.gcp_billing_export_v1_XXXXX`
WHERE DATE(usage_start_time) >= DATE_SUB(CURRENT_DATE(), INTERVAL 30 DAY)
GROUP BY service, currency
ORDER BY total_cost DESC;

Cost by Project (Current Month)

SELECT
  project.name AS project,
  SUM(cost) AS total_cost,
  currency
FROM `project-id.billing_export.gcp_billing_export_v1_XXXXX`
WHERE DATE(usage_start_time) >= DATE_TRUNC(CURRENT_DATE(), MONTH)
GROUP BY project, currency
ORDER BY total_cost DESC;

Top 10 Most Expensive SKUs

SELECT
  service.description AS service,
  sku.description AS sku,
  SUM(cost) AS total_cost,
  currency
FROM `project-id.billing_export.gcp_billing_export_v1_XXXXX`
WHERE DATE(usage_start_time) >= DATE_SUB(CURRENT_DATE(), INTERVAL 7 DAY)
GROUP BY service, sku, currency
ORDER BY total_cost DESC
LIMIT 10;

Best Practices

Use a Dedicated Billing Project

A dedicated billing project can simplify IAM and keep finance data separated from production workloads.

Label Resources for Attribution

Consistent labels enable cost attribution by team and environment.

Query Efficiently

Filter by date to leverage partitioning and reduce scanned data. Avoid SELECT *.

Integrating Billing Export with InfraPilot

  1. Sign in to InfraPilot
  2. Add an environment and select GCP billing analysis
  3. Grant read access to the billing dataset + permission to run queries
  4. Run cost analysis and generate AI insights
Start Analyzing Billing Data