Visualize spend over time with Google Data Studio

You can get up-to-date Cloud Billing graphs throughout the day, and use labels to slice and dice your Google Cloud bill the way you want by combining Cloud Billing data export to BigQuery functionality with Google Data Studio.

A Data Studio Dashboard showing cost trends over
         time and monthly cost by team for a fictional company, ACME.

Export your Cloud Billing data to BigQuery

To start exporting your billing data into a BigQuery dataset, follow the procedure in Export Cloud Billing Data to BigQuery. After you follow the procedure, it takes about a day for the dataset to begin to be populated with Cloud Billing data. (You might see some network egress first, then some VM charges, then Pub/Sub usage, and so on.) After you've got data in your dataset, you can run queries against it.

The following is an example query:

SELECT
  invoice.month,
  service.description,
  ROUND(SUM((cost) + SUM(IFNULL((
        SELECT
          SUM(c.amount)
        FROM
          UNNEST(credits) c),
        0))) AS cost_after_credits
FROM
  `data-analytics-pocs:public.gcp_billing_export_EXAMPL_E0XD3A_DB33F1`
WHERE
  invoice.month = "201906"
GROUP BY
  1,
  2
ORDER BY
  3 DESC;

The following screenshot shows the example query in BigQuery:

A Cloud Billing query and the results in
         BigQuery.

Start working with the sample Cloud Billing report

To see and copy the sample billing report:

  1. Open the Billing Report Demo.
  2. In the left navigation pane, click READ ME for steps to copy and use the report with your data.

A Data Studio Dashboard showing cost trends over time, monthly cost by team, and monthly cost by project for a fictional company, ACME.

Slice and dice your Cloud Billing reports using labels

You can use labels to answer complex questions, such as "How can I tell what Service X is costing me?", or "What am I spending on my development environments versus production?" You apply labels, which are key/value pairs, to your Google Cloud resources. Common uses of labels include:

  • Labels based on team or cost center. You can use these labels to distinguish projects owned by different teams, which is useful in cost accounting or budgeting. For example, team:marketing and team:research.
  • Labels based on component. For example, component:redis and component:frontend.
  • Labels based on environment or stage. For example, environment:prod and environment:test.

For additional information about labels, read Labelling and grouping your Google Cloud resources.

The example report and dataset uses three project labels (project.labels.key) to demonstrate visualizing data by project label:

A Data Studio Dashboard showing costs by Google Cloud service for a fictional company, ACME.