forked from GoogleCloudPlatform/professional-services
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgce_interval_view.sql
More file actions
31 lines (31 loc) · 810 Bytes
/
gce_interval_view.sql
File metadata and controls
31 lines (31 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
WITH
timestamp_interval_table AS (
SELECT
instance_id,
GENERATE_TIMESTAMP_ARRAY(TIMESTAMP_TRUNC(inserted, _TIME_INTERVAL_UNIT_),
TIMESTAMP_TRUNC(IFNULL(deleted,
CURRENT_TIMESTAMP()), _TIME_INTERVAL_UNIT_),
INTERVAL _TIME_INTERVAL_AMOUNT_ _TIME_INTERVAL_UNIT_) AS custom_interval_array
FROM
`_PROJECT_.gce_usage_log._gce_usage_log`)
SELECT
timestamp_interval_table.instance_id,
custom_interval,
preemptible,
project_id,
zone,
machine_type,
cores,
memory_mb,
pd_standard_size_gb,
pd_ssd_size_gb,
tags,
labels
FROM
timestamp_interval_table,
UNNEST(custom_interval_array) AS custom_interval
JOIN
`_PROJECT_.gce_usage_log._gce_usage_log` usage_view
ON
usage_view.instance_id = timestamp_interval_table.instance_id
ORDER BY custom_interval ASC