Once your billing data is exported to BigQuery, you can write SQL queries to analyze cloud spending by project, SKU, time range, and more. Hereβs how to run a sample cost breakdown query over the last 30 days.
π Step-by-Step Instructions
- Open the BigQuery Console.
- Select your billing dataset from the left-hand panel.
- Click Compose Query.
- Paste the sample query below into the editor.
- Click Run to execute the query.
π‘ Example Query
SELECT
project.name,
sku.description,
cost
FROM
`my_project.my_dataset.gcp_billing_export`
WHERE
usage_start_time >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 30 DAY)
ORDER BY
cost DESC
LIMIT 10;
Tip: Replace my_project.my_dataset.gcp_billing_export
with your actual project and dataset name.
β Expected Outcome
Youβll see a list of the top 10 SKUs with the highest costs in your project over the past 30 days, sorted by cost in descending order.
π οΈ Troubleshooting Tips
- Query fails? Double-check your dataset and table name formatting.
- No results? Ensure thereβs billing data within the past 30 days and that the export is working correctly.
π§ Related Articles or Next Steps
π Last Updated: April 2025