Working with OCI Cost Reports

April 24, 2020 | 2 minute read
Text Size 100%:

OCI has recently started providing new daily csv reports that include cost data for each resource instance.  The Cost Reports incorporate fields like SKU, mycost, billedQuantity, and billingUnit that allow to do data mining and analytics on resource instance usage and cost down to the hour.  More information on the included fields for both reports can be found in the documentation.

A difference between the new Cost Reports and the Usage Reports, besides the cost related fields, is the inclusion of usage/cost data for non-native services like CASB, OMC, Analytics, BlockChain, etc. in the Cost Report. These services can be distinguished from the others by an empty compartment field in the csv file as in the following example:

 

Before the release of Cost Reports the only way to obtain this degree of detail on cost data was to combine information from the Metering API with Usage Reports.

The Cost Reports are located in the same Object Storage Bucket as the Usage Reports.  To access them with OCI Console, go to Account Management->Usage Report

 

 

From the report list, notice that the Cost Reports have a different prefix from the Usage Reports, for example:

Cost Report name:       reports/cost-csv/000X0000000XXXXX.csv
Usage Report name:    reports/usage-csv/000Y0000000YYYYY.csv

 

If you are using a script with an OCI SDK to retrieve reports and you want to get a list of only one type of report, you can use the prefix argument in the object_storage.list_objects call to do so, for example in python:

report_list = oci.pagination.list_call_get_all_results(object_storage.list_objects, report_namespace,report_bucket,prefix="reports/cost-csv",fields='name,size,timeCreated')

This call will retrieve only Cost Reports.  If you want to retrieve both types of reports in the same list, just remove the prefix argument:

report_list = oci.pagination.list_call_get_all_results(object_storage.list_objects, report_namespace,report_bucket,fields='name,size,timeCreated')

You can find an example for downloading reports using the API here.

The OCI Cost Reports introduce a new simpler way to obtain and analyze usage and costs for all resources in your tenancy.  The csv files can be ingested and processed with Business Intelligence and Analytics tools that can process the cost data for better visualization and clarity.

Gustavo Saurez


Previous Post

Going beyond TCP healthchecks with OCI Load Balancer

Manasi Vaishampayan | 4 min read

Next Post


Using the OCI Instance Principals and Vault with Python to retrieve a Secret

Tim Melander | 10 min read