Accessing Usage Reports
A usage report is a comma-separate value (CSV) file that is generated daily and stored in an Object Storage bucket. This topic describes how to access usage reports.
Required IAM Policy
To use Oracle Cloud Infrastructure, you must be given the required type of access in a policy written by an administrator, whether you're using the Console or the REST API with an SDK, CLI, or other tool. If you try to perform an action and get a message that you don’t have permission or are unauthorized, confirm with your administrator the type of access you've been granted and which compartment you should work in.
If you're new to policies, see Getting Started with Policies and Common Policies.
Reports are generated in another tenancy and stored in an Oracle-owned Object Storage bucket. You must set up a cross-tenancy IAM policy to access your usage reports as shown below, changing the group name as appropriate:
define tenancy usage-report as ocid1.tenancy.oc1..aaaaaaaaned4fkpkisbwjlr56u7cj63lf3wffbilvqknstgtvzub7vhqkggq
endorse group MyGroupName to read objects in tenancy usage-report
Using the Console
To download a usage report
Open the navigation menu. Under Governance and Administration, go to Account Management and select Usage Report.
- Click the report you want to download from the list, and follow your browser's instructions for downloading.
Using the API
For information about using the API and signing requests, see REST APIs and Security Credentials. For information about SDKs, see Software Development Kits and Command Line Interface.
To download a usage report, use the Object Storage APIs. The reports are stored in the tenancy's home region. The Object Storage namespace used for the reports is
bling; the bucket name is the tenancy OCID.
The following example shows how to download a usage report using a Python script:
# This script downloads all of the usage reports for a tenancy (specified in the config file)
# Pre-requisites: Create an IAM policy to endorse users in your tenancy to read usage reports from the OCI tenancy
# Example policy:
# define tenancy usage-report as ocid1.tenancy.oc1..aaaaaaaaned4fkpkisbwjlr56u7cj63lf3wffbilvqknstgtvzub7vhqkggq
# endorse group group_name to read objects in tenancy usage-report
# Note - the only value you need to change is group name. Do not change the OCID in the first statement
usage_report_namespace = 'bling'
# Update these values
destintation_path = 'downloaded_reports'
# Make a directory to receive reports
if not os.path.exists(destintation_path):
# Get the list of usage reports
config = oci.config.from_file('config/config','DEFAULT')
usage_report_bucket = config['tenancy']
object_storage = oci.object_storage.ObjectStorageClient(config)
report_bucket_objects = object_storage.list_objects(usage_report_namespace, usage_report_bucket)
for o in report_bucket_objects.data.objects:
print('Found file ' + o.name)
object_details = object_storage.get_object(usage_report_namespace,usage_report_bucket,o.name)
filename = o.name.rsplit('/', 1)[-1]
with open(destintation_path + '/' + filename, 'wb') as f:
for chunk in object_details.data.raw.stream(1024 * 1024, decode_content=False):
print('Finished downloading ' + o.name + '\n')