Skip to main content

Google Cloud Platform (GCP)

The GCP data source connects DataDios to one Google Cloud project. It lists the project's resources, starts and stops VMs and Cloud SQL instances, and reads the project's billed cost, after credits, from the BigQuery billing export. The cost appears on the Cost Dashboard in FinOps and on the data source's own dashboards in Workload Analyzer.

DataDios lists Compute Engine VMs, Cloud SQL instances, Cloud Storage buckets, BigQuery datasets, GKE clusters, Cloud Functions, Filestore instances, load balancers, Artifact Registry repositories, and Secret Manager secret names. It never reads secret values. Global resources, such as global HTTP(S) load balancers, are always listed, even when the region list is limited. BigQuery datasets show no start date.

This page takes you through everything in order: the setup in Google Cloud, the connection in DataDios, and turning on cost collection.


Checklist​

Work through this list in Google Cloud before you open DataDios. Each item links to its steps below.

#What you needWho can do itNeeded for
1The project ID of the project to connectAnyone with access to the projectEverything
2The APIs enabled in that projectProject Owner or EditorListing resources and cost
3A BigQuery dataset for the billing exportBigQuery User on the project that holds itCost
4The billing export turned onBilling Account Administrator or Billing Account Costs Manager, plus BigQuery User on the dataset's projectCost
5A service account with the right rolesService Account Admin and Project IAM AdminEverything
6A JSON key for that service accountService Account Key AdminEverything
7The full name of the billing export tableAnyone who can see the datasetCost

Without items 3, 4 and 7 the data source still connects and lists resources, but shows no cost.


Set Up Google Cloud​

1. Find the project ID​

  1. In the Google Cloud console, open the project picker at the top of the page.
  2. Copy the value in the ID column, for example acme-prod-123456. The project name does not work; DataDios needs the ID.

Create one GCP data source per project. A data source does not cover a whole organization or folder.

2. Enable the APIs​

Each Google Cloud service has its own API. If an API is disabled, DataDios skips that resource type without an error, and it never appears in the tree.

  1. In the project, open APIs & Services → Library.
  2. Search for each API below and click Enable.
APIRequiredWhat it is for
BigQuery APIYes, for costRunning the cost query.
Compute Engine APIYesVMs, and finding the project's regions when you leave region_name blank.
Cloud SQL Admin APIOptionalCloud SQL instances.
Cloud Storage APIOptionalBuckets. Enabled by default in most projects.
Kubernetes Engine APIOptionalGKE clusters.
Cloud Functions APIOptionalCloud Functions.
Cloud Filestore APIOptionalFilestore instances.
Artifact Registry APIOptionalArtifact Registry repositories.
Secret Manager APIOptionalSecret names.

In the project that holds the billing export dataset, also enable the BigQuery Data Transfer Service API. Google needs it to write the export.

With the gcloud command-line tool, the same step is:

gcloud services enable --project=PROJECT_ID \
bigquery.googleapis.com compute.googleapis.com sqladmin.googleapis.com storage.googleapis.com \
container.googleapis.com cloudfunctions.googleapis.com file.googleapis.com \
artifactregistry.googleapis.com secretmanager.googleapis.com

3. Create a dataset for the billing export​

The billing export writes to a BigQuery dataset that you choose. Many companies keep it in a separate billing project; that works, as long as you grant the roles in step 5 in the right projects.

  1. Open BigQuery in the project that will hold the export.
  2. In the Explorer panel, click the three-dot menu next to the project and click Create dataset.
  3. Enter a Dataset ID, for example billing_export.
  4. In Location type, select Multi-region and then US or EU. Google recommends a multi-region for billing data.
  5. Click Create dataset.

4. Turn on the billing export​

  1. In the Google Cloud console, open Billing and select the billing account that pays for the project.
  2. Click Billing export, then open the BigQuery export tab.
  3. Under Standard usage cost, click Edit settings. Detailed usage cost also works.
  4. Select the project and the dataset from step 3, and click Save.

Google creates the table within a few hours and starts filling it. The detailed export is not backfilled: cost starts on the day you turn it on, and DataDios cannot show cost for any earlier day. A standard export into a US or EU multi-region dataset also includes cost from the start of the previous month. If the export was already on, skip this step and use the existing table.

5. Create the service account​

DataDios signs in to Google Cloud as a service account: a Google account for an application, not a person. Create one for DataDios in the project to connect.

Create the account​

  1. At the top left of the Google Cloud console, open the project picker and select the project to connect.
  2. Open the ☰ menu and go to IAM & Admin → Service Accounts.
  3. Click + Create service account.
  4. In Service account name, enter datadios. Google fills in the Service account ID and shows the account's email, for example datadios@acme-prod-123456.iam.gserviceaccount.com. Copy the email; you need it below and in DataDios.
  5. Click Create and continue.

Grant the roles​

You are now on the Permissions step of the same screen.

  1. Click Select a role, type Viewer, and select Viewer.
  2. Click + Add another role, type BigQuery Job User, and select it.
  3. Click + Add another role, type BigQuery Data Viewer, and select it.
  4. Add any optional role from the table below in the same way.
  5. Click Continue, then Done.
RoleGrant it onRequiredWhat breaks without it
Viewer (roles/viewer)The project to connectYesResources do not appear.
BigQuery Job User (roles/bigquery.jobUser)The project to connectFor costCost extraction fails with a message asking for this role.
BigQuery Data Viewer (roles/bigquery.dataViewer)The billing export datasetFor costCost extraction fails with a message asking for this role.
Secret Manager Viewer (roles/secretmanager.viewer)The project to connectOptionalSecret names do not appear.
Compute Instance Admin (v1) (roles/compute.instanceAdmin.v1)The project to connectOptionalYou cannot start or stop VMs from DataDios.
Cloud SQL Editor (roles/cloudsql.editor)The project to connectOptionalYou cannot start or stop Cloud SQL instances from DataDios.

BigQuery Job User must be granted in the project you enter as project_id in DataDios, because that is where DataDios runs the cost query.

Give the account access to the billing dataset​

Granting BigQuery Data Viewer in the step above covers the billing dataset only when the dataset is in the same project. Grant it on the dataset itself as well; this is required when the export is in a separate billing project.

  1. Open the ☰ menu and go to BigQuery.
  2. In the Explorer panel, expand the project that holds the billing export and click the dataset from step 3.
  3. At the top of the dataset page, click Sharing → Permissions.
  4. Click Add principal.
  5. In New principals, paste the service account's email.
  6. In Select a role, select BigQuery Data Viewer.
  7. Click Save.

Role changes take up to a few minutes to apply. If a cost extraction fails with a permission message right after you grant a role, wait a few minutes and run it again.

The same steps with gcloud​

In Cloud Shell (the >_ button at the top right of the console):

PROJECT_ID=acme-prod-123456          # the project to connect
BILLING_PROJECT_ID=acme-prod-123456 # the project that holds the billing export dataset
SA=datadios@$PROJECT_ID.iam.gserviceaccount.com

gcloud iam service-accounts create datadios --project=$PROJECT_ID --display-name="DataDios"
for ROLE in roles/viewer roles/bigquery.jobUser; do
gcloud projects add-iam-policy-binding $PROJECT_ID --member="serviceAccount:$SA" --role="$ROLE"
done
# Read on the whole billing project. For least privilege, grant it on the dataset only, as above.
gcloud projects add-iam-policy-binding $BILLING_PROJECT_ID --member="serviceAccount:$SA" \
--role=roles/bigquery.dataViewer

6. Create a JSON key​

  1. Open the ☰ menu and go to IAM & Admin → Service Accounts.
  2. Click the email of the service account from step 5.
  3. Open the Keys tab.
  4. Click Add key → Create new key.
  5. Select JSON and click Create. The key file downloads to your computer.

The key file holds the two values DataDios needs:

"private_key": "-----BEGIN PRIVATE KEY-----\nMIIE...\n-----END PRIVATE KEY-----\n",
"client_email": "datadios@acme-prod-123456.iam.gserviceaccount.com",

If key creation is disabled​

If Google answers Service account key creation is disabled, your organization enforces the iam.disableServiceAccountKeyCreation policy, which is on by default for organizations created since May 2024. Someone with the Organization Policy Administrator role can allow keys for this project:

  1. With the project selected, open the ☰ menu and go to IAM & Admin → Organization Policies.
  2. In the filter box, type Disable service account key creation and click the policy.
  3. Click Manage policy.
  4. Under Policy source, select Override parent's policy.
  5. Click Add a rule, set Enforcement to Off, and click Done.
  6. Click Set policy.
  7. Create the key again.

The key file is a credential. Keep it out of email, chat and source control, and delete it once the data source is saved.

7. Copy the billing table name​

  1. Open BigQuery and expand the billing export dataset.
  2. Click the table whose name starts with gcp_billing_export_v1_ (or gcp_billing_export_resource_v1_ for the detailed export).
  3. On the Details tab, copy the Table ID. It has three parts separated by dots: BILLING_PROJECT_ID.billing_export.gcp_billing_export_v1_0A1B2C_3D4E5F_6G7H8I.

If the console shows a colon after the project, as in project:dataset.table, replace the colon with a dot.

Check the service account before you connect (optional)​

This runs the same kind of query DataDios runs, as the service account, and shows Google's own error if something is missing. In Cloud Shell, upload the key file (⋮ → Upload), then run:

gcloud auth activate-service-account --key-file=KEY_FILE.json
bq query --use_legacy_sql=false --project_id=PROJECT_ID \
'SELECT COUNT(*) AS row_count FROM `BILLING_TABLE`'
gcloud config set account YOUR_EMAIL # switch Cloud Shell back to your own account
rm KEY_FILE.json
ResultMeaning
A numberThe account can read the export. A 0 means the export has no rows yet.
bigquery.jobs.create permission deniedBigQuery Job User is missing in PROJECT_ID.
Access Denied: Table …BigQuery Data Viewer is missing on the dataset, or the table name belongs to another project.
BigQuery API has not been used in project …Enable the BigQuery API in PROJECT_ID (step 2).

Create the Data Source in DataDios​

  1. Navigate to the DataSources tab in DataDios and click Create DS.
  2. From the data source type list, select GCP_service, and enter a Name for the data source.
  3. Fill in the Connection Details in the credentials form.
FieldRequiredWhat to enterWhere to find it
client_emailYesThe service account address, for example datadios@acme-prod-123456.iam.gserviceaccount.com.client_email in the JSON key file.
private_key_inputYesDirect Input to paste the key, or From Secret Store to read it from AWS Secrets Manager or Azure Key Vault.Your choice.
private_keyYesThe whole key, from -----BEGIN PRIVATE KEY----- to -----END PRIVATE KEY-----.private_key in the JSON key file. Paste the value as it is in the file, including the \n sequences; DataDios restores the line breaks.
project_idYesThe project ID from step 1, for example acme-prod-123456.The project picker in the console.
region_nameNoRegions to scan, separated by commas, for example us-central1,europe-west1. Leave it blank to scan every region.The Location of your resources in the console.
billing_tableFor costThe table ID from step 7, in project.dataset.table form.The table's Details tab in BigQuery.
  1. Click Test Connection. DataDios gets an access token from Google with the key, which proves the key and email are valid without needing any API, and checks that billing_table has the project.dataset.table form. A successful test shows Successfully connected to the GCP_service.
  2. Open the Workload tab and turn on cost collection, as described in the next section.
  3. Click Save.

Turn on cost collection​

Cost is collected by workload analysis, which is off until you turn it on.

  1. On the Workload tab of the connection dialog, turn on Enable workload analysis.
  2. In Schedule, select Daily. The billing export is daily, so a shorter schedule collects nothing new.
  3. Under Workflows, keep GCP Cost Workload selected.
  4. Click Save. The toast Workload extraction started (30-day window) confirms it, and DataDios collects the last 30 days of cost, or every day since the billing export was turned on, if that is less.

To turn it on for a data source you already created, edit the data source on the DataSources tab, open the Workload tab, and follow the same steps.


Check That It Works​

WhereWhat you see when it works
DataSources → the GCP data sourceResources grouped by region, and a Cost Center node with the month-to-date cost of each Google Cloud service and the total on the parent row.
Workload Analyzer → DatasourcesThe GCP data source with a successful last run and a next run time.
Workload Analyzer → the data source's dashboardGCP Cost Trend, Cost by GCP Service and GCP Cost Summary for the selected dates.
FinOps → Overview → Cost DashboardA GCP bar in the Infrastructure domain. Click it to see each GCP data source, and click a data source to see its services.

If the tree loads but Cost Center is missing, or the dashboards stay empty, see Troubleshooting.


How Cost Is Counted​

  • Cost is shown after credits: sustained use and committed use discounts, free tier and promotions are subtracted, as on your invoice.
  • Only the connected project's cost is shown. A billing export holds every project on the billing account, so DataDios keeps the rows for this project only, and two GCP data sources on one billing account never count the same cost twice.
  • Each row is the cost of one Google Cloud service in one region on one day, in the currency of your billing account. Services that have no region, such as some global networking, appear without one.
  • Cost is per service. The billing export does not attach cost to the resources in the tree, so a VM row carries no cost.
  • A day is collected once, the day after it ends. Google can still add late charges to a day for up to a few days, and DataDios does not collect them afterwards, so the most recent days can come out slightly below the invoice.

Turning VMs and Cloud SQL Instances On and Off​

  1. On the DataSources tab, open the GCP data source and click Refresh Row Data on the VM or Cloud SQL instance, so its status is current.
  2. Click the Power icon on the row to start or stop it.

This needs the optional Compute Instance Admin (v1) or Cloud SQL Editor role, and works only for Compute Engine VMs and Cloud SQL instances.


Troubleshooting​

Message or symptomCause and fix
project_id, client_email, and private_key are required.One of the three is empty. Fill it in from the JSON key file.
billing_table '…' is not a valid BigQuery table.billing_table is not in project.dataset.table form, for example a bare table name, a missing dataset, or a colon after the project.
private_key is not a valid service-account key.The key text is incomplete or was retyped. Copy private_key from the JSON key file again.
Google rejected the service-account key (invalid_grant)The key was deleted or disabled, or client_email belongs to a different service account. Create a new key.
Cost extraction fails asking for BigQuery Data Viewer and BigQuery Job UserGoogle refused the query. Check, in order: the roles from step 5 are on the service account in client_email (not another account); billing_table is the exact table ID, since a table in a project the account cannot see is refused the same way; project_id is the project where BigQuery Job User is granted; and a few minutes have passed since the roles were granted. Check the service account shows Google's exact reason.
Cost extraction fails with check 'billing_table'The table does not exist. Check for a typo, or for an export that was turned off and on again under a new table.
Cost extraction fails with needs a BigQuery billing export tablebilling_table is empty. Cost has no other source.
Cost extraction fails with Data source rate limit or query throttle exceeded.BigQuery quota or rate limit. DataDios tries the same day again on the next run.
A resource type never appearsIts API is disabled in the project, or the service account lacks Viewer.
The tree loads but Cost Center is missingThe export table is still empty, because the first rows take a few hours, or the service account cannot read it.
Days before a certain date never fill inThe billing export starts on the day it was turned on (a standard export into a US or EU dataset also covers the previous month).
Key creation is disabled in Google CloudYour organization enforces iam.disableServiceAccountKeyCreation. See If key creation is disabled.

Not Supported​

  • Inventory or cost across a whole organization or folder. Create one data source per project.
  • Cost per individual resource.
  • Starting and stopping anything other than Compute Engine VMs and Cloud SQL instances.
  • Authentication other than a service account JSON key, such as workload identity federation.