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 An IAM document that specifies who has what type of access to your resources. It is used in different ways: to mean an individual statement written in the policy language; to mean a collection of statements in a single, named "policy" document (which has an Oracle Cloud ID (OCID) assigned to it); and to mean the overall body of policies your organization uses to control access to resources. 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 A collection of related resources that can be accessed only by certain groups that have been given permission by an administrator in your organization. you should work in.
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
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:
import oci import os # 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): os.mkdir(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): f.write(chunk) print('Finished downloading ' + o.name + '\n')