Visualize your costs with Looker Studio

You can combine Cloud Billing data export to BigQuery withLooker Studio to stay up to date on your Google Cloud costs.

This document shows you how to set up theBilling usage and cost insightsdashboard with your Cloud Billing data. You can use the dashboard to answerquestions about your Google Cloud spend, such asHow much am I spending on Compute Engine resources?, andWhich environments are costing me the most?.

Example visualization in Looker Studio

You can set up your dashboard by following this tutorial, or watching thefollowing video:

Objectives

This tutorial shows you how to complete the following tasks:

  • Set up your own copy of theBilling usage and cost insights dashboard using Cloud Shell.

    You can use either Terraform or Python to follow the steps in this tutorial.

  • Configure the dashboard's filters to use the labels that you use in yourGoogle Cloud environment.

  • Learn about modifying the dashboard's data source for advanced cases, suchas if you have multiple Cloud Billing accounts, or aCloud Billing account in a currency other than US Dollars (USD).

Costs

In this document, you use the following billable components of Google Cloud:

The cost of storing your Cloud Billing data in BigQueryis typically free or minimal. Depending on the size of theBigQuery dataset, you might incur costs for querying the data foranalysis.

To generate a cost estimate based on your projected usage, use thepricing calculator.

New Google Cloud users might be eligible for afree trial.

Before you begin

  1. Ensure that you can access the sampleBilling usage and cost insights dashboard.If you can't access the sample, your organization might have domainrestrictions enabled. Your administrator can temporarily turn offdomain restriction for your account.

    Learn about domain restrictions.

    Note: If you are viewing the sample dashboard, thenproject names aredisplayed as anonymized project IDs. After you create a copy of thedashboard that fetches your Cloud Billing data, then you'll seeyour own projects in the dashboard, displayed by their project name.
  2. Verify that your organization has enabled the Cloud Billing exportto BigQuery, for the Standard usage cost data.

    If the Cloud Billing data export isn't enabled,learn about enabling the Cloud Billing data export toBigQuery.

    Note: When you enable the Cloud Billing data export toBigQuery for the first time, it might take a few hours foryour cost data to propagate to your BigQuery dataset.Learn more about data availability for your cost data export.
  3. You must havepermissions to create BigQueryviews in the project that hosts the datasets for your Cloud Billingdata export.

    Optionally, if you want to create a new dataset for theBigQuery views, you must have permissions to createBigQuerydatasets.

  4. Get the following information about your Google Cloud environment:

    • The project ID where your Cloud Billing BigQuerydataset is hosted.
    • The dataset names for your Standard and Detailed cost data exports.Typically, the cost data exports are in the same dataset.
  5. If you're sharing the dashboard with others in your organization, werecommend the following additional steps. These help you set up aGoogle Cloud service account, which can authenticate to theBigQuery data instead of requiring others to either use yourcredentials or their own to access the data.

    1. Get the email address for the Looker Studio service agentfrom theLooker Studio service agent helppage.

    2. If you're using the Python script to create the dashboard,create aservice account for the Looker Studio serviceagent.

      If you're using Terraform, you don't need to create the service accountmanually. The Terraform configuration creates the service account whenyou apply the configuration.

  6. If you're using the Python script, ensure that your Cloud Shellenvironment has a recent version of Python 3. To check Python version,in the Cloud Shell terminal, typepython --versionand press Enter.

Create your copy of the dashboard

Terraform

To create your own copy of the dashboard using Terraform, you first clone theGitHub repository that automates the process. This step usesCloud Shell, which is an interactive shell environmentfor Google Cloud that you can use from your browser. Cloud Shellcomes with Terraform pre-installed.

At a high level, the Terraform configuration in the repository does these tasks:

  • Creates a new BigQuery view that fetches data from yourStandard cost data export.
  • Copies thedashboard template and connects the copy to the BigQuery view of your data.
  • Gives you a Looker Studio link to your copy, which you cansave to your Looker Studio dashboards.
  • Gives you a Google Cloud service account ID, which you use as theauthentication method for the dashboard.

Follow these steps to create your dashboard:

  1. Open the GitHub repository in Cloud Shell:

    Open inCloud Shell

  2. Create a Terraform variable definitions file, with the information aboutyour project and BigQuery dataset. Use the following commandto create the file, calledvariables.tfvars:

    cat <<EOF >variables.tfvarsproject-id="PROJECT_ID"bq-dashboard-dataset-name="DATASET_NAME"bq-billing-export-table-id="PROJECT_ID.DATASET_NAME.TABLE_ID"looker-studio-service-agent-name="LOOKER_STUDIO_AGENT_NAME"EOF

    Where the variables are as follows:

    • PROJECT_ID: The project ID that hosts yourCloud Billing dataset.
    • DATASET_NAME: The BigQuery datasetthat contains your Standard cost data export.
    • TABLE_ID: The name for theBigQuery table that contains the Standard billing dataexport.
    • LOOKER_STUDIO_AGENT_NAME: The email address forthe Looker Studio service agent, which you get from theLooker Studio service agent helppage
  3. To initialize the GitHub repository as the Terraform working directory, runthe following command:

    terraforminit
  4. Optionally, to preview the changes that the Terraform configuration makes,run the followingterraform plan command:

    terraformplan-var-file=variables.tfvars

    You might be prompted to authorize Cloud Shell to make API calls onyour behalf.

  5. Review the Terraform changes, and editvariables.tfvars if you need tochange any variable values. When you're ready to create the resources, runthe followingterraform apply command:

    terraformapply-var-file=variables.tfvars

    After the command runs, you get the service account that was created forauthentication, and the link to your Looker Studio dashboard.

  6. Copy the service account name. You need this information when you configureauthentication for the Looker Studio data source.

  7. Click the Looker Studio link to open the dashboard.

  8. In Looker Studio, clickEdit and share to save the dashboard.When you're prompted to review data access settings, clickAcknowledge and save.

  9. If you're prompted about adding data to the report, clickAdd to report.

You can now access your dashboard from yourLooker Studio homepage.

Python

To create your own copy of the dashboard using Python, you first clone theGitHub repository that automates the process. This step usesCloud Shell,which is an interactive shell environmentfor Google Cloud that you can use from your browser.

At a high level, the setup script in the repository does these tasks:

  • Creates a new BigQuery view in the dataset that has yourStandard cost data export.
  • Copies thedashboard template and connects the copy to the BigQuery view of your data.
  • Gives you a Looker Studio link to your copy, which you cansave to your Looker Studio dashboards.

Follow these steps to create your dashboard:

  1. Open the GitHub repository in Cloud Shell:

    Open inCloud Shell

  2. Navigate to thebillboard directory:

    cdexamples/billboard
  3. Run the following commands to set up the Python environment for the script:

    rm-rfbill-envpython3-mvenvbill-envsourcebill-env/bin/activatepipinstall-rrequirements.txt
  4. Run the script that creates your dashboard. You might need to authorizeCloud Shell to make API calls on your behalf:

    pythonbillboard.py\-pr'PROJECT_ID'\-se'STANDARD_BILLING_EXPORT_DATASET'\-bb'BILLBOARD_DATASET'

    Where the variables are as follows:

    • PROJECT_ID: The project ID that hosts yourCloud Billing datasets.
    • STANDARD_BILLING_EXPORT_DATASET: TheBigQuery dataset that contains your Standard usage costdata export.
    • BILLBOARD_DATASET: The name for theBigQuery dataset where the BigQuery viewfor the dashboard is created, for example,example_dashboard_view.If you don't already have a dataset for the views, the script creates anew one with this name.

    When the script finishes running, you get a Looker Studio link toyour dashboard.

  5. Click the Looker Studio link to open the dashboard.

  6. In Looker Studio, clickEdit and share to save the dashboard.When you're prompted to add data sources to the report, clickAdd to report.

You can now access your dashboard from yourLooker Studio homepage.

(Optional) Configure the data source credentials

By default, the Billing usage dashboard uses your credentials to access theBigQuery data source. If you want to share the dashboard withothers, we recommend using a Google Cloud service account to authenticateto the BigQuery dataset, so that the data source isn't dependenton your credentials.

If you used Terraform to copy the dashboard, you get the service account ID whenyou run theterraform apply command. If you used the Python script, you mustmanually create the service account, using these steps:

  1. Get the email address for the Looker Studio service agentfrom theLooker Studio service agent helppage.

  2. Create a service account for the Looker Studio serviceagent.

  3. Grant the service account the following permissions on the project that hasthe BigQuery view for the dashboard:

    • bigquery.dataViewer
    • bigquery.jobUser
    • iam.serviceAccountTokenCreator

When you have the service account ID, follow these steps to use the serviceaccount for authentication:

  1. From yourLooker Studio homepage, open thedashboard.

  2. ClickEdit to edit the dashboard.

  3. From theResource menu, selectManage added data sources. The nameof the data source for the dashboard starts withbilling-export-view.

  4. From theActions column for the data source, clickEdit.

  5. ClickData credentials.

  6. In theUpdate data credentials page, selectService accountcredentials, and enter the service account ID.

  7. ClickUpdate to use the service account credentials.

  8. ClickDone to save the changes to the data source.

  9. To view the dashboard, clickView.

Update the dashboard to use your organization's labels

Several charts in the dashboard, such as those in theCost Reporting: Labelspage, are based on the labels on your resources. To see an accurate breakdown ofyour costs by specific labels, you must modify the default filters to use yourown labels.

  1. From yourLooker Studio homepage, open thedashboard.

  2. ClickEdit to edit the dashboard.

  3. From theResource menu, selectManage filters.

  4. Review filters that are based onlabels.key andproject.labels.key, andwhere applicable, clickEdit to change the label keys to ones that yourorganization uses.

    For example, if you use the label keydepartment to organize resources bybusiness unit, edit thebusiness_unit filter, and change theproject.labels.key filter todepartment.

  5. ClickClose to finish editing the filter.

Analyze your data in the dashboard

The pages in the Looker Studio dashboard break down your costdata so that you can look at quick summaries of your costs and trends, and getdetailed information about your spending.

In most pages, you can filter the data by project, and by using the calendarto choose the period for which you want to analyze the costs.

Get a high-level view of your costs

Use theOverview page for a high-level look at the net costs for the currentand previous invoice months, the costs for your top services, and daily costsfor the last 30 days.

Use theTrends page to compare your costs for different periods, such asthe current month and the last month, or the current quarter and last quarter.

Use theAnalysis page to analyze your costs over time, and identifyanomalies such as unusually high or low spending.

Identify your cost drivers

Use the following pages to find where you're spending the most:

  • Cost by service by month
  • Cost by project by month
  • Cost by project, service, and SKU
  • Cost by region

For a detailed look at your costs for each service, use the service-specificpages. For example, theGKE Clusters page shows you the costs broken down byyour GKE clusters and namespaces.

Identify opportunities to save with committed use discounts

Committed use discounts (CUDs) provide discounted prices in exchange for yourcommitment to use a minimum level of resources for a specified term.

The CUD pages in the dashboard show you yourCompute Engine, Cloud SQL, and Memorystore usagethat might be eligible for CUDs. If you already have one or more CUDs, thesepages only show usage that isn't already covered by your existing CUDs.

View costs for Cloud Marketplace software and additional licenses

Use theMarketplace page to see your costs for software thatyou've purchased from Cloud Marketplace, such asGoogle Cloud NetApp Volumes.

Use theLicenses page to see how much you're spending on additionallicences, such as licenses for Windows Server on Compute Engine, andthird-party licences that you've purchased from Cloud Marketplace.

View costs by labels

You cancustomize the dashboard's filters to use yourorganization's labels. After you update the filters, you can use the followingpages to view your costs across projects and folders:

  • TheBy application page shows costs for all resources under the label keyapplication. For example, if you have a web and mobile app, and label theirresources withapplication:web andapplication:mobile respectively, youcan see your costs for each application separately.

  • TheLabels page shows your costs for specific labels, such as costcenter and business code. If you customized the filters for the dashboard,you can change the titles on the charts to reflect your filters.

(Advanced) Modify the data for multiple Cloud Billing accounts

If you want the dashboard to include data from multiple Cloud Billingaccounts, you can modify the BigQuery views to include thebilling data exports for all the Cloud Billing accounts.

Before you begin

For each Cloud Billing account that you want to include, follow all thesteps inthe tutorial prerequisites.

Update the BigQuery views to include additional Cloud Billing exports

  1. In the Google Cloud console, open the BigQuery page.

    Go to BigQuery

  2. Select the project that containsthe dataset that you createdfor the dashboard.

  3. In theExplorer panel, expand your project, then expand the dataset.

  4. Click thebillboard view to see its details. This view queries yourStandard cost and usage data export.

  5. Click theDetails tab, then clickEdit Query. The query for the viewlooks similar to the following:

    SELECT*,COALESCE((SELECTSUM(x.amount)FROMUNNEST(s.credits)x),0)AScredits_sum_amount,COALESCE((SELECTSUM(x.amount)FROMUNNEST(s.credits)x),0)+costasnet_cost,PARSE_DATE("%Y%m",invoice.month)ASInvoice_Month,date(usage_end_time)ASdatefrom`PROJECT_ID.BILLING_ACCOUNT_EXPORT`sWHEREdate(usage_end_time) >DATE_SUB(CURRENT_DATE(),INTERVAL13MONTH)

    WherePROJECT_ID is the project that contains theBigQuery Standard cost data export for theCloud Billing, andBILLING_ACCOUNT_EXPORT is thename of the BigQuery table with your Standard cost data.

  6. Duplicate the existing query, and in theFROM clause, replace the projectID and BigQuery table with information for the additionalCloud Billing account.

  7. Add theUNION ALLoperator between the two queries to combine the data. Your final query lookssomething like the following example, which combines the data exports forBILLING_ACCOUNT_1 andBILLING_ACCOUNT_2, which are inPROJECT_ID_1 andPROJECT_ID_2respectively.

    SELECT*,--query for BILLING_ACCOUNT_1COALESCE((SELECTSUM(x.amount)FROMUNNEST(s.credits)x),0)AScredits_sum_amount,COALESCE((SELECTSUM(x.amount)FROMUNNEST(s.credits)x),0)+costasnet_cost,EXTRACT(DATEFROM_PARTITIONTIME)ASdateFROM`PROJECT_ID_1.BILLING_ACCOUNT_1_EXPORT`sWHERE_PARTITIONTIME>"2021-01-01"UNIONALLSELECT*,--query for BILLING_ACCOUNT_2COALESCE((SELECTSUM(x.amount)FROMUNNEST(s.credits)x),0)AScredits_sum_amount,COALESCE((SELECTSUM(x.amount)FROMUNNEST(s.credits)x),0)+costasnet_cost,PARSE_DATE("%Y%m",invoice.month)ASInvoice_Month,date(usage_end_time)ASdatefrom`PROJECT_ID_2.BILLING_ACCOUNT_2_EXPORT`sWHEREdate(usage_end_time) >DATE_SUB(CURRENT_DATE(),INTERVAL13MONTH)
  8. Repeat these steps for thebillboard_detail view, which queries theDetailed cost and usage data.

  9. If one of your accounts is in a different currency than USD, repeat thesesteps, and use thecurrency_conversion_rate column to convert to USD,similar to the following example:

    select*,(COALESCE((SELECTSUM(x.amount)FROMUNNEST(s.credits)x),0))/currency_conversion_rateAScredits_sum_amount,(COALESCE((SELECTSUM(x.amount)FROMUNNEST(s.credits)x),0))/currency_conversion_rate+cost/currency_conversion_rateasnet_cost,'USD'asnet_cost_currency,PARSE_DATE("%Y%m",invoice.month)ASInvoice_Month,date(usage_end_time)ASdatefrom`PROJECT_ID.BILLING_ACCOUNT_DATASET`sWHEREdate(usage_end_time) >DATE_SUB(CURRENT_DATE(),INTERVAL13MONTH)

Clean up

Terraform

If you don't want to use the dashboard any more, open your Terraform workingdirectory again, and use theterraform apply command to delete the resourcesthat you created.

  1. Open your Terraform working directory in Cloud Shell. If you usedthe GitHub repository in this tutorial, use the following link to open therepository:

    Open inCloud Shell

  2. Optionally, to preview which resources are deleted, run the followingterraform plan command:

    terraformplan-destroy
  3. Review the Terraform changes. When you're ready to delete the resources, runthe followingterraform apply command:

    terraformapply-destroy

Python

If you don't want to use the dashboard any more, clone the GitHub repository andrun the dashboard script with the-clean option. The script deletes theBigQuery views, but leaves your BigQuery exportdataset intact.

  1. Open the GitHub repository in Cloud Shell:

    Open inCloud Shell

  2. Navigate to thebillboard directory:

    cdexamples/billboard
  3. Run the following commands to set up the Python environment for the script:

    pipinstallvirtualenvvirtualenvbill-envsourcebill-env/bin/activatepipinstall-rrequirements.txt
  4. Run the cleanup command:

    pythonbillboard.py\-pr'PROJECT_ID'\-se'STANDARD_BILLING_EXPORT_DATASET'\-de'DETAILED_BILLING_EXPORT_DATASET'\-bb'BILLBOARD_DATASET'\-cleanyes

    Where the variables are as follows:

    • PROJECT_ID: The project ID that hosts yourCloud Billing datasets.
    • STANDARD_BILLING_EXPORT_DATASET: TheBigQuery dataset that contains your Standard usage costdata export.
    • DETAILED_BILLING_EXPORT_DATASET: TheBigQuery dataset that contains your Detailed usage costdata export.
    • BILLBOARD_DATASET: The BigQuerydataset where youcreated the BigQueryviews for the dashboard.
  5. To delete the Looker Studio dashboard,openLooker Studiolocate the dashboard, and from the menu

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-19 UTC.