Skip to content

Commit

Permalink
Populate data transfer amounts
Browse files Browse the repository at this point in the history
  • Loading branch information
samdoran committed May 14, 2024
1 parent c776e97 commit 9f63a4c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ INSERT INTO {{schema | sqlsafe}}.reporting_ocpusagelineitem_daily_summary (
infrastructure_project_raw_cost,
infrastructure_usage_cost,
supplementary_usage_cost,
infrastructure_data_in_gigabytes,
infrastructure_data_out_gigabytes,
pod_usage_cpu_core_hours,
pod_request_cpu_core_hours,
pod_limit_cpu_core_hours,
Expand Down Expand Up @@ -72,6 +74,14 @@ INSERT INTO {{schema | sqlsafe}}.reporting_ocpusagelineitem_daily_summary (
{% endif %}
'{"cpu": 0.000000000, "memory": 0.000000000, "storage": 0.000000000}'::jsonb as infrastructure_usage_cost,
'{"cpu": 0.000000000, "memory": 0.000000000, "storage": 0.000000000}'::jsonb as supplementary_usage_cost,
CASE
WHEN upper(data_transfer_direction) = 'IN' THEN sum(infrastructure_data_in_gigabytes)
ELSE 0
END as infrastructure_data_in_gigabytes,
CASE
WHEN upper(data_transfer_direction) = 'OUT' THEN sum(infrastructure_data_out_gigabytes)
ELSE 0
END as infrastructure_data_out_gigabytes,
0 as pod_usage_cpu_core_hours,
0 as pod_request_cpu_core_hours,
0 as pod_limit_cpu_core_hours,
Expand Down Expand Up @@ -107,5 +117,6 @@ INSERT INTO {{schema | sqlsafe}}.reporting_ocpusagelineitem_daily_summary (
ocp_aws.persistentvolumeclaim,
ocp_aws.resource_id,
ocp_aws.pod_labels,
ocp_aws.data_transfer_direction,
rp.provider_id
;
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,7 @@ INSERT INTO hive.{{schema | sqlsafe}}.reporting_ocpawscostlineitem_project_daily
product_family,
instance_type,
usage_account_id,
account_alias_id,
availability_zone,
region,
unit,
Expand Down Expand Up @@ -800,6 +801,7 @@ SELECT
max(product_family),
max(instance_type),
max(usage_account_id),
max(aa.id) AS account_alias_id,
max(availability_zone),
max(region),
max(unit),
Expand Down Expand Up @@ -829,6 +831,8 @@ FROM hive.{{schema | sqlsafe}}.reporting_ocpusagelineitem_daily_summary AS ocp
JOIN hive.{{schema | sqlsafe}}.aws_openshift_daily_resource_matched_temp AS aws
ON aws.usage_start = ocp.usage_start
AND position(ocp.resource_id IN aws.resource_id) != 0
LEFT JOIN postgres.{{schema | sqlsafe}}.reporting_awsaccountalias AS aa
ON aws.usage_account_id = aa.account_id
WHERE ocp.source = {{ocp_source_uuid}}
AND ocp.year = {{year}}
AND lpad(ocp.month, 2, '0') = {{month}} -- Zero pad the month when fewer than 2 characters
Expand Down Expand Up @@ -869,6 +873,8 @@ INSERT INTO postgres.{{schema | sqlsafe}}.reporting_ocpawscostlineitem_project_d
region,
unit,
usage_amount,
infrastructure_data_in_gigabytes,
infrastructure_data_out_gigabytes,
data_transfer_direction,
currency_code,
unblended_cost,
Expand Down Expand Up @@ -910,6 +916,14 @@ SELECT uuid(),
region,
unit,
usage_amount,
CASE
WHEN upper(data_transfer_direction) = 'IN' THEN usage_amount
ELSE 0
END AS infrastructure_data_in_gigabytes,
CASE
WHEN upper(data_transfer_direction) = 'OUT' THEN usage_amount
ELSE 0
END AS infrastructure_data_out_gigabytes,
data_transfer_direction,
currency_code,
unblended_cost,
Expand Down

0 comments on commit 9f63a4c

Please sign in to comment.