Skip to content

Commit 044f8e8

Browse files
authored
collect schema level metrics (#139)
1 parent 11646a0 commit 044f8e8

6 files changed

+34
-28
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
select
2+
row_number() OVER () AS id, -- exclude schema to anonymize data
23
to_char(DATE_TRUNC('month', date), 'YYYY-MM') AS month,
34
SUM(aws_unblended_cost) AS "aws_unblended_cost",
45
SUM(aws_calculated_amortized_cost) AS "aws_calculated_amortized_cost",
@@ -7,6 +8,6 @@ select
78
SUM(gcp_total) AS "gcp_total",
89
SUM(oci_cost) AS "oci_cost"
910
from __cust_cloud_cost_report
10-
GROUP BY DATE_TRUNC('month', date)
11-
ORDER BY DATE_TRUNC('month', date)
11+
GROUP BY schema, DATE_TRUNC('month', date)
12+
ORDER BY schema, DATE_TRUNC('month', date)
1213
;

kokudaily/sql/key_metrics/cust_cloud_costs_data_setup.sql

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ DROP TABLE IF EXISTS __cust_cloud_cost_report;
22

33
-- create temp table for results
44
CREATE TEMPORARY TABLE IF NOT EXISTS __cust_cloud_cost_report (
5-
id serial,
5+
schema text,
66
date date,
77
aws_unblended_cost numeric(33, 2),
88
aws_calculated_amortized_cost numeric(33, 2),
@@ -18,6 +18,7 @@ DECLARE
1818
schema_rec record;
1919
stmt_tmpl text = '
2020
INSERT INTO __cust_cloud_cost_report (
21+
schema,
2122
date,
2223
aws_unblended_cost,
2324
aws_calculated_amortized_cost,
@@ -119,7 +120,7 @@ oci_costs AS (
119120
GROUP BY date
120121
)
121122
SELECT
122-
-- awc.customer AS "customer", -- customer is used for grouping, but left off report for anonymity
123+
awc.customer AS "schema",
123124
date AS "date",
124125
awc.aws_unblended_cost AS "aws_unblended_cost",
125126
awc.aws_calculated_amortized_cost AS "aws_calculated_amortized_cost",

kokudaily/sql/key_metrics/cust_openshift_costs_data.sql

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
select
2+
row_number() OVER () AS id, -- exclude schema to anonymize data
23
to_char(DATE_TRUNC('month', date), 'YYYY-MM') AS month,
34
SUM(total_infrastructure_raw_cost) AS "total_infrastructure_raw_cost",
45
SUM(total_cost_model_costs) AS "total_cost_model_costs",
@@ -11,6 +12,6 @@ select
1112
SUM(sup_cost_model_memory_cost) AS "sup_cost_model_memory_cost",
1213
SUM(sup_cost_model_volume_cost) AS "sup_cost_model_volume_cost"
1314
from __cust_openshift_cost_report
14-
GROUP BY DATE_TRUNC('month', date)
15-
ORDER BY DATE_TRUNC('month', date)
15+
GROUP BY schema, DATE_TRUNC('month', date)
16+
ORDER BY schema, DATE_TRUNC('month', date)
1617
;

kokudaily/sql/key_metrics/cust_openshift_costs_data_setup.sql

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ DROP TABLE IF EXISTS __cust_openshift_cost_report;
22

33
-- create temp table for results
44
CREATE TEMPORARY TABLE IF NOT EXISTS __cust_openshift_cost_report (
5-
id serial,
5+
schema text,
66
date date,
77
total_infrastructure_raw_cost numeric(33, 2),
88
total_cost_model_costs numeric(33, 2),
@@ -22,6 +22,7 @@ DECLARE
2222
schema_rec record;
2323
stmt_tmpl text = '
2424
INSERT INTO __cust_openshift_cost_report (
25+
schema,
2526
date,
2627
total_infrastructure_raw_cost,
2728
total_cost_model_costs,
@@ -121,7 +122,7 @@ sup_costs AS (
121122
GROUP BY date
122123
)
123124
SELECT
124-
-- ir.customer AS "customer", -- customer is used for grouping, but left off report for anonymity
125+
ir.customer AS "schema",
125126
date AS "date",
126127
COALESCE(ir.infrastructure_raw_cost, 0) AS "total_infrastructure_raw_cost",
127128
ic.infra_total_cost_model+sc.sup_total_cost_model AS "total_cost_model_costs",
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
SELECT
2+
row_number() OVER () AS id, -- exclude schema to anonymize data
23
to_char(DATE_TRUNC('month', date), 'YYYY-MM') AS month,
3-
SUM(cluster_count) AS total_cluster_count,
4-
SUM(node_count) AS total_node_count,
5-
SUM(infra_node_count) AS total_infra_node_count,
6-
SUM(control_plane_node_count) AS total_control_plane_node_count,
7-
SUM(worker_node_count) AS total_worker_node_count,
8-
SUM(infra_node_cpu_cores) AS total_infra_node_cpu_cores,
9-
SUM(control_plane_node_cpu_cores) AS total_control_plane_node_cpu_cores,
10-
SUM(worker_node_cpu_cores) AS total_worker_node_cpu_cores,
11-
SUM(infra_node_mem_gb) AS total_infra_node_mem_gb,
12-
SUM(control_plane_node_mem_gb) AS total_control_plane_node_mem_gb,
13-
SUM(worker_node_mem_gb) AS total_worker_node_mem_gb,
14-
SUM(pvc_count) AS total_pvc_count,
15-
SUM(cluster_capacity_cores) AS total_cluster_capacity_cores,
4+
MAX(cluster_count) AS total_cluster_count,
5+
MAX(node_count) AS total_node_count,
6+
MAX(infra_node_count) AS total_infra_node_count,
7+
MAX(control_plane_node_count) AS total_control_plane_node_count,
8+
MAX(worker_node_count) AS total_worker_node_count,
9+
MAX(infra_node_cpu_cores) AS total_infra_node_cpu_cores,
10+
MAX(control_plane_node_cpu_cores) AS total_control_plane_node_cpu_cores,
11+
MAX(worker_node_cpu_cores) AS total_worker_node_cpu_cores,
12+
MAX(infra_node_mem_gb) AS total_infra_node_mem_gb,
13+
MAX(control_plane_node_mem_gb) AS total_control_plane_node_mem_gb,
14+
MAX(worker_node_mem_gb) AS total_worker_node_mem_gb,
15+
MAX(pvc_count) AS total_pvc_count,
16+
MAX(cluster_capacity_cores) AS total_cluster_capacity_cores,
1617
SUM(cluster_capacity_core_hours) AS total_cluster_capacity_core_hours,
17-
SUM(cluster_capacity_memory_gb) AS total_cluster_capacity_memory_gb,
18+
MAX(cluster_capacity_memory_gb) AS total_cluster_capacity_memory_gb,
1819
SUM(cluster_capacity_memory_gb_hours) AS total_cluster_capacity_memory_gb_hours,
19-
SUM(volume_request_gb) AS total_volume_request_gb,
20+
MAX(volume_request_gb) AS total_volume_request_gb,
2021
SUM(volume_request_gb_mo) AS total_volume_request_gb_mo,
21-
SUM(pvc_capacity_gb) AS total_pvc_capacity_gb,
22+
MAX(pvc_capacity_gb) AS total_pvc_capacity_gb,
2223
SUM(pvc_capacity_gb_mo) AS total_pvc_capacity_gb_mo
2324
FROM __cust_openshift_infra_report
24-
GROUP BY DATE_TRUNC('month', date)
25-
ORDER BY DATE_TRUNC('month', date)
25+
GROUP BY schema, DATE_TRUNC('month', date)
26+
ORDER BY schema, DATE_TRUNC('month', date)
2627
;

kokudaily/sql/key_metrics/cust_openshift_infra_data_setup.sql

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ DROP TABLE IF EXISTS __cust_openshift_infra_report;
22

33
-- create temp table for results
44
CREATE TEMPORARY TABLE IF NOT EXISTS __cust_openshift_infra_report (
5-
id serial,
5+
schema text,
66
date date,
77
cluster_count integer,
88
node_count integer,
@@ -32,6 +32,7 @@ DECLARE
3232
schema_rec record;
3333
stmt_tmpl text = '
3434
INSERT INTO __cust_openshift_infra_report (
35+
schema,
3536
date,
3637
cluster_count,
3738
node_count,
@@ -161,7 +162,7 @@ storage_agg AS (
161162
GROUP BY date
162163
)
163164
SELECT
164-
-- customer is used for grouping, but left off report for anonymity
165+
customer AS "schema",
165166
date,
166167
cluster_count,
167168
node_count,

0 commit comments

Comments
 (0)