StackSpendDocs

GCP

Connect Google Cloud Platform billing to StackSpend via BigQuery export.

What StackSpend tracks

StackSpend imports GCP costs through the BigQuery billing export. This provides project-level, service-level, and dataset-level granularity. Data is updated on a daily batch schedule with a 24–48 hour latency after it lands in BigQuery.

No historical backfill.GCP has no historical backfill. StackSpend can only import costs from the date you enable BigQuery billing export. There is no way to retrieve data before that date. Enable billing export as soon as possible — every day you wait is data you permanently lose.

Data reference

PropertyValue
Latency24–48 hours
Historical dataFrom export-enable date only
Setup time~10 min

Prerequisites

  • A GCP project with an active billing account
  • Cloud Billing API enabled
  • BigQuery API enabled

This is the most complex provider setup (~10 minutes) because it requires enabling BigQuery billing export, creating a service account, and granting three separate IAM roles.

Tip.Write down your Billing Account ID, Project ID, Dataset ID, and Table ID before opening StackSpend — you will need all four.

Setup

1

Enable BigQuery billing export

Go to GCP Console → Billing → Billing export → BigQuery export → Edit settings.

  1. Select your project.
  2. Create a new dataset or choose an existing one. Note the dataset ID — you will need it later.
  3. Enable Standard usage cost export.
  4. Click Save.

Data takes 24–48 hours to start appearing after enabling export for the first time.

2

Enable the Cloud Billing API

Go to Console → APIs & Services → Enable APIs & Services. Search for Cloud Billing API and click Enable.

3

Create a service account

Go to Console → IAM & Admin → Service Accounts → Create service account.

  1. Set the name to stackspend-billing.
  2. Click Create and continue, then Done.
4

Grant IAM roles

The service account needs three roles granted at different levels.

(a) Billing Account Viewer — on the billing account

Go to Billing → Account management → Roles → Add principal. Paste the service account email and assign Billing Account Viewer. This must be set on the billing account, not the project.

(b) BigQuery Job User — on the project

Go to IAM → Add principal. Paste the service account email and assign BigQuery Job User.

(c) BigQuery Data Viewer — on the dataset

Open BigQuery Studio, navigate to your billing dataset, click Share → Add principal, paste the service account email, and assign BigQuery Data Viewer.

5

Create a JSON key

Go to Service Accounts → your service account → Keys → Add Key → Create new key. Select JSON and download the key file. Keep this file secure.

6

Note your IDs

Collect the following before proceeding:

  • Billing Account ID — Billing → Account management, shown at the top of the page.
  • Project ID — visible in the project selector dropdown.
  • Dataset ID — the dataset you selected or created in Step 1.
  • Table ID — usually named gcp_billing_export_v1_..., visible in BigQuery Studio under your dataset.
7

Add to StackSpend

Go to Providers → Add provider → GCP.

  1. Paste the entire contents of the JSON key file into the key field.
  2. Enter your Billing Account ID, Project ID, Dataset ID, and Table ID.
  3. Click Save.
8

Verify

If you just enabled billing export, wait 24–48 hours before expecting data to appear. Check the provider page in StackSpend for the last sync status and any errors.

StackSpend Docs