Monitoring billing for tenants

All tenants are billed as part of their Identity Platform project. This document explains how to export billing data and monitor the cost of individual tenants.

Before you begin

To export tenant billing data, you'll need to be granted the IAM Owner role (roles/owner) on the following:

  • An Identity Platform project with multi-tenancy enabled.
  • The billing account linked to your project.

Enabling billing export to BigQuery

To make billing data available in BigQuery, follow the steps in Export billing data to BigQuery.

You only need to complete the step once per project.

Querying billing data

  1. Open the BigQuery page in the Google Cloud console.
    Go to the BigQuery page

  2. Select the table containing your project's billing information.

  3. Click Compose Query to open the query editor.

  4. Enter a query.

    To list the total cost for each tenant, use the following, replacing dataset-name.table-name with the name of the billing dataset and table you exported in step 1:

    SELECT labels.value as Tenant, SUM(cost) as TenantCost
    FROM [dataset-name.table-name]
    WHERE labels.key = "goog-identitytoolkit-tenant"
    GROUP BY 1
    

    All monthly active user reports have a start time at the beginning of the month. You can use WHERE usage_start_time and the first day of the month (expressed in Pacific Time) to filter on a monthly basis. For example, to list the cost of each tenant for August 2019:

    SELECT labels.value as Tenant, SUM(cost) as TenantCost
    FROM [dataset-name.table-name]
    WHERE labels.key = "goog-identitytoolkit-tenant"
    AND usage_start_time = "2019-08-01 00:00:00 -07:00"
    GROUP BY 1
    

    You can also get the costs for one specific tenant. Replace tenant-id with the ID of your tenant in the following example:

    SELECT labels.value as Tenant, SUM(cost) as TenantCost
    FROM [dataset-name.table-name]
    WHERE labels.key = "goog-identitytoolkit-tenant"
    AND labels.value = "tenant-id"
    GROUP BY 1
    
  5. Click Run query to execute it.

You should see a billing breakdown specific to one particular tenant.

What's next