Skip to content

Commit

Permalink
Add docs for the OCI/CBF field mappings.
Browse files Browse the repository at this point in the history
  • Loading branch information
intjonathan-forcepoint committed Jan 29, 2024
1 parent 1723f0c commit b3bd599
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
24 changes: 24 additions & 0 deletions OCI-CBF-TABLE.md
Original file line number Diff line number Diff line change
@@ -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/`<tag_key>` | resource/tag:`<tag_key>` | 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 |
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions python/anycostoci.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down

0 comments on commit b3bd599

Please sign in to comment.