From b3bd599be1d4c3a7f5e58f80dc976be7718d0659 Mon Sep 17 00:00:00 2001 From: Jonathan Owens Date: Mon, 29 Jan 2024 15:01:03 -0800 Subject: [PATCH] Add docs for the OCI/CBF field mappings. --- OCI-CBF-TABLE.md | 24 ++++++++++++++++++++++++ README.md | 4 ++++ python/anycostoci.py | 4 ++-- 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 OCI-CBF-TABLE.md diff --git a/OCI-CBF-TABLE.md b/OCI-CBF-TABLE.md new file mode 100644 index 0000000..b3a410a --- /dev/null +++ b/OCI-CBF-TABLE.md @@ -0,0 +1,24 @@ +# OCI/CBF Field Mappings + +OCI emits both Cost and Usage reports. This tool uses only the Cost reports, as CBF has no fields for usage ("500 MB of this resource", etc). CBF only has fields for the cost of usage, which OCI emits in the cost report, so only that is used. + +You can view details of the [OCI Cost Reports schema](https://docs.oracle.com/en-us/iaas/Content/Billing/Concepts/usagereportsoverview.htm#Cost_and_Usage_Reports_Overview__cost_report_schema) on Oracle's documentation site, and the same for [CBF Schema](https://docs.cloudzero.com/docs/anycost-common-bill-format-cbf#data-file-columns) at CloudZero's. + +| OCI Cost File Column | CBF Column | Notes | +| --------------------------- | ------------------------------------ | ---------------------------------------------------------------------------------------------- | +| | lineitem/type | Always set to 'Usage' | +| product/description | lineitem/description | | +| lineitem/intervalUsageStart | time/usage_start | Always UTC from Oracle | +| lineitem/intervalUsageStart | time/usage_end | Always UTC from Oracle | +| product/resourceId | resource/id | | +| product/service | resource/service | | +| lineItem/tenantId | resource/account | | +| product/region | resource/region | | +| lineItem/tenantId | action/account | | +| usage/BilledQuantity | usage/amount | | +| cost/myCost | cost/cost | | +| tags/`` | resource/tag:`` | OCI tag keys permit more characters than CBF does. Disallowed CBF characters will be stripped. | +| | resource/tag:oci_tenancy_name | Synthesized tag | +| | resource/tag:oci_compartment_name | Synthesized tag | +| | resource/tag:oci_compartment_id | Synthesized tag | +| | resource/tag:oci_availability_domain | Synthesized tag | diff --git a/README.md b/README.md index 1a83b9d..98778db 100644 --- a/README.md +++ b/README.md @@ -127,6 +127,10 @@ For example, cost data files for January will continue to flow into the OCI obje Additional runs that pick up no new data do not affect accuracy, they merely incur processing cost. +### Output Notes + +OCI billing output doesn't necessarily map cleanly to every CBF field. Some special handling of OCI-specific tenancy and account properties are represented as synthesized resource tags. For details, see [OCI/CBF Field Mappings](OCI-CBF-TABLE.md). + ## Contributing We appreciate feedback and contribution to this repo! Before you get started, please see the following: diff --git a/python/anycostoci.py b/python/anycostoci.py index db7afa8..022b2a4 100644 --- a/python/anycostoci.py +++ b/python/anycostoci.py @@ -166,8 +166,8 @@ def build_anycost_drop_from_oci_files(lookback_months: int, cbf_frame.insert(0, 'lineitem/id', oci_cost.loc[:, 'lineItem/referenceNo']) # AFAICT all cost types in OCI are 'Usage', with the possible # exception of 'Adjustment's for rows with isCorrection=True. - # Depending on how corrections are handled we may not need - # to show that. + # However, Adjustments just emit the corrected cost, not the + # offset. So we'll just call everything Usage. cbf_frame.insert(1, 'lineitem/type', 'Usage') cbf_frame.insert(2, 'lineitem/description', oci_cost.loc[:, 'product/Description']) cbf_frame.insert(3, 'time/usage_start', oci_cost.loc[:, 'lineItem/intervalUsageStart'])