GCP: SQL to get the GCP cost from BigQuery table
search cancel

GCP: SQL to get the GCP cost from BigQuery table

book

Article ID: 426519

calendar_today

Updated On:

Products

CloudHealth

Issue/Introduction

To troubleshoot cost discrepancies between GCP and CloudHealth, please run the following BigQuery SQL to retrieve the raw billing data for comparison.

Resolution

You can use the below SQL to get the cost details from GCP BigQuery.


SELECT 
    billing_account_id,
    Invoice.month,
    SUM(cost) AS total_cost
FROM 
    Project_ID.Dataset.Table where cost_type in ('regular')
GROUP BY 
    billing_account_id,Invoice.month 
ORDER BY 
    Invoice.month