OnboardingGoogle Cloud

Billing export

LevelFour reads your Cloud Billing data through the BigQuery billing export, the most detailed billing data Google Cloud produces. It breaks costs down to the individual resource, label, and SKU, and prices every recommendation against what you were billed rather than list rates.

Set it up once per Cloud Billing account, in the Cloud Billing console. Billing export is billing-account scoped, so a single export covers every project that pays through that billing account. You do not configure it per project.

Connect your projects first. Follow Connect Google Cloud before this page. LevelFour reads costs only for projects you have already connected, so an export connected on its own produces no cost data.

An organization connection ingests every connected project's costs from the export. A single-project connection ingests only that one project's costs, even though the export itself contains the whole billing account.

What you enable

  • Detailed usage cost export, one row per SKU per resource per day, with resource-level detail and labels.

The export lands in a table named gcp_billing_export_resource_v1_<BILLING_ACCOUNT_ID> inside a BigQuery dataset you control.

Enable the Detailed export, not the Standard one. The Standard usage cost export drops the per-resource rows that LevelFour needs to attribute cost to individual resources. A Standard export will connect successfully, but it produces no savings recommendations and only an estimated figure for realized savings.

Google Cloud offers two further exports on the same screen:

  • Committed Use Discounts. Enable it if you hold committed use discounts and connected at the organization level. See Committed Use Discounts export.
  • Pricing. LevelFour does not read the Pricing export yet. Leave it off unless another tool needs it.

The export itself is free. You pay only BigQuery storage for the export table: the first 10 GB per month is free, and beyond that BigQuery active storage is about $0.02 per GB per month. LevelFour's queries run in LevelFour's own Google Cloud project, so the cost of reading the export is on LevelFour, not on you.

Costs in a non-USD billing account are converted to USD using the conversion rate Google includes in each export row. Everything you see in LevelFour is in USD.

Prerequisites

  • A finance or billing identity with Billing Account Administrator or Costs Manager on the Cloud Billing account you want to export.
  • BigQuery Admin (or an equivalent) on the Google Cloud project that will hold the export dataset, so the console can create the dataset and the connect command can update its access list.

These are often different people from whoever connected your projects. That is fine: billing export is configured once at the billing-account level.

Billing-account IAM admin rights are useful but not required. Without them the connect command still grants LevelFour read access to your export dataset; it just skips two optional billing-account roles and tells you it did.

Step 1 - Create a BigQuery dataset

In the project that will hold the export, create a BigQuery dataset (the Cloud Billing setup can also create one for you). A common name is billing_export. Choose the location deliberately:

  • Use a US or EU multi-region unless you have a specific data-residency requirement. Multi-region is the most broadly compatible location and matches how LevelFour reads the data.
  • The dataset location is permanent. You cannot move a dataset after it is created, so if you pick the wrong location you have to make a new dataset and reconfigure the export.

Note which project holds this dataset. You need it in Step 4.

Step 2 - Turn on the Detailed usage cost export

  1. Open the Cloud Billing console and select the billing account you want to export.
  2. Go to Billing export, then the BigQuery export tab.
  3. Under Detailed usage cost, click Edit settings, choose the project and the dataset from Step 1, and save.

Do not point the Standard usage cost export at the same dataset. If one dataset holds both tables, the connect command in Step 4 registers the Standard export and your recommendations stay empty. Use a separate dataset if you need Standard for another tool.

Step 3 - Wait for the first data

Google Cloud writes the first rows 24 to 48 hours after you enable the export. When the export starts, it also backfills recent history, filling in up to 5 days of prior usage, so early cost views populate retroactively. Until the first load lands, the dataset exists but its tables are empty. That is expected and not an error.

Step 4 - Connect the export to LevelFour

Open the Connect Google Cloud page in the dashboard and find the Billing data (BigQuery export) panel. Click Generate billing connect command, then Copy.

This is a second, separate command from the one that connected your projects. Paste it as shown; there is nothing in it for you to fill in.

Run this from a Cloud Shell whose active project is the project that holds your export dataset. The script searches that project only. Set it first:

gcloud config set project YOUR_EXPORT_PROJECT_ID

The script also uses the first billing account your identity can see. Run gcloud billing accounts list to check. If you have several, connect them one at a time from an identity scoped to each.

The script needs gcloud, bq, and python3, all of which Cloud Shell provides. It finds your export table, then asks you two questions:

  1. Continue? [y/N] before granting roles/bigquery.dataViewer on the export dataset to your service account. Answer y.
  2. Cap this export table to 92 days to minimize BigQuery storage cost? LevelFour keeps full history. [y/N] Answer y to bound your BigQuery storage, or press Enter to leave your table's retention alone. LevelFour re-reads only the recent window and keeps full history in its own database, so capping loses you no analysis.

Anything other than y or Y counts as no. The dataset grant is already applied by the time the second question appears, so declining the cap does not undo the connection.

The script then tries to grant two optional read roles on the billing account itself, roles/billing.viewer and roles/recommender.billingAccountCudViewer. These need billing-account IAM admin. If you do not have it the script prints Could not grant <role> (needs billing-account IAM admin); skipping. and carries on.

Finally it reports the dataset and table back to LevelFour, which confirms the service account can read the export before marking it connected. The command stays valid for 30 days and is safe to re-run.

Capping storage yourself

If you would rather set the partition expiration before you connect, or your finance team manages BigQuery retention centrally, run it directly once the table exists:

bq update --time_partitioning_expiration 7948800 \
  YOUR_PROJECT_ID:billing_export.gcp_billing_export_resource_v1_YOUR_BILLING_ACCOUNT_ID

7948800 seconds is 92 days.

Confirming it worked

Open Connect Accounts -> Google Cloud in the dashboard. The Billing data (BigQuery export) panel summarizes which billing accounts are connected. Within about two days of enabling the export, your billing account shows as connected and resource-level cost breakdowns appear in your cost views.

Export status reference

The Billing data, Committed Use Discounts, and Pricing panels all use the same status labels:

StatusMeaning
Not connected yetLevelFour has no access to this export. Run the connect command, or enable the export first
Setting upLevelFour has access and is waiting for the first data to land
ConnectedLevelFour is reading the export. The panel shows when it last synced
Action neededSomething on your side is blocking the read, usually a missing grant or a missing export
Sync errorThe last read failed. The panel shows the reason Google Cloud returned

If you have several billing accounts, the panel shows the least-ready status across all of them, so a partially connected setup never reads as fully connected.

Removing access

Remove the dataset access entry and the two billing-account roles. Use the address the connect script printed; see Finding your service-account address if you no longer have it.

SA="PASTE_THE_ADDRESS_THE_SCRIPT_PRINTED"

# Drop the dataset read grant
bq show --format=prettyjson YOUR_PROJECT_ID:billing_export > policy.json
# remove the entry whose userByEmail is $SA, then:
bq update --source policy.json YOUR_PROJECT_ID:billing_export

# Drop the billing-account roles, if they were granted
for ROLE in roles/billing.viewer roles/recommender.billingAccountCudViewer; do
  gcloud billing accounts remove-iam-policy-binding YOUR_BILLING_ACCOUNT_ID \
    --member="serviceAccount:$SA" --role="$ROLE"
done

To also remove the project and organization roles, see Removing access.

Troubleshooting

No BigQuery billing export table found. Enable BigQuery billing export first, then re-run. Either the export is not on yet, its first data has not landed (Step 3), or your Cloud Shell is pointed at a different project than the one holding the dataset. Run gcloud config set project YOUR_EXPORT_PROJECT_ID and try again.

No billing account found for your gcloud identity. The identity running the command cannot see any billing account. Run gcloud billing accounts list to confirm, and use an identity with Billing Account Administrator or Costs Manager.

bq (the BigQuery CLI) is required. Open this in a Cloud Shell. Run the command in Cloud Shell, which ships gcloud, bq, and python3.

The script stops on a bq error and the panel stays at Not connected yet. A failed read or update on the dataset stops the script before it reports back, so LevelFour never hears about the connection. Confirm you have BigQuery Admin on the project holding the dataset, then re-run.

The dataset tables are still empty after two days. Confirm the Detailed usage cost export is enabled on the correct billing account, that the dataset is in a US or EU multi-region, and that the billing service has write access to the dataset. The first export can take the full 24 to 48 hours.

You get a permission error when enabling the export. You need Billing Account Administrator or Costs Manager on the billing account, and BigQuery Admin on the project that holds the dataset. Have whoever owns billing complete this step.

The panel shows Connected, but there are no savings recommendations. Check that you enabled the Detailed export, not the Standard one. Only the Detailed export carries the per-resource rows LevelFour needs.

The command fails on the IAM binding. If your organization enforces Domain Restricted Sharing (iam.allowedPolicyMemberDomains), the policy blocks the grant until you allowlist LevelFour's Cloud Identity customer ID. See the Domain Restricted Sharing note in Connect Google Cloud.