Skip to content

Instantly share code, notes, and snippets.

@bbelchak
Created June 6, 2017 11:11
Show Gist options
  • Save bbelchak/b453f5a96df08f0ecb40c1dbe6db90f8 to your computer and use it in GitHub Desktop.
Save bbelchak/b453f5a96df08f0ecb40c1dbe6db90f8 to your computer and use it in GitHub Desktop.
How to get the cost of your Internet Egress in GCP
SELECT labels.key, labels.value, project.name, resource_type, start_time, end_time, SUM(cost) as cost FROM FLATTEN((
SELECT
*
FROM (
FLATTEN((
SELECT
*
FROM
[YOUR_TABLE_HERE]),
labels.key)
)
),
project.labels.value)
WHERE resource_type LIKE "%Internet Egress%"
group by labels.key, labels.value, project.name, resource_type, start_time, end_time ORDER by start_time desc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment