Note:

Track OCI Resources, Cost, and Usage Report using Oracle Autonomous Database

Introduction

Oracle Autonomous Database is a convenient medium to track Oracle Cloud Infrastructure (OCI) resources, associated cost and usage reports. The resource usage reports come in a tabular format which is easier to read, download and use for further analysis. You can use inbuilt views in Oracle Autonomous Database to easily access these reports.

Objective

Prerequisites

Task 1: Create a Dynamic Group and Add the required Rules

  1. Create a dynamic group.

    Dynamic Groups

  2. Add the following required rules for the dynamic group.

    resource.id = '<autonomous database ocid>'
    
    ALL {resource.type = 'autonomous-database', resource.compartment.id =  '<compartment-ocid>'}
    

    Note:

    • resource.id is the OCID of the Oracle Autonomous Database instance.

    • resource.compartment.id is OCID of the compartment.

Task 2: Create the required Policies

Create the required policies for getting privileges to access the dynamic group created in Task 1. These are required to access the views.

policies

For example, to access all views, define the following policies:

Note: Do not replace the OCID in this policy with another OCID. This usage-report OCID provides the Oracle Cloud Infrastructure usage data for your tenancy.

Define tenancy usage-report as ocid1.tenancy.oc1..aaaaaaaaned4fkpkisbwjlr5xxxxxxxxxxfbilvqknstgtvzub7vhqkggq
Endorse dynamic-group <group-name> to read objects in tenancy usage-report
Allow dynamic-group <group-name> to inspect compartments in tenancy
Allow dynamic-group <group-name> to inspect tenancies in tenancy
Allow dynamic-group <group-name> to read buckets in tenancy
Allow dynamic-group <group-name> to read autonomous-database in tenancy
Allow dynamic-group <group-name> to read usage-reports in tenancy
Allow dynamic-group <group-name> to manage buckets in tenancy
Allow dynamic-group <group-name> to manage objects in tenancy
Allow dynamic-group <group-name> to read autonomous-database in compartment <compartment>

Task 3: Verify or Enable Resource Principal for the ADMIN user on Oracle Autonomous Database

Open the Oracle SQL Developer tool and run the following commands.

  1. Verify that resource principal is enabled for the ADMIN user on the Oracle Autonomous Database instance.

    SELECT owner, credential_name FROM dba_credentials
    WHERE credential_name = 'OCI$RESOURCE_PRINCIPAL' AND owner = 'ADMIN';
    
    OWNER CREDENTIAL_NAME
    ----- ---------------------
    ADMIN OCI$RESOURCE_PRINCIPAL
    
  2. If the resource principal is not enabled, then enable the resource principal.

    EXEC DBMS_CLOUD_ADMIN.ENABLE_RESOURCE_PRINCIPAL();
    

Task 4: Access the OCI Report Usage Views

Run the appropriate query to access the view. It may take some time for the views to populate and that is expected. You can also download the report in different file formats.

Acknowledgments

More Learning Resources

Explore other labs on docs.oracle.com/learn or access more free learning content on the Oracle Learning YouTube channel. Additionally, visit education.oracle.com/learning-explorer to become an Oracle Learning Explorer.

For product documentation, visit Oracle Help Center.