Created
June 15, 2025 09:27
-
-
Save sleroy/14536d232e2483db1e53caf694429842 to your computer and use it in GitHub Desktop.
Extract billing from BigQuery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
project.id as ID, | |
invoice.month as Month, | |
service.description as ServiceDescription, | |
service.id as ServiceID, | |
sku.description as SKUDescription, | |
sku.id as SKUID, | |
location.location as Region, | |
SUM(usage.amount_in_pricing_units) as UsageAmount, | |
usage.pricing_unit as UsageUnit, | |
SUM(cost) as ActualCost, #optional | |
FROM `<project>.<dataset>.gcp_billing_export_v1_<UUID>` # Replace project, table, and UUID. | |
WHERE invoice.month = "202304" # Modify this clause for the period of time. | |
AND cost_type = "regular" # This will filter out private pricing, credits, and discounts. | |
GROUP BY ID, | |
Month, | |
ServiceDescription, | |
ServiceID, | |
SKUDescription, | |
SKUID, | |
Region, | |
UsageUnit | |
ORDER BY ServiceID ASC, SKUID ASC | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment