Linking GCP Cloud Billing as a source

Alpha release

This source is currently in alpha. The interface and available tables may change.

Let AI connect your sources for you

Skip the manual setup — run this in your project and the wizard auto-detects your databases and APIs and connects them to PostHog.

Learn more
PostHog Wizard hedgehog

The GCP Cloud Billing connector syncs your Google Cloud Platform billing data into the PostHog data warehouse, including billing accounts, projects, subaccounts, services, SKUs, and budgets.

Note: This source is currently in alpha.

Prerequisites

Configuring Google Cloud

Step 1: Create a service account

  1. Go to the Google Cloud Console.
  2. Navigate to IAM & Admin > Service Accounts.
  3. Click Create Service Account.
  4. Provide a descriptive name (e.g., posthog-billing-reader) and click Create and continue.

Step 2: Grant billing permissions

Grant the service account the Billing Account Viewer role (roles/billing.viewer) on each billing account you want to sync. This provides read access to billing accounts, linked projects, services, and budgets.

For organization-wide access, grant the role at the organization level. For specific billing accounts, grant the role on each billing account individually.

Alternatively, create a custom role with just these permissions:

  • billing.accounts.list – list billing accounts
  • billing.accounts.get – read billing account details
  • billing.resourceAssociations.list – list projects linked to billing accounts
  • billing.budgets.get and billing.budgets.list – read budgets

Step 3: Generate a JSON key file

  1. In IAM & Admin > Service Accounts, click your service account.
  2. Go to the Keys tab.
  3. Click Add Key > Create new key, choose JSON, and download the key file.
  4. Store the key file securely – you can't download it again.

Step 4: Enable the APIs

  1. Enable the Cloud Billing API.
  2. Enable the Cloud Billing Budget API.

Adding a data source

  1. In PostHog, go to the Sources tab of the data pipeline section.
  2. Click + New source and click Link next to this source.
  3. Enter your credentials (see Configuration below) and click Next.
  4. Select the tables you want to sync, choose a sync method and frequency, then click Import.

Once the syncs are complete, you can start querying this data in PostHog.

Import billing accounts, project links, subaccounts, budgets, and the public price catalog from Google Cloud Platform. Upload the service account JSON key file you created above.

You'll be asked for:

  • Service account JSON key file – the JSON key file downloaded in the previous step

Sync modes

Each table can be synced in one of several modes, depending on what the source supports:

  • Webhook (when available) – the source pushes changes to PostHog in real time. Fastest freshness, lowest ongoing cost, and the only mode that reliably captures updates and deletes.
  • Incremental – only new or updated rows are synced on each run, using a cursor field (such as an updated_at timestamp). Cheaper than a full refresh, but deletes aren't captured.
  • Append only – new rows are appended using a cursor field; existing rows are never updated. Ideal for immutable, append-only tables like event logs.
  • Full refresh – the whole table is reloaded on every sync. Use it when a table has no reliable cursor or when you need deletions reflected.

See sync methods for a full explanation of how each mode works and how to choose between them.

All GCP Cloud Billing tables use full refresh sync. Each sync replaces the contents of the table because the Cloud Billing API doesn't provide timestamp filters for incremental updates.

Configuration

OptionTypeRequired
Service account JSON key filefile-uploadYes

Supported tables

TableDescriptionSync methodIncremental fieldPrimary key
billing_accounts

Billing accounts accessible to the service account.

Full refresh——
projects

Projects linked to each accessible billing account.

Full refresh——
sub_accounts

Billing subaccounts under each accessible reseller account.

Full refresh——
services

Google Cloud services in the public price catalog.

Full refresh——
skus

Public SKUs and their latest prices in USD for each Google Cloud service.

Full refresh——
budgets

Budget amounts, cost filters, thresholds, and notification settings for each accessible billing account.

Full refresh——

TableDescription
billing_accountsBilling accounts accessible to the service account
projectsProjects linked to each accessible billing account
sub_accountsBilling subaccounts under each accessible reseller account
servicesGoogle Cloud services in the public price catalog
skusPublic SKUs and their latest prices in USD for each service
budgetsBudget amounts, cost filters, thresholds, and notification settings

Limitations

  • The source imports current public SKU prices in USD only. Historical pricing isn't available.
  • Negotiated pricing and committed-use discounts aren't reflected – only public list prices are synced.
  • Detailed cost and usage data (line-item spend, usage metrics) isn't available through this source. For that, export your billing data to BigQuery and connect it as a separate BigQuery source.

Troubleshooting

Invalid service account key

If you see an error about an invalid or missing key:

  • Ensure you uploaded the complete JSON key file, not a partial copy or a different file type.
  • Generate a fresh key from the Google Cloud Console under IAM & Admin > Service Accounts > your account > Keys.

Permission denied

If syncing fails with a 403 error:

  • Verify the service account has the Billing Account Viewer role on the billing accounts you want to sync.
  • Confirm both the Cloud Billing API and Cloud Billing Budget API are enabled.
  • For organization-level access, grant the role at the organization level rather than on individual projects.

No billing accounts found

If no data appears after syncing:

  • Verify the service account is associated with at least one billing account.
  • Check that the Cloud Billing API is enabled in the Google Cloud project that owns the service account.

Credentials rejected by Google

If you see an error that Google rejected the service account key:

  • The key may have been rotated or revoked. Generate a new JSON key file and reconnect the source.
  • The service account may have been deleted. Create a new service account and key.

If your sync is failing or data looks wrong, see the Data warehouse troubleshooting guide. If that doesn't help, contact support – we're happy to help.

Still have questions?

Was this page useful?