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.
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 `ctg-storage.bigquery_billing_export.gcp_billing_export_v1_01150A_B8F62B_47D999` WHERE invoice.month = "202006" GROUP BY 1, 2 ORDER BY 3 DESC;
The following screenshot shows the example query in BigQuery:
Start working with the sample Cloud Billing report
To see and copy the sample billing report:
- Open the Billing Report Demo.
- In the left navigation pane, click READ ME for steps to copy and use the report with your data.
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,
- Labels based on component. For example,
- Labels based on environment or stage. For example,
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:
- team label is used to populate the respective charts and filters for costs by team.
- service label is used to populate the respective charts and filters for costs by Google Cloud service type (for example, compute, storage, and more).
- env label is used to populate the respective charts and filters for costs distributed by environment (for example, prod, dev, and more).