View Sample Billing Data with BigQuery

45 minutes
  • 2 Learning Objectives

About this Hands-on Lab

In this lab, we are going to use BigQuery to view a public dataset with sample billing data from a Google Cloud organization.

Note: Make sure you right-click on the green “Open GCP Window” button and choose “Open Link in Incognito Window.” If the legal agreement hangs for over a minute, just use the refresh page on your browser.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Launch BigQuery

Launch BigQuery

  • From the top left menu, scroll down to Big Data, and select BigQuery.
Run queries and view results

Run queries and view results

Now that we are in BigQuery, let’s look at the sample dataset we are going to work with. We are going to view all columns in our example table to see what fields are included. From the large Query Editor box, copy and paste the following query, then click the Run button:

FROM `cloud-training-prod-bucket.arch_infra.billing_data`

The field FROMcloud-training-prod-bucket.arch_infra.billing_data“ is the public dataset we are working with.

If we click the Results tab underneath, we can view the entire table we are going to work with. Feel free to experiment with other queries such as ordering by cost or usage amount by adding the below string to your query to sort by the column of your choice:

FROM `cloud-training-prod-bucket.arch_infra.billing_data`

In this query, we are bringing up the entire table contents, but sorting by the highest cost first. You can experiment with other fields as well.

Let’s now do some specific queries. In the same Query editor box, delete the existing contents, and enter the below query to find all charges that were more than 3 dollars:

SELECT product, resource_type, start_time, end_time,  
cost, project_id, project_name, project_labels_key, currency, currency_conversion_rate,
usage_amount, usage_unit
FROM `cloud-training-prod-bucket.arch_infra.billing_data`
WHERE (cost > 3)

Next let’s find which product had the highest total number of records:

SELECT product, COUNT(*)
FROM `cloud-training-prod-bucket.arch_infra.billing_data`
GROUP BY product

Looks like Pub/Sub is pretty popular here…

Finally, let’s see which product most frequently cost more than a dollar:

SELECT product, cost, COUNT(*)
FROM `cloud-training-prod-bucket.arch_infra.billing_data`
WHERE (cost > 1)
GROUP BY cost, product

Additional Resources

Though we have a few specific queries to go through, feel free to try other queries to see what type of data and insights you can find.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?