Google Cloud — Export Billing Data to BigQuery

Allan Alfonso
Google Cloud - Community
5 min readMay 9, 2022

FinOps is an evolving cloud financial management discipline and cultural practice that enables organizations to get maximum business value by helping engineering, finance, technology and business teams to collaborate on data-driven spending decisions. — FinOps Foundation Technical Advisory Council

In other words, FinOps is a practice where users take ownerships of their cloud consumption, manage their costs accordingly, and think about how their cloud spend affects business value. This involves a combination of education, visibility, and shared best practices. For Google Cloud customers, one piece of a FinOps strategy is to export billing data into BigQuery to make costs visible across the organization.

The Google Cloud billing reports helps you monitor, optimize, and analyze your Google cloud costs. You can use it to review your cost history, cost trends, and forecasted costs from the Google console. However, for more granular analysis, use “Exporting your billing data into BigQuery”. Exporting your billing data into BigQuery allows you to slice and dice your billing data using the querying capabilities of BigQuery and offers the most customizable form of analysis. You can fine tune your analysis using advanced queries and then visualize your results using Data Studio or Looker. The recommendation from Google Cloud is to setup the billing export when you create the billing account.

Benefits:

  • Cost analysis beyond the default billing reports dashboard.
  • Create custom queries and dashboards.
  • Export data to visualization tools or csv files.
  • Part of a FinOps strategy.

Setup Billing Export

  1. Enable the BigQuery Data Transfer Service API
BigQuery Data Transfer API

2. Create a BigQuery dataset to manage all your billing data. The Google recommendation is to use a multi-region option since some features such as detailed usage cost data is only supported in multi-region location. Click the 3 dots next to the project ID and select “Create Dataset”.

Create BigQuery dataset

To create the dataset:

  • Enter a dataset ID. This is user defined.
  • Select a data location. The Google recommendation is multi-region.
  • Ensure table expiration option is cleared.
  • Ensure Use a customer-managed encryption key (CMEK) option is cleared.

You should see the create dataset under the project ID in BigQuery.

Created dataset nested under project ID

3. Enable cloud billing export to the BigQuery dataset from the billing menu. Select one of Standard usage cost or Detailed usage cost. The detailed usage cost provides the same information as the standard usage cost along with additional fields that provide resource-level data.

Enable cloud billing export options

In the billing export configuration, select the project where the BigQuery lives and select the dataset you created.

The Biling export page will show which items are enabled and exported. These settings can be changed by enabling/disabling the options. You can also export pricing, which is pricing data applicable to your cloud billing account.

Billing export options

After a few minutes, billing data tables are automatically created in the BigQuery dataset. Do NOT modify any of these data tables. Depending on the type of exported data, it could take up to 48 hours to start seeing data.

BigQuery dataset collects exported billing data

Google Cloud provides several sample queries you can use to analyze your billing data.

Example query to calculate total costs per invoice

Visualization

Since the billing data is in BigQuery, you can use any visualization tool that is compatible with BigQuery. Two recommended tools from Google Cloud are Looker and Data Studio. Looker is feature rich and the more flexible of the two options. If you need quick and free, then try Data Studio. Data Studio also has a sample dashboard you can copy for quick visualization.

Visualize Billing Data with Data Studio

On the left hand side, select “(READ ME)”. This shows instructions on how to copy the dashboard and change the data source to the BigQuery table you created.

TIP: To easily find the fully qualified table name, create a query in BigQuery
The Fully Qualified Table Name is auto-generated when creating a query

When you reconnect and review the confirmation, you should see the following pop-up screen. No fields should change.

Confirm connection to Big Query

When complete, data studio will visualize your data using the pre-built queries.

Visualize Billing Data using Data Studio

Further Watching

Export Billing Data

--

--