☁️ Using BigQuery Billing Export to Manage your Invoice ☁️
Tags: googlecloud, gcp, bigquery, 100daysofcloud
Published: 2020-07-15 20:50:55

Welcome 😄

I'll be walking you through how to set up Google Cloud Platform Billing Export with BigQuery to help you manage and have more insight into your cloud invoice. 

## Why do I need this?

It depends. 

If you manage Billing at your company or have different side projects you definitely want to be able to manage, analyze, and optimize your cloud costs to fit your company/personal budget. If you're just experimenting with GCP, then it's just something to learn!

## Set up a BigQuery Dataset

### Navigate to BigQuery

![Searching for 'BigQuery' in the GCP console search bar](https://dev-to-uploads.s3.amazonaws.com/i/ibx4zvobs1moh9t6f2a5.PNG)

### Create a new Dataset

This is the Dataset that the Billing data will be streamed into

![BigQuery UI with Create Dataset button selected](https://dev-to-uploads.s3.amazonaws.com/i/s3cfhih909itiyoao0f7.PNG)

![Create Dataset form fields including dataset id, data location, table expiration, and encryption method](https://dev-to-uploads.s3.amazonaws.com/i/jgi0dt1nluvj0ds5t57n.PNG)

- Dataset ID: Can be whatever - 'Billing' works
- Data Location: Default is fine
- Table Expiration: For this walkthrough 2 days is fine, you probably wouldn't want it ever expiring though
- Encryption: Google-managed key is fine

### Click 'Create Dataset'

You now have a Dataset set up for your Billing data to be streamed into!

## Activate the Billing Export Feature

### Navigate to Billing

![GCP Console Left Menu with selection around Billing](https://dev-to-uploads.s3.amazonaws.com/i/p00k3n2jbr9r5nyc7968.png)

### Navigate to Billing Export

![GCP Billing View with selection around Billing Export](https://dev-to-uploads.s3.amazonaws.com/i/gee0awne4vw51l9u11di.PNG)

### Click 'Edit Settings' Button

![Billing Export UI with selection around 'Edit Settings'](https://dev-to-uploads.s3.amazonaws.com/i/51gf92m2jf7bslqpus4c.PNG)

> Note: If you don't see text that says 'Disabled' then you already have the Billing Export feature activated. So you just need to know the Dataset that it's streaming into and check it out.

### Select your Project & Billing Dataset

![Billing BigQuery Export Settings Form with fields for project and billing dataset](https://dev-to-uploads.s3.amazonaws.com/i/euxhj1yizev8sfhybdz0.PNG)

### Click Save

## And that's it!

Google mentions that it might take a few hours before the data starts streaming into the table, but there's nothing else to do from your end other than wait. 

## What you can do with this Dataset

The [Dataset](https://cloud.google.com/billing/docs/how-to/export-data-bigquery#data-schema) that Google creates and streams for you is really detailed and they're constantly making updates so that you can gain more insight into your costs and a breakdown of those costs down to the penny. This Dataset can be drilled down and analyzed by project or service and can even show you how much of your costs are in taxes. All you need to do is be creative with your queries.

## Extra Resources

[Analyzing Google cloud Billing Data with BigQuery](https://medium.com/google-cloud/analyzing-google-cloud-billing-data-with-big-query-30bae1c2aae4)

[Reconcile your Monthly GCP Invoice with BigQuery Billing Export](https://medium.com/@lukwam/reconcile-your-monthly-gcp-invoice-with-bigquery-billing-export-b36ae0c961e)

## Follow Me 😄

Twitter - @jsrioss
Github - @juanri0s