Skip to content

Commit

Permalink
[COST-4936] Add memory and operating system columns to aws trino table (
Browse files Browse the repository at this point in the history
#5071)

* [COST-4936] Add memory and operating system columns to aws trino table

* fix typo
  • Loading branch information
djnakabaale authored May 2, 2024
1 parent 5d8b4b4 commit e48395e
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 2 deletions.
5 changes: 5 additions & 0 deletions dev/scripts/nise_ymls/ocp_on_aws/aws_static_data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ generators:
resourceTags/user:dashed-key-on-aws: dashed-value
resourceTags/user:Mapping: a1
resourceTags/user:Map: a2
resourceTags/user:Name: instance-name-1
cost_category:
costCategory/env: prod
instance_type:
Expand Down Expand Up @@ -40,6 +41,7 @@ generators:
resourceTags/user:com_redhat_rhel_usage: disaster Recovery
resourceTags/user:Mapping: b1
resourceTags/user:Map: b2
resourceTags/user:Name: instance-name-2
cost_category:
costCategory/env: prod
instance_type:
Expand Down Expand Up @@ -67,6 +69,7 @@ generators:
resourceTags/user:CoM_RedHat_Rhel_varianT: Workstation
resourceTags/user:Mapping: c1
resourceTags/user:Map: c2
resourceTags/user:Name: instance_name_3
cost_category:
costCategory/env: stage
costCategory/Organization: Ninja
Expand Down Expand Up @@ -94,6 +97,7 @@ generators:
resourceTags/user:com_redhat_rhel_sla: self-support
resourceTags/user:CoM_RedHat_Rhel_varianT: hPC
resourceTags/user:com_redhat_rhel_usage: disaster Recovery
resourceTags/user:Name: instance name 4
cost_category:
costCategory/env: prod
instance_type:
Expand All @@ -120,6 +124,7 @@ generators:
resourceTags/user:com_redhat_rhel_sla: self-support
resourceTags/user:CoM_RedHat_Rhel_varianT: hPC
resourceTags/user:com_redhat_rhel_usage: disaster Recovery
resourceTags/user:Name: instance-name-5
cost_category:
costCategory/env: prod
instance_type:
Expand Down
6 changes: 6 additions & 0 deletions koku/masu/test/util/aws/test_aws_post_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ def test_aws_generate_daily_data(self):
"product_instancetype": "t2.micro",
"product_region": "us-east-1",
"product_vcpu": "8",
"product_memory": "8 GiB",
"product_operatingsystem": "Linux",
"pricing_unit": "hours",
"resourcetags": '{"key": "value"}',
"costcategory": '{"cat": "egory"}',
Expand Down Expand Up @@ -81,6 +83,8 @@ def test_aws_generate_daily_data(self):
"product_instancetype": "t2.micro",
"product_region": "us-east-1",
"product_vcpu": "4",
"product_memory": "8 GiB",
"product_operatingsystem": "Linux",
"pricing_unit": "hours",
"resourcetags": '{"key": "value"}',
"costcategory": '{"cat": "egory"}',
Expand Down Expand Up @@ -114,6 +118,8 @@ def test_aws_generate_daily_data(self):
"product_region": "us-east-1",
"pricing_unit": "hours",
"product_vcpu": "8",
"product_memory": "8 GiB",
"product_operatingsystem": "Linux",
"resourcetags": '{"key": "value"}',
"costcategory": '{"cat": "egory"}',
"lineitem_usageamount": lineitem_usageamount,
Expand Down
5 changes: 4 additions & 1 deletion koku/masu/util/aws/aws_post_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class AWSPostProcessor:
"reservation_end_time": "reservation/EndTime",
"product_physical_cores": "product/physicalCores",
"identity_time_interval": "identity/TimeInterval",
"product_operating_system": "product/operatingSystem",
}

CSV_COLUMN_PREFIX = (
Expand Down Expand Up @@ -206,6 +207,7 @@ def _generate_daily_data(self, data_frame):
"lineitem_availabilityzone",
"lineitem_lineitemtype",
"product_productfamily",
"product_operatingsystem",
"product_instancetype",
"product_region",
"pricing_unit",
Expand All @@ -226,9 +228,10 @@ def _generate_daily_data(self, data_frame):
"pricing_publicondemandcost": ["sum"],
"pricing_publicondemandrate": ["max"],
"savingsplan_savingsplaneffectivecost": ["sum"],
"product_productname": ["max"],
"bill_invoiceid": ["max"],
"product_productname": ["max"],
"product_vcpu": ["max"],
"product_memory": ["max"],
}
)
columns = daily_data_frame.columns.droplevel(1)
Expand Down
2 changes: 2 additions & 0 deletions koku/masu/util/aws/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,15 @@
"product/instanceType",
"product/vcpu",
"product/memory",
"product/operatingSystem",
}

OPTIONAL_ALT_COLS = {
"product_physical_cores",
"product_instancetype",
"product_vcpu",
"product_memory",
"product_operating_system",
}

DATE_FMT = "%Y-%m-%d"
Expand Down
2 changes: 2 additions & 0 deletions koku/reporting/provider/aws/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
"product/instanceType": "",
"product/physicalCores": "",
"product/vcpu": "",
"product/memory": "",
"product/operatingSystem": "",
"pricing/unit": "",
"lineItem/UsageAmount": 0.0,
"lineItem/NormalizationFactor": 0.0,
Expand Down
3 changes: 2 additions & 1 deletion scripts/cji_scripts/migrate_trino.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ def main():
logging.info(schemas)

tables_to_drop = [
"azure_line_items",
"aws_line_items",
"aws_line_items_daily",
]
# columns_to_drop = ["ocp_matched"]
# columns_to_add = {
Expand Down

0 comments on commit e48395e

Please sign in to comment.