Structure of Detailed data export

This document provides reference information for the schema of Cloud Billing detailed usage cost data that's exported to each table in BigQuery.

The detailed usage cost data provides all of the information included in the standard usage cost data , along with additional fields that provide granular, resource-level cost data, like a virtual machine or SSD that generates usage. The detailed export includes granular cost information about the following services:

  • AlloyDB for PostgreSQL
  • App Engine
  • BigQuery
  • Bigtable
  • Cloud Data Fusion
  • Cloud Deploy
  • Cloud Run functions
  • Cloud Logging
  • Cloud Run
  • Cloud SQL
  • Cloud Storage
  • Compute Engine
  • Dataflow
  • Dataproc Metastore
  • Firestore and Datastore
  • Google Kubernetes Engine (GKE)
    To view a breakdown of GKE cluster costs in a detailed data export, you must also enable cost allocation for GKE .
  • Managed Microsoft AD
  • Memorystore for Redis
  • Secret Manager
  • Spanner

Identify granular cost data by service

To analyze granular cost information in a detailed export, use the following table to identify the column that contains information about specific resources.

Service description
Column
How to identify resources
AlloyDB for PostgreSQL
service.description and resource.name or resource.global_name

The service.description column contains the name of the service. The resource.name column contains the name provided by the user. The resource.global_name column contains a unique identifier for the resource.

App Engine
service.description and resource.name , or resource.global_name

The service.description column contains the name of the service. The resource.name column contains the name provided by the user. The resource.global_name column contains a unique identifier for the resource.

BigQuery
service.description and resource.name , or resource.global_name

The service.description column contains the name of the service. The resource.name column contains the name provided by the user. The resource.global_name column contains a unique identifier for the resource.

Bigtable
service.description and resource.global_name

The service.description column contains the name of the service. The resource.global_name column contains a unique identifier for the resource.

Cloud Data Fusion
service.description and resource.name or resource.global_name

The service.description column contains the name of the service. The resource.name column contains the name provided by the user. The resource.global_name column contains a unique identifier for the resource.

Cloud Deploy
service.description and resource.name or resource.global_name

The service.description column contains the name of the service. The resource.name column contains the name provided by the user. The resource.global_name column contains a unique identifier for the resource.

Cloud Run functions
service.description and resource.name or resource.global_name

The service.description column contains the name of the service. The resource.name column contains the name provided by the user. The resource.global_name column contains a unique identifier for the resource.

Cloud Logging
service.description and resource.global_name

The service.description column contains the name of the service. The resource.global_name column contains a unique identifier for the resource.

Cloud Run
service.description and resource.name or resource.global_name

The service.description column contains the name of the service. The resource.name column contains the name provided by the user. The resource.global_name column contains a unique identifier for the resource.

Cloud SQL
service.description and resource.global_name

The service.description column contains the name of the service, and the resource.global_name column contains a unique identifier for the resource.

Cloud Storage
service.description and resource.global_name

The service.description column contains the name of the service. The resource.global_name column contains a unique identifier for the resource.

Compute Engine
service.description and resource.name or resource.global_name

The service.description column contains the name of the service. The resource.name column contains the name provided by the user. The resource.global_name column contains a unique identifier for the resource.

Dataflow
service.description and resource.name , or resource.global_name

The service.description column contains the name of the service. The resource.name column contains the name provided by the user. The resource.global_name column contains a unique identifier for the resource.

Dataproc Metastore
service.description and resource.name or resource.global_name

The service.description column contains the name of the service. The resource.name column contains the name provided by the user. The resource.global_name column contains a unique identifier for the resource.

Firestore and Datastore
service.description and resource.name , or resource.global_name

The service.description column will be App Engine. The resource.name column contains the name provided by the user. The resource.global_name column contains a unique identifier for the resource.

Google Kubernetes Engine (GKE)
labels.key

Use the following label keys to filter the resources:

  • goog-fleet-project : Filter your cluster resources by fleet host project , if the cluster is registered to a fleet.
  • goog-k8s-cluster-location : Filter your GKE resources by location.
  • goog-k8s-cluster-name : Filter your GKE resources by cluster.
  • goog-k8s-node-pool-name : Filter your cluster resources by node pool.
  • k8s-namespace : Filter your GKE resources by namespace.
  • k8s-namespace-labels : Filter your GKE resources by fleet namespace label .
  • k8s-label : View all your GKE resources.

To view granular GKE cluster costs in your detailed cost data export, you must also enable cost allocation for GKE .

See example queries for filtering GKE data in BigQuery exports .

Managed Microsoft AD
service.description and resource.name or resource.global_name

The service.description column contains the name of the service. The resource.name column contains the name provided by the user. The resource.global_name column contains a unique identifier for the resource.

Memorystore for Redis
service.description and resource.global_name

The service.description column contains the name of the service. The resource.global_name column contains a unique identifier for the resource.

Secret Manager
service.description , resource.name , and resource.global_name

The service.description column contains the name of the service. The resource.name column contains the name provided by the user. The resource.global_name column contains a unique identifier for the resource.

Spanner
service.description and resource.global_name

The service.description column contains the name of the service, and the resource.global_name column contains a unique identifier for the resource.

See examples of querying granular data for your resources .

Detailed usage cost data schema

In your BigQuery dataset, your detailed Google Cloud usage cost data is loaded into a data table named gcp_billing_export_resource_v1_<BILLING_ACCOUNT_ID> .

When you use the detailed usage cost data in BigQuery, note the following:

  • The table schema for the detailed Cloud Billing data export can change over time, such as when new fields are added to the detailed export. To protect your queries from future schema changes, rather than relying on queries that directly reference the exported columns, we recommend that you use BigQuery views to normalize the data so that the table presents the same schema to your queries. Learn more about this limitation .
  • When selecting or creating a BigQuery dataset for your detailed usage cost data , you can select any dataset location that is supported for use with Cloud Billing data .
  • When you enable the detailed usage cost data export for the first time in Cloud Billing, if you select a dataset configured to use a multi-region location (EU or US), Cloud Billing data will be available retroactively from the start of the previous month. Data is exported in chronological order. For the initial backfill of exported data, it might take up to five days for your retroactive Cloud Billing data to finish exporting before you start seeing your most recent usage data.
  • If you enable the detailed usage cost data export and select a dataset that's configured to use a supported region location , your Cloud Billing data will be available starting from the date when you enabled the export.
  • If you enabled, disabled, and subsequently re-enabled the detailed usage cost data export, the Cloud Billing data might not be available for the period when data export was explicitly disabled.
  • Learn more about the frequency of the data loads into your BigQuery tables .
  • See other limitations that might impact exporting your billing data to BigQuery, such as datasets with customer-managed encryption keys (CMEK) enabled.
  • Consider the additional data volume that your BigQuery tables might need and the additional cost when enabling detailed usage cost data instead of the standard usage cost data export. The increased granularity of resource-level information can increase the number of rows, which are aggregated in the standard usage cost format. We recommend that you review Control costs in BigQuery for further best practices in managing your BigQuery costs.
subscription.instance_id String

The subscription ID linked to a commitment.

Understand standard and detailed usage cost data

The following sections describe the standard and detailed usage cost data exported to BigQuery.

About labels

The cost data for a specific label only shows usage from the date that the label was applied to a resource. For example, if you add the label environment:dev to a Compute Engine VM on January 15, 2024, any analysis for environment:dev includes only the usage for that VM since January 15.

You might also see label data at different times for different services, depending on when each service provides it.

Available system labels

System labels are key-value pairs for important metadata about the resource that generated the usage. The following system labels are automatically included on applicable usage.

storage.googleapis.com/object_state live; noncurrent ; soft_deleted ; multipart The state of the storage object being charged.

Differences between exported data and invoices

Google Cloud products report usage and cost data to Cloud Billing processes at varying intervals. As a result, you might see a delay between your use of Google Cloud services, and the usage and costs being available to view in Cloud Billing. Typically, your costs are available within a day, but can sometimes take more than 24 hours.

At the end of a calendar month, late-reported usage might not be included on that month's invoice and instead might roll over to the next month's invoice.

When you query your costs using timestamp fields, your returned data might pick up late-reported usage that wasn't originally included on the invoice that was generated for the same usage month. As a result, the Cloud Billing data returned might not map directly to that invoice.

Timestamp fields include:

  • usage_start_time
  • usage_end_time
  • export_time

To return Cloud Billing data that maps directly to an invoice, query on invoice.month instead of timestamp fields.

Taxes

As of September 1, 2020, your usage cost data shows your tax liability for each of your projects, instead of as a single line item. If you have queries or visualizations that depend on tax data, you might need to update the queries to account for these changes.

For example, for costs recorded before September 1, your usage cost data looks similar to the following example, which shows a total tax liability of $10.

billing_account_id project.id cost_type cost
123456-ABCDEF-123456
example-project Regular $60
123456-ABCDEF-123456
test-project Regular $40
123456-ABCDEF-123456
[empty] Tax $10

For costs recorded after September 1, the $10 is broken down to $6 for example-project , and $4 for test-project :

billing_account_id project.id cost_type cost
123456-ABCDEF-123456
example-project Regular $60
123456-ABCDEF-123456
test-project Regular $40
123456-ABCDEF-123456
example-project Tax $6
123456-ABCDEF-123456
test-project Tax $4

Errors and adjustments

In the rare event that your Cloud Billing data contains an error or requires an adjustment, it's appended with corrective data. These adjustments fall under one of two categories: billing modifications or corrections.

Billing modifications

Billing modifications appear as separate line items. If you received a billing modification, a new line item in your Cloud Billing export to BigQuery shows the change. The adjustments shown correspond to the invoice, credit memo, and debit memo documents available in the Documentsarea of the Billingsection in the Google Cloud console.

For more information on billing modifications and how they're applied, see Understand memos and adjustments .

Corrections

Corrections appear as new data that negates incorrect data on the source SKUs. In some cases, new data replaces the incorrect charge. All columns in the billing data export will match the original data, except for the following columns:

  • cost
  • credit
  • usage.amount
  • export_time

For example, imagine that you're charged $10 for your usage of SKU A on January 1. On your January invoice (issued in early February), you'll see a charge of $10 for SKU A . However, on February 2, Google Cloud issued a correction against SKU A , reducing the usage cost to $5. You'll receive two additional line items on your February invoice (issued in early March):

  • -$10 for usage on January 1 (negating the original charge)
  • $5 for usage on January 1 (stating the intended charge)

These new items have an adjustment_info column in the billing data export. The original January invoice, showing the overcharge, won't be adjusted. You can verify your charges in your billing data export by viewing your costs by usage_start_time and grouping by Day . In these views, any corrections or charges for late-monetized usage are accumulated, and you don't need to worry about any temporarily incorrect data.

If you want more detailed information on your corrections, view all charges in an invoice month , and look for charges where the usage date occurred before the invoice month. These charges are the results of corrections or late-monetized usage.

The following code sample shows how to create a basic query that returns the total cost of corrections or late-monetized usage:

  SELECT 
  
 SUM 
 ( 
 cost 
 ) 
  
 + 
  
 SUM 
 ( 
 IFNULL 
 (( 
 SELECT 
  
 SUM 
 ( 
 c 
 . 
 amount 
 ) 
  
 FROM 
  
 UNNEST 
 ( 
 credits 
 ) 
  
 c 
 ), 
  
 0 
 )) 
  
 AS 
  
 total 
 FROM 
  
 ` 
 project 
 . 
 dataset 
 . 
 gcp_billing_export_v1_XXXXXX 
 - 
 XXXXXX 
 - 
 XXXXXX 
 ` 
 WHERE 
  
 invoice 
 . 
 month 
  
 = 
  
 '202311' 
  
 AND 
  
 DATE 
 ( 
 TIMESTAMP_TRUNC 
 ( 
 usage_start_time 
 , 
  
 Day 
 , 
  
 'US/Pacific' 
 )) 
 < 
 '2023-11-01' 
 ; 
 

For a query example that returns a cost breakdown by service , for invoice charges, where the usage date occurred before the invoice month , see Query cost details to view corrections or late-monetized usage by service for a specified invoice month in "Example queries for Cloud Billing data export."

About promotional credits in custom pricing contracts

If you have a custom pricing contract, you might receive promotional credits to use on Google Cloud as part of the contract. For example, you might receive $1,000 to use on Compute Engine resources. Promotional credits are typically considered a form of payment. When available, promotional credits are automatically applied to reduce your total bill.

The terms of your contract specify whether the promotional credits apply to your costs calculated at the list price of a SKU, or the net price (after discounts).

If your promotional credits apply to costs that are calculated at the list price , in the Cost tablereport, there's a service called Invoice , with a SKU called Contract billing adjustment . This SKU adjusts your credits so that they apply to the costs at list price. To see the usage that the adjustment is for, query the system.labels columns. The key in system.labels.key is cloud-invoice.googleapis.com/sku_id , and the value in system.labels.value contains the SKU ID that the credit and the adjustment applied to.

About tags

Tags are resources in the form of key-value pairs that can be attached to resources directly or through inheritance. You can use tags to perform chargebacks, audits, and other cost allocation analysis. You can also use tags and conditional enforcement of policies for fine-grained control across your resource hierarchy.

Tags have a robust permissions model and can support inheritance, centralized management, nomenclature standardization, and policy engine integration, while labels are a separate tool that allow you to annotate resources.

Tags data appears in BigQuery exports for Resources, Projects, Folders, and Organizations.

Available tags

The Standard costs and Detailed costs exports for Resources, Projects, Folders, and Organizations include these fields for tags data: Tags Key, Tags Value, Tags Inherited, and Tags Namespace.

Resource-level tags in the Cloud Billing data export are available for the following resources:

  • AlloyDB for PostgreSQL clusters, instances, and backups
  • Artifact Registry repositories
  • Bigtable instances
  • Cloud Run services and jobs
  • Cloud Storage buckets
  • Compute Engine instances
  • Memorystore for Redis instances
  • Secret Manager global and regional secrets
  • Spanner instances
  • Firestore databases

Tags limitations

  • Tags might take up to an hour to propagate to BigQuery exports. If a tag has been added or removed within an hour, or if a resource has existed for less than an hour, it might not appear in the export.

Detailed usage cost query examples

This section provides examples of how to query the Cloud Billing detailed usage cost data exported to BigQuery.

Because the detailed usage cost schema includes all of the fields from the standard usage cost schema, the query examples provided for the standard data exported to BigQuery also work with the detailed data that's exported. The standard query examples aren't written to retrieve any of the resource-level information that's provided with the detailed usage cost export option. When creating queries for the detailed data, you can use a standard query example as a template, update the Table name, and add any of the fields that are available in the detailed usage cost schema .

Common values used in the example detailed cost queries

The query examples in this section use the following value for Table name: project.dataset.gcp_billing_export_resource_v1_XXXXXX_XXXXXX_XXXXXX

Return the resource-level costs on an invoice

The following queries demonstrate two ways of viewing resource-level cost and credit values on an invoice using exported billing data.

  • The total field directly sums the floating point cost and credit values, which can result in floating point rounding errors.
  • The total_exact field converts costs and credit values to micros before summing, then converts back to dollars after summing, avoiding the floating point rounding error.

Sum costs for each resource, per invoice

This query shows the invoice total for each resource.name per month, as a sum of regular costs, taxes, adjustments, and rounding errors. Any costs not associated with a resource-level item are aggregated under the name null for the month.

Standard SQL

 SELECT 
  
 invoice 
 . 
 month 
 , 
  
 resource 
 . 
 name 
 , 
  
 SUM 
 ( 
 cost 
 ) 
  
 + 
  
 SUM 
 ( 
 IFNULL 
 (( 
 SELECT 
  
 SUM 
 ( 
 c 
 . 
 amount 
 ) 
  
 FROM 
  
 UNNEST 
 ( 
 credits 
 ) 
  
 c 
 ), 
  
 0 
 )) 
  
 AS 
  
 total 
 , 
  
 ( 
 SUM 
 ( 
 CAST 
 ( 
 cost 
  
 * 
  
 1000000 
  
 AS 
  
 int64 
 )) 
  
 + 
  
 SUM 
 ( 
 IFNULL 
 (( 
 SELECT 
  
 SUM 
 ( 
 CAST 
 ( 
 c 
 . 
 amount 
  
 * 
  
 1000000 
  
 as 
  
 int64 
 )) 
  
 FROM 
  
 UNNEST 
 ( 
 credits 
 ) 
  
 c 
 ), 
  
 0 
 ))) 
  
 / 
  
 1000000 
  
 AS 
  
 total_exact 
 FROM 
  
 ` 
 project 
 . 
 dataset 
 . 
 gcp_billing_export_resource_v1_XXXXXX_XXXXXX_XXXXXX 
 ` 
 GROUP 
  
 BY 
  
 1 
 , 
  
 2 
 ORDER 
  
 BY 
  
 1 
  
 ASC 
 , 
  
 2 
  
 ASC 
 ; 

For example, the result of the preceding query might be:

Row month name total total_exact
1
201901 null $1005.004832999999984 $1005.00
2
201901 backend1 $781.8499760000028 $781.85
3
201902 null $953.0034923645475983 $953.03
4
201902 backend1 $992.3101739999999717 $992.31
5
201902 bitnami-launchpad-wordpress-1-wordpress $1.2817819999999998 $1.28

Return details by cost type for each resource, per invoice month

This query shows the totals for each cost_type for each resource.name per month. Cost types include regular costs, taxes, adjustments, and rounding errors. Any costs not associated with a resource-level item are aggregated under the name null for the month.

Standard SQL

 SELECT 
  
 invoice 
 . 
 month 
 , 
  
 cost_type 
 , 
  
 resource 
 . 
 name 
 , 
  
 SUM 
 ( 
 cost 
 ) 
  
 + 
  
 SUM 
 ( 
 IFNULL 
 (( 
 SELECT 
  
 SUM 
 ( 
 c 
 . 
 amount 
 ) 
  
 FROM 
  
 UNNEST 
 ( 
 credits 
 ) 
  
 c 
 ), 
  
 0 
 )) 
  
 AS 
  
 total 
 , 
  
 ( 
 SUM 
 ( 
 CAST 
 ( 
 cost 
  
 * 
  
 1000000 
  
 AS 
  
 int64 
 )) 
  
 + 
  
 SUM 
 ( 
 IFNULL 
 (( 
 SELECT 
  
 SUM 
 ( 
 CAST 
 ( 
 c 
 . 
 amount 
  
 * 
  
 1000000 
  
 as 
  
 int64 
 )) 
  
 FROM 
  
 UNNEST 
 ( 
 credits 
 ) 
  
 c 
 ), 
  
 0 
 ))) 
  
 / 
  
 1000000 
  
 AS 
  
 total_exact 
 FROM 
  
 ` 
 project 
 . 
 dataset 
 . 
 gcp_billing_export_resource_v1_XXXXXX_XXXXXX_XXXXXX 
 ` 
 GROUP 
  
 BY 
  
 1 
 , 
  
 2 
 , 
  
 3 
 ORDER 
  
 BY 
  
 1 
  
 ASC 
 , 
  
 2 
  
 ASC 
 , 
  
 3 
  
 ASC 
 ; 

For example, the result of the preceding query might be:

Row month cost_type name total total_exact
1
201901 regular null $1000.501209987994782 $1000.50
2
201901 rounding_error null –$0.500489920049387 –$0.50
3
201901 tax null $10.000329958477891 $10.00
4
201901 adjustment null –$5.002572999387045 –$5.00
5
201901 regular backend1 $410.998795012082947 $411.00
2
201901 rounding_error backend1 –$0.2404900489920378 –$0.24
3
201901 tax backend1 $4.105840329977189 $4.11

Get a breakdown of Google Kubernetes Engine (GKE) cluster costs

This section provides examples of filtering GKE cluster costs in your BigQuery export reports. To learn more about GKE cluster costs, visit View breakdown of cluster costs .

Filter GKE costs

The following example queries show you how to filter and group your GKE costs for supported resource types by cluster name, namespace, and label.

GKE cluster costs before credits

 SELECT 
  
 SUM 
 ( 
 cost 
 ) 
  
 AS 
  
 cost_before_credits 
 , 
  
 labels 
 . 
 value 
  
 AS 
  
 cluster_name 
 FROM 
  
 ` 
 project 
 - 
 ID 
 . 
 dataset 
 . 
 gcp_billing_export_resource_v1_XXXXXX 
 - 
 XXXXXX 
 - 
 XXXXXX 
 ` 
 LEFT 
  
 JOIN 
  
 UNNEST 
 ( 
 labels 
 ) 
  
 as 
  
 labels 
  
 ON 
  
 labels 
 . 
 key 
  
 = 
  
 "goog-k8s-cluster-name" 
 GROUP 
  
 BY 
  
 labels 
 . 
 value 
 ; 

GKE costs after credits by namespace

 SELECT 
  
 labels 
 . 
 value 
  
 as 
  
 namespace 
 , 
  
 SUM 
 ( 
 cost 
 ) 
  
 + 
  
 SUM 
 ( 
 IFNULL 
 (( 
 SELECT 
  
 SUM 
 ( 
 c 
 . 
 amount 
 ) 
  
 FROM 
  
 UNNEST 
 ( 
 credits 
 ) 
  
 c 
 ), 
  
 0 
 )) 
  
 AS 
  
 cost_after_credits 
 , 
 FROM 
  
 ` 
 project 
 - 
 ID 
 . 
 dataset 
 . 
 gcp_billing_export_resource_v1_XXXXXX 
 - 
 XXXXXX 
 - 
 XXXXXX 
 ` 
 LEFT 
  
 JOIN 
  
 UNNEST 
 ( 
 labels 
 ) 
  
 as 
  
 labels 
  
 ON 
  
 labels 
 . 
 key 
  
 = 
  
 "k8s-namespace" 
 GROUP 
  
 BY 
  
 namespace 
 ; 

GKE costs by SKU

 SELECT 
  
 project 
 . 
 id 
  
 AS 
  
 project_id 
 , 
  
 labels 
 . 
 value 
  
 AS 
  
 cluster_name 
 , 
  
 sku 
 . 
 id 
  
 AS 
  
 sku_id 
 , 
  
 sku 
 . 
 description 
  
 AS 
  
 sku_description 
 , 
  
 SUM 
 ( 
 cost 
 ) 
  
 AS 
  
 cost 
 FROM 
  
 ` 
 project 
 - 
 ID 
 . 
 dataset 
 . 
 gcp_billing_export_resource_v1_XXXXXX 
 - 
 XXXXXX 
 - 
 XXXXXX 
 ` 
 JOIN 
  
 UNNEST 
 ( 
 labels 
 ) 
  
 AS 
  
 labels 
  
 ON 
  
 labels 
 . 
 key 
  
 = 
  
 "goog-k8s-cluster-name" 
 GROUP 
  
 BY 
  
 cluster_name 
 , 
  
 project_id 
 , 
  
 sku_description 
 , 
  
 sku_id 
 ; 

Query examples with tags

The following examples illustrate ways to query your data with tags.

Calculate costs by invoice month with tags

The following query demonstrates how you can use return costs by invoice month for the cost_center tag.

 SELECT 
  
 invoice 
 . 
 month 
  
 AS 
  
 invoice_month 
 , 
  
 tag 
 . 
 value 
  
 AS 
  
 cost_center 
 , 
  
 ROUND 
 (( 
 SUM 
 ( 
 CAST 
 ( 
 cost 
  
 AS 
  
 NUMERIC 
 )) 
  
 + 
  
 SUM 
 ( 
 IFNULL 
 (( 
 SELECT 
  
 SUM 
  
 ( 
 CAST 
 ( 
 c 
 . 
 amount 
  
 AS 
  
 NUMERIC 
 )) 
  
 FROM 
  
 UNNEST 
 ( 
 credits 
 ) 
  
 AS 
  
 c 
 ), 
  
 0 
 ))), 
  
 2 
 ) 
  
 AS 
  
 net_cost 
 FROM 
  
 ` 
 project 
 - 
 ID 
 . 
 dataset 
 . 
 gcp_billing_export_resource_v1_XXXXXX 
 - 
 XXXXXX 
 - 
 XXXXXX 
 ` 
 , 
  
 UNNEST 
 ( 
 tags 
 ) 
  
 AS 
  
 tag 
 WHERE 
  
 tag 
 . 
 key 
  
 = 
  
 "cost_center" 
  
 AND 
  
 tag 
 . 
 namespace 
  
 = 
  
 "821092389413" 
 GROUP 
  
 BY 
  
 invoice 
 . 
 month 
 , 
  
 tag 
 . 
 value 
 ORDER 
  
 BY 
  
 invoice 
 . 
 month 
 , 
  
 tag 
 . 
 value 
 ; 

For example, the result of the preceding query might be:

Row invoice_month cost_center net_cost
1
202208 android_mobile_apps 9.93
2
202208 ios_mobile_apps 9.93
3
202209 android_mobile_apps 25.42
4
202209 ios_mobile_apps 25.4
5
202209 personalization 16.08

View costs of untagged resources

This query shows the invoice total for untagged resources, grouped by invoice month.

 SELECT 
  
 invoice 
 . 
 month 
  
 AS 
  
 invoice_month 
 , 
  
 ROUND 
 (( 
 SUM 
 ( 
 CAST 
 ( 
 cost 
  
 AS 
  
 NUMERIC 
 )) 
  
 + 
  
 SUM 
 ( 
 IFNULL 
 (( 
 SELECT 
  
 SUM 
 ( 
 CAST 
 ( 
 c 
 . 
 amount 
  
 AS 
  
 NUMERIC 
 )) 
  
 FROM 
  
 UNNEST 
 ( 
 credits 
 ) 
  
 AS 
  
 c 
 ), 
  
 0 
 ))), 
  
 2 
 ) 
  
 AS 
  
 net_cost 
 FROM 
  
 ` 
 project 
 - 
 ID 
 . 
 dataset 
 . 
 gcp_billing_export_v1_XXXXXX 
 - 
 XXXXXX 
 - 
 XXXXXX 
 ` 
 WHERE 
  
 "color" 
  
 NOT 
  
 IN 
  
 ( 
 SELECT 
  
 key 
  
 FROM 
  
 UNNEST 
 ( 
 tags 
 )) 
 GROUP 
  
 BY 
  
 invoice_month 
 ORDER 
  
 BY 
  
 invoice_month 
 ; 

For example, the result of the preceding query might be:

Row invoice_month net_cost
1
202202 0
2
202203 16.81
3
202204 54.09
4
202205 55.82
5
202206 54.09
6
202207 55.83
7
202208 31.49

Query using system labels

System labels for Google Cloud reservations provide enhanced visibility into your reservation usage. They allow you to track which instances are consuming which reservations, and analyze the costs associated with both used and unused capacity directly within BigQuery.

These examples use two system labels:

  • compute.googleapis.com/reservation_name
  • compute.googleapis.com/reservation_project_id

These labels are present on Cloud Billing records from both instances consuming a reservation and the unused portion of a reservation.

The following examples demonstrate how to query the BigQuery billing export to analyze reservation consumption using system labels.

Before you begin

To query using system labels, you must have Cloud Billing export to BigQuery enabled, specifically the Detailed usage cost dataexport. This export contains the resource-level information, including system labels, necessary to see the new reservation labels.

To set up or verify your BigQuery export, see the following documentation:

  1. Overview of billing data export to BigQuery
  2. Set up billing data export to BigQuery
  3. Understand the Detailed data export schema

Ensure your BigQuery dataset is configured to receive the detailed export. The table name will typically be in the format gcp_billing_export_resource_v1_<BILLING_ACCOUNT_ID> .

View consumption for a given instance

This query lets you check if a given instance utilized a reservation during a particular period and, if so, which reservation it was.

  SELECT 
  
 t 
 . 
 usage_start_time 
 , 
  
 sl_reservation 
 . 
 value 
  
 AS 
  
 reservation_name 
 , 
  
 t 
 . 
 sku 
 . 
 description 
  
 AS 
  
 sku_description 
 , 
  
 SUM 
 ( 
 t 
 . 
 usage 
 . 
 amount 
 ) 
  
 AS 
  
 total_usage_amount 
 FROM 
  
  project 
 - 
 ID 
 . 
 dataset 
 . 
 gcp_billing_export_resource_v1_X 
 
  
 AS 
  
 t 
  
 LEFT 
  
 JOIN 
  
 UNNEST 
 ( 
 t 
 . 
 system_labels 
 ) 
  
 AS 
  
 sl_reservation 
  
 ON 
  
 sl_reservation 
 . 
 key 
  
 = 
  
 'compute.googleapis.com/reservation_name' 
 WHERE 
  
 t 
 . 
 service 
 . 
 id 
  
 = 
  
 '6F81-5844-456A' 
  
 AND 
  
 DATE 
 ( 
 TIMESTAMP_TRUNC 
 ( 
 t 
 . 
 _PARTITIONTIME 
 , 
  
 DAY 
 )) 
  
 = 
  
 '2025-09-16' 
  
 AND 
  
 t 
 . 
 sku 
 . 
 description 
  
 LIKE 
  
 '%Core%' 
  
 AND 
  
 t 
 . 
 resource 
 . 
 name 
  
 LIKE 
  
 '%tc-billing-case1-instance-1757983787%' 
 GROUP 
  
 BY 
  
 t 
 . 
 usage_start_time 
 , 
  
 reservation_name 
 , 
  
 t 
 . 
 sku 
 . 
 description 
 ORDER 
  
 BY 
  
 t 
 . 
 usage_start_time 
 , 
  
 reservation_name 
 , 
  
 t 
 . 
 sku 
 . 
 description 
 ; 
 

Sample Result:

usage_start_time reservation_name sku_description total_usage_amount
2025-09-16 00:00:00.000000 UTC
E2 Instance Core running in Americas 597
2025-09-16 01:00:00.000000 UTC
E2 Instance Core running in Americas 3009
2025-09-16 01:00:00.000000 UTC
tc-billing-case1-res0-1757983787 E2 Instance Core running in Americas 591
2025-09-16 02:00:00.000000 UTC
E2 Instance Core running in Americas 10
2025-09-16 02:00:00.000000 UTC
tc-billing-case1-res0-1757983787 E2 Instance Core running in Americas 3054
2025-09-16 02:00:00.000000 UTC
tc-billing-case1-res1-1757983787 E2 Instance Core running in Americas 37

Note:

  • SKU Filtering: Limiting the SKU to CPU cores offers clearer resource distribution. This can be adjusted to other reserved resources, such as RAM, LocalSSD, TPU, or GPU.
  • On-Demand Consumption: When both reservation_name and reservation_project_id are null, the instance is consuming on-demand resources.

When multiple rows with differing reservation_name and reservation_project_id correspond to a specific instance within a given timeframe, it indicates that the instance's consumed reservation changed during that period. The usage portion will detail the consumption.

Analyze usage distribution for a given reservation

This query helps you understand the distribution of usage for a given shared reservation, showing how much capacity was used or unused among different Google Cloud projects that can consume the given reservation.

  SELECT 
  
 t 
 . 
 project 
 . 
 id 
  
 AS 
  
 consumer_project_id 
 , 
  
 t 
 . 
 sku 
 . 
 description 
  
 AS 
  
 sku_description 
 , 
  
 CASE 
  
 WHEN 
  
 t 
 . 
 resource 
 . 
 global_name 
  
 NOT 
  
 LIKE 
  
 '%instances/%' 
  
 THEN 
  
 'Unused Capacity' 
  
 WHEN 
  
 t 
 . 
 resource 
 . 
 name 
  
 IS 
  
 NOT 
  
 NULL 
  
 AND 
  
 t 
 . 
 resource 
 . 
 name 
  
 != 
  
 '' 
  
 THEN 
  
 'Instance Usage' 
  
 ELSE 
  
 'Other Reservation Cost' 
  
 END 
  
 AS 
  
 usage_category 
 , 
  
 SUM 
 ( 
 t 
 . 
 usage 
 . 
 amount 
 ) 
  
 AS 
  
 total_usage_amount 
 , 
  
 t 
 . 
 usage 
 . 
 unit 
  
 AS 
  
 usage_unit 
 , 
  
 SUM 
 ( 
 t 
 . 
 cost 
 ) 
  
 AS 
  
 total_cost_usd 
 FROM 
  
  project 
 - 
 ID 
 . 
 dataset 
 . 
 gcp_billing_export_resource_v1_X 
 
  
 AS 
  
 t 
  
 LEFT 
  
 JOIN 
  
 UNNEST 
 ( 
 t 
 . 
 system_labels 
 ) 
  
 AS 
  
 sl_reservation 
  
 ON 
  
 sl_reservation 
 . 
 key 
  
 = 
  
 'compute.googleapis.com/reservation_name' 
  
 LEFT 
  
 JOIN 
  
 UNNEST 
 ( 
 t 
 . 
 system_labels 
 ) 
  
 AS 
  
 sl_project_id 
  
 ON 
  
 sl_project_id 
 . 
 key 
  
 = 
  
 'compute.googleapis.com/reservation_project_id' 
 WHERE 
  
 t 
 . 
 service 
 . 
 id 
  
 = 
  
 '6F81-5844-456A' 
  
 AND 
  
 DATE 
 ( 
 TIMESTAMP_TRUNC 
 ( 
 t 
 . 
 _PARTITIONTIME 
 , 
  
 DAY 
 )) 
  
 = 
  
 '2025-09-16' 
  
 AND 
  
 t 
 . 
 sku 
 . 
 description 
  
 LIKE 
  
 '%Core%' 
  
 AND 
  
 sl_reservation 
 . 
 value 
  
 LIKE 
  
 '%tc-billing-case2-res-1757983801%' 
 GROUP 
  
 BY 
  
 consumer_project_id 
 , 
  
 t 
 . 
 sku 
 . 
 description 
 , 
  
 usage_category 
 , 
  
 usage_unit 
 ORDER 
  
 BY 
  
 consumer_project_id 
 , 
  
 usage_category 
 ; 
 

Sample Results:

consumer_project_id sku_description usage_category total_usage_amount usage_unit total_cost_usd
disco-sector-292704
E2 Instance Core running in Americas Instance Usage 14551 seconds 0.088158
flash-freehold-292704
E2 Instance Core running in Americas Instance Usage 7347 seconds 0.044512
united-sandbox-303721
E2 Instance Core running in Americas Unused Capacity 7936 seconds 0.04808

List all the instances consuming a reservation

Similarly, we can write a query to understand all the instances that have consumed a given reservation during a given time period.

  SELECT 
  
 t 
 . 
 usage_start_time 
 , 
  
 t 
 . 
 usage_end_time 
 , 
  
 t 
 . 
 project 
 . 
 id 
  
 AS 
  
 consumer_project_id 
 , 
  
 t 
 . 
 resource 
 . 
 name 
  
 AS 
  
 instance_name 
 , 
  
 t 
 . 
 usage 
 . 
 amount 
  
 AS 
  
 usage_amount 
 FROM 
  
  project 
 - 
 ID 
 . 
 dataset 
 . 
 gcp_billing_export_resource_v1_X 
 
  
 AS 
  
 t 
  
 LEFT 
  
 JOIN 
  
 UNNEST 
 ( 
 t 
 . 
 system_labels 
 ) 
  
 AS 
  
 sl_reservation 
  
 ON 
  
 sl_reservation 
 . 
 key 
  
 = 
  
 'compute.googleapis.com/reservation_name' 
 WHERE 
  
 t 
 . 
 service 
 . 
 id 
  
 = 
  
 '6F81-5844-456A' 
  
 AND 
  
 DATE 
 ( 
 TIMESTAMP_TRUNC 
 ( 
 t 
 . 
 _PARTITIONTIME 
 , 
  
 DAY 
 )) 
  
 = 
  
 '2025-09-16' 
  
 AND 
  
 t 
 . 
 sku 
 . 
 description 
  
 LIKE 
  
 '%Core%' 
  
 AND 
  
 sl_reservation 
 . 
 value 
  
 LIKE 
  
 '%tc-billing-case2-res-1757983801%' 
  
 AND 
  
 t 
 . 
 resource 
 . 
 global_name 
  
 NOT 
  
 LIKE 
  
 '%allocation/%' 
  
 AND 
  
 t 
 . 
 resource 
 . 
 name 
  
 IS 
  
 NOT 
  
 NULL 
  
 AND 
  
 t 
 . 
 resource 
 . 
 name 
  
 != 
  
 '' 
 ORDER 
  
 BY 
  
 t 
 . 
 usage_start_time 
 , 
  
 t 
 . 
 project 
 . 
 id 
 , 
  
 t 
 . 
 resource 
 . 
 name 
 ; 
 

Sample Results:

usage_start_time usage_end_time consumer_project_id instance_name usage_amount
2025-09-16 00:00:00.000000 UTC
2025-09-16 01:00:00.000000 UTC disco-sector-292704 projects/204187533293/instances/tc-billing-case2-ins0-1757983801 552
2025-09-16 00:00:00.000000 UTC
2025-09-16 01:00:00.000000 UTC disco-sector-292704 projects/204187533293/instances/tc-billing-case2-ins1-1757983801 533
2025-09-16 00:00:00.000000 UTC
2025-09-16 01:00:00.000000 UTC flash-freehold-292704 projects/978655420110/instances/tc-billing-case2-ins2-1757983801 517
2025-09-16 01:00:00.000000 UTC
2025-09-16 02:00:00.000000 UTC disco-sector-292704 projects/204187533293/instances/tc-billing-case2-ins0-1757983801 3600
2025-09-16 01:00:00.000000 UTC
2025-09-16 02:00:00.000000 UTC disco-sector-292704 projects/204187533293/instances/tc-billing-case2-ins1-1757983801 3600
2025-09-16 01:00:00.000000 UTC
2025-09-16 02:00:00.000000 UTC flash-freehold-292704 projects/978655420110/instances/tc-billing-case2-ins2-1757983801 3600
2025-09-16 02:00:00.000000 UTC
2025-09-16 03:00:00.000000 UTC disco-sector-292704 projects/204187533293/instances/tc-billing-case2-ins0-1757983801 3022
2025-09-16 02:00:00.000000 UTC
2025-09-16 03:00:00.000000 UTC disco-sector-292704 projects/204187533293/instances/tc-billing-case2-ins0-1757983801 79
2025-09-16 02:00:00.000000 UTC
2025-09-16 03:00:00.000000 UTC disco-sector-292704 projects/204187533293/instances/tc-billing-case2-ins1-1757983801 79
2025-09-16 02:00:00.000000 UTC
2025-09-16 03:00:00.000000 UTC disco-sector-292704 projects/204187533293/instances/tc-billing-case2-ins1-1757983801 3086
2025-09-16 02:00:00.000000 UTC
2025-09-16 03:00:00.000000 UTC flash-freehold-292704 projects/978655420110/instances/tc-billing-case2-ins2-1757983801 3151
2025-09-16 02:00:00.000000 UTC
2025-09-16 03:00:00.000000 UTC flash-freehold-292704 projects/978655420110/instances/tc-billing-case2-ins2-1757983801 79

Cost and pricing reports available in the Google Cloud console

Create a Mobile Website
View Site in Mobile | Classic
Share by: