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.
Data reference
| Property | Value |
|---|---|
| Latency | 24–48 hours |
| Historical data | From 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.
Setup
Enable BigQuery billing export
Go to GCP Console → Billing → Billing export → BigQuery export → Edit settings.
- Select your project.
- Create a new dataset or choose an existing one. Note the dataset ID — you will need it later.
- Enable Standard usage cost export.
- Click Save.
Data takes 24–48 hours to start appearing after enabling export for the first time.
Enable the Cloud Billing API
Go to Console → APIs & Services → Enable APIs & Services. Search for Cloud Billing API and click Enable.
Create a service account
Go to Console → IAM & Admin → Service Accounts → Create service account.
- Set the name to
stackspend-billing. - Click Create and continue, then Done.
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.
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.
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.
Add to StackSpend
Go to Providers → Add provider → GCP.
- Paste the entire contents of the JSON key file into the key field.
- Enter your Billing Account ID, Project ID, Dataset ID, and Table ID.
- Click Save.
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.
