Track Oracle Cloud Infrastructure Resources, Cost and Usage Reports with Autonomous Database Views

Oracle Autonomous Database tracks the Oracle Cloud Infrastructure resources, cost and usage reports. You can access these reports using the OCI views.

Prerequisite Steps to Use OCI Resource Views

Describes the prerequisite steps you must perform to use OCI resource views on Autonomous Database.

Note

Only ADMIN user has access to the OCI resource views by default. To access these views as another user, the ADMIN must grant READ privileges.

To query an OCI resource view, do the following:

  1. Create a dynamic group that includes your Autonomous Database instance and define the required policies to access a view.

    For example, the Autonomous Database instance is specified in the resource.id parameter with an OCID:

    resource.id = '<your_Autonomous_Database_instance_OCID>'

    Each view shows the details for the policy that you must define to query the view.

    See Perform Prerequisites to Use Resource Principal with Autonomous Database for details on creating a dynamic group and defining policies.

    For example, to access all of the views, define the following policy:

    Define tenancy usage-report as ocid1.tenancy.oc1..aaaaaaaaned4fkpkisbwjlr56u7cj63lf3wffbilvqknstgtvzub7vhqkggq 
    Endorse dynamic-group <group-name> to read objects in tenancy usage-report
    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-budgets in tenancy
    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.
  2. Verify that resource principal is enabled for the ADMIN user on the 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

    If the resource principal is not enabled, then enable the resource principal:

    EXEC DBMS_CLOUD_ADMIN.ENABLE_RESOURCE_PRINCIPAL();

    See Use Resource Principal to Access Oracle Cloud Infrastructure Resources for more information.

  3. Run a query on an OCI resource view.

    For example:

    SELECT NAME, APPROXIMATESIZE FROM OCI_OBJECTSTORAGE_BUCKETS;
    SELECT * FROM OCI_USAGE_DATA;

OCI_AUTONOMOUS_DATABASES View

OCI_AUTONOMOUS_DATABASES describes all the Oracle Cloud Infrastructure Autonomous Databases in the Oracle Cloud Infrastructure tenancy obtained from the current Autonomous Database instance.

To query this view you need a dynamic group that includes your Autonomous Database instance and the following policy defined on that dynamic group:

Allow dynamic-group <group-name> to read autonomous-database in tenancy

This policy lets you list all Autonomous Databases in your tenancy. Optionally you can restrict it to list Autonomous Databases in a given compartment:

Allow dynamic-group <group-name> to read autonomous-database in compartment <compartment-name>
Column Datatype Description
DISPLAYNAME VARCHAR2 The user friendly name for the Autonomous Database
REGION VARCHAR2 Region Name
COMPARTMENTID VARCHAR2 The OCID of the compartment
ID VARCHAR2 The OCID of the Autonomous Database
DBNAME VARCHAR2 The database name
LIFECYCLESTATE VARCHAR2 The current state of the Autonomous Database
TIMECREATED VARCHAR2 The date and time the Autonomous Database was created
DATASTORAGESIZEINTBS VARCHAR2 The quantity of data in the database in terabytes
LICENSEMODEL VARCHAR2 The Oracle license model that applies to the Autonomous Database
SERVICECONSOLEURL VARCHAR2 The URL of the Service Console for the Autonomous Database
APEXDETAILS CLOB Information about Oracle APEX Application Development
AREPRIMARYWHITELISTEDIPSUSED VARCHAR2 Primary White Listed IPs
AUTONOMOUSCONTAINERDATABASEID VARCHAR2 The Autonomous Container Database OCID
AUTONOMOUSMAINTENANCESCHEDULETYPE VARCHAR2 Maintenance Schedule Type
AVAILABLEUPGRADEVERSIONS VARCHAR2 List of Oracle Database versions available for a database upgrade
BACKUPCONFIG CLOB Autonomous Database Backup Config
CONNECTIONSTRINGS CLOB Autonomous Database Connection Strings
CONNECTIONURLS CLOB Autonomous Database Connection URLs
CPUCORECOUNT NUMBER The number of OCPU cores to be made available to the database
CUSTOMERCONTACTS CLOB The Customer Contacts
DATASAFESTATUS VARCHAR2 Status of the Data Safe registration for this Autonomous Database
DATASTORAGESIZEINGBS NUMBER The quantity of data in the database in gigabytes
DBVERSION VARCHAR2 The Oracle Database version for the Autonomous Database
DATAGUARDREGIONTYPE VARCHAR2 The Autonomous Data Guard region type of the Autonomous Database
DBWORKLOAD VARCHAR2 The Autonomous Database workload type
DEFINEDTAGS CLOB Defined tags for the resource
FAILEDDATARECOVERYINSECONDS NUMBER Indicates the number of seconds of data loss for an Autonomous Data Guard failover
FREEFORMTAGS CLOB Free form tags for the resource
INFRASTRUCTURETYPE VARCHAR2 The infrastructure type this resource belongs to
ISACCESSCONTROLENABLED VARCHAR2 Indicates if the database level access control is enabled
ISAUTOSCALINGENABLED VARCHAR2 Indicates if auto scaling is enabled for the Autonomous Database
ISDATAGUARDENABLED VARCHAR2 Indicates whether the Autonomous Database has a local Autonomous Data Guard enabled
ISDEDICATED VARCHAR2 True if the database uses dedicated Exadata infrastructure
ISFREETIER VARCHAR2 Indicates if this is an Always Free resource
ISMTLSCONNECTIONREQUIRED VARCHAR2 Indicates whether the Autonomous Database requires mTLS connections
ISPREVIEW VARCHAR2 Indicates if the Autonomous Database version is a preview version
ISREFRESHABLECLONE VARCHAR2 Indicates whether the Autonomous Database is a refreshable clone
KEYHISTORYENTRY CLOB Key History Entry
KEYSTOREID VARCHAR2 The OCID of the key store
KEYSTOREWALLETNAME VARCHAR2 The wallet name for Oracle Cloud Infrastructure Vault
KMSKEYID VARCHAR2 The OCID of the key container that is used as the master encryption key
KMSKEYLIFECYCLEDETAILS VARCHAR2 Customer managed key lifecycle details
LIFECYCLEDETAILS VARCHAR2 Information about the current lifecycle state
NSGIDS CLOB A list of the OCIDs of the network security groups NSGs
OCPUCOUNT NUMBER The number of OCPU cores to be made available to the database
OPENMODE VARCHAR2 The Autonomous Database open mode
OPERATIONSINSIGHTSSTATUS VARCHAR2 Status of OCI Ops Insights for this Autonomous Database
PEERDBIDS VARCHAR2 The list of OCIDs of standby databases located in Autonomous Data Guard
PERMISSIONLEVEL CLOB The Autonomous Database permission level
PRIVATEENDPOINT VARCHAR2 The private endpoint for the resource
PRIVATEENDPOINTIP VARCHAR2 The private endpoint IP address for the resource
PRIVATEENDPOINTLABEL VARCHAR2 The private endpoint label for the resource
REFRESHABLEMODE VARCHAR2 The refresh mode of the clone
REFRESHABLESTATUS VARCHAR2 The refresh status of the clone
ROLE VARCHAR2 The Autonomous Data Guard role
SOURCEID VARCHAR2 The OCID of the source Autonomous Database that was cloned
SQLWEBDEVELOPERURL VARCHAR2 The Database Actions (SQL Developer Web) URL for the Autonomous Database
STANDBYDB CLOB Autonomous Database Standby Summary
STANDBYWHITELISTEDIPS CLOB The client IP access control list
SUBNETID VARCHAR2 The OCID of the subnet the resource is associated with
SUPPORTEDREGIONSTOCLONETO CLOB The list of regions that support the creation of Autonomous Data Guard
SYSTEMTAGS CLOB System tags for this resource
TIMEDATAGUARDROLECHANGED VARCHAR2 The date and time the Autonomous Data Guard role was switched
TIMEDELETIONOFFREEAUTONOMOUSDATABASE NUMBER Time deletion of Free Autonomous Database
TIMELOCALDATAGUARDENABLED VARCHAR2 The date and time that Autonomous Data Guard was enabled for the Autonomous Database
TIMEMAINTENANCEBEGIN VARCHAR2 The date and time when maintenance will begin
TIMEMAINTENANCEEND VARCHAR2 The date and time when maintenance will end
TIMEOFLASTFAILOVER VARCHAR2 The timestamp of the last failover operation
TIMEOFLASTREFRESH VARCHAR2 The date and time of the last refresh
TIMEOFLASTREFRESHPOINT VARCHAR2 The refresh point timestamp
TIMEOFLASTSWITCHOVER VARCHAR2 The timestamp of the last switchover operation for the Autonomous Database
TIMEOFNEXTREFRESH VARCHAR2 The date and time of next refresh
TIMERECLAMATIONOFFREEAUTONOMOUSDATABASE VARCHAR2 The date and time the Always Free database
USEDDATASTORAGESIZEINTBS NUMBER The amount of storage that has been used in terabytes
VAULTID VARCHAR2 The OCID of the Oracle Cloud Infrastructure Vault
WHITELISTEDIPS CLOB The client IP access control list

OCI_BUDGET_ALERT_RULES View

OCI_BUDGET_ALERT_RULES describes all the Oracle Cloud Infrastructure budget alert rules in the Oracle Cloud Infrastructure tenancy obtained from the current Autonomous Database instance.

Queries against this view return results only if you have budgets and budget alerts created in your tenancy.

See Budgets Overview for more information.

To query this view you need a dynamic group that includes your Autonomous Database instance and the following policy defined on that dynamic group:

Allow dynamic-group <group-name> to read usage-budgets in tenancy

This policy lets you list budget summary and budget alerts in your tenancy (if you created a budget and a budget alert). Optionally you can restrict the result returned by querying the view to a given compartment:

Allow dynamic-group <group-name> to read usage-budgets in compartment <compartment-name>
Column Datatype Description
BUDGETID VARCHAR2 The OCID of the budget
REGION VARCHAR2 Region name
COMPARTMENTID VARCHAR2 The compartment ID in which the bucket is authorized
DEFINEDTAGS CLOB Defined tags for the resource
DESCRIPTION VARCHAR2 The description of the alert rule
DISPLAYNAME VARCHAR2 The name of the alert rule
FREEFORMTAGS CLOB Free-form tags for the resource
ID VARCHAR2 The OCID of the alert rule
LIFECYCLESTATE VARCHAR2 The current state of the alert rule
MESSAGE VARCHAR2 The custom message that will be sent when the alert is triggered
RECIPIENTS VARCHAR2 The audience that receives the alert when it triggers
THRESHOLD NUMBER The threshold for triggering the alert
THRESHOLDTYPE VARCHAR2 The type of threshold
TIMECREATED VARCHAR2 The time when the budget was created
TIMEUPDATED VARCHAR2 The time when the budget was updated
TYPE VARCHAR2 ACTUAL or FORECAST types of alert triggers
VERSION NUMBER The version of the alert rule

OCI_BUDGET_SUMMARY View

OCI_BUDGET_SUMMARY describes all the Oracle Cloud Infrastructure budget summaries in the Oracle Cloud Infrastructure tenancy obtained from the current Autonomous Database instance.

Queries against this view return results only if you have budgets created in your tenancy.

See Budgets Overview for more information.

To query this view you need a dynamic group that includes your Autonomous Database instance and the following policy defined on that dynamic group:

Allow dynamic-group <group-name> to read usage-budgets in tenancy

This policy lets you list budget summary and budget alerts in your tenancy (if you created a budget and a budget alert). Optionally you can restrict the result returned by querying the view to a given compartment:

Allow dynamic-group <group-name> to read usage-budgets in compartment <compartment-name>
Column Datatype Description
REGION VARCHAR2 Region name
COMPARTMENTID VARCHAR2 The OCID of the compartment
AMOUNT NUMBER The amount of the budget, expressed in the currency of a rate card
DEFINEDTAGS CLOB Defined tags for the resource
FREEFORMTAGS CLOB Free-form tags for the resource
DISPLAYNAME VARCHAR2 The display name of the budget
LIFECYCLESTATE VARCHAR2 The current state of the budget
ACTUALSPEND NUMBER The actual spend in currency for the current budget cycle
ALERTRULECOUNT NUMBER The total number of alert rules in the budget
BUDGETPROCESSINGPERIODSTARTOFFSET NUMBER The number of days offset from the first day of the month, at which the budget processing period starts
DESCRIPTION VARCHAR2 The description of the budget
FORECASTEDSPEND NUMBER The forecasted spend in currency by the end of the current budget cycle
ID VARCHAR2 The OCID of the budget
RESETPERIOD VARCHAR2 The reset period for the budget
TARGETS CLOB The list of targets on which the budget is applied
TARGETCOMPARTMENTID VARCHAR2 Target compartment OCID
TARGETTYPE VARCHAR2 The type of target on which the budget is applied
TIMECREATED VARCHAR2 The time the budget was created
TIMESPENDCOMPUTED VARCHAR2 The time the budget spend was last computed
TIMEUPDATED VARCHAR2 The time the budget was updated
VERSION VARCHAR2 The version of the budget

OCI_COST_DATA View

OCI_COST_DATA describes all the Oracle Cloud Infrastructure cost data for the Oracle Cloud Infrastructure tenancy obtained from the current Autonomous Database instance.

To query this view you need a dynamic group that includes your Autonomous Database instance and the following policy defined on that dynamic group:

Define tenancy usage-report as ocid1.tenancy.oc1..aaaaaaaaned4fkpkisbwjlr56u7cj63lf3wffbilvqknstgtvzub7vhqkggq 
Endorse dynamic-group <group-name> to read objects in tenancy usage-report
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.
Column Datatype Description
REFERENCE_NUMBER VARCHAR2 Reference Number/Line identifier used for debugging and corrections
TENANT_ID VARCHAR2 The identifier (OCID) for the Oracle Cloud Infrastructure tenant
INTERVAL_USAGE_START TIMESTAMP The start time of the usage interval for the resource in UTC
INTERVAL_USAGE_END TIMESTAMP The end time of the usage interval for the resource in UTC
SERVICE_NAME VARCHAR2 The service that the resource is in
COMPARTMENT_ID VARCHAR2 The ID of the compartment that contains the resource
COMPARTMENT_NAME VARCHAR2 The name of the compartment that contains the resource
REGION VARCHAR2 The region that contains the resource
AVAILABILITY_DOMAIN VARCHAR2 The availability domain that contains the resource
RESOURCE_ID VARCHAR2 The identifier for the resource
BILLED_QUANTITY VARCHAR2 The quantity of the resource that has been billed over the usage interval
BILLED_QUANTITY_OVERAGE VARCHAR2 The usage quantity for which you were billed
SUBSCRIPTION_ID VARCHAR2 A unique identifier associated with your commitment or subscription
PRODUCT_SKU VARCHAR2 The Part Number for the resource in the line
PRODUCT_DESCRIPTION VARCHAR2 The product description for the resource in the line
UNIT_PRICE VARCHAR2 The cost billed to you for each unit of the resource used
UNIT_PRICE_OVERAGE VARCHAR2 The cost per unit of usage for overage usage of a resource
MY_COST VARCHAR2 The cost charged for this line of usage
MY_COST_OVERAGE VARCHAR2 The cost billed for overage usage of a resource
CURRENCY_CODE VARCHAR2 The currency code for your tenancy
BILLING_UNIT_READABLE VARCHAR2 The unit measure associated with the usage/billedQuantity in the line
SKU_UNIT_DESCRIPTION VARCHAR2 The unit used for measuring billed quantity
OVERAGE_FLAG CHAR Flag used for overage usage
IS_CORRECTION VARCHAR2 Used if the current line is a correction
BACK_REFERENCE_NUMBER VARCHAR2 Data amendments and corrections reference
CREATED_BY VARCHAR2 The user who created the service
CREATED_ON TIMESTAMP The time when the service was created
FREE_TIER_RETAINED VARCHAR2 Is the service retained on free tier

OCI_OBJECTSTORAGE_BUCKETS View

OCI_OBJECTSTORAGE_BUCKETS describes all the Oracle Cloud Infrastructure object storage buckets in the Oracle Cloud Infrastructure tenancy obtained from the current Autonomous Database instance.

To query this view you need a dynamic group that includes your Autonomous Database instance and the following policy defined on that dynamic group:

Allow dynamic-group <group-name> to read buckets in tenancy

This policy lets you list object storage buckets in your tenancy. Optionally you can restrict the result returned by querying this view to a given compartment:

Allow dynamic-group <group-name> to read buckets in compartment <compartment-name>
Column Datatype Description
REGION VARCHAR2 Region name
COMPARTMENTID VARCHAR2 The compartment ID in which the bucket is authorized
NAMESPACE VARCHAR2 The Object Storage namespace in which the bucket resides
APPROXIMATECOUNT NUMBER The approximate number of objects in the bucket
APPROXIMATESIZE NUMBER The approximate total size in bytes of all objects in the bucket
AUTOTIERING VARCHAR2 The auto tiering status on the bucket
CREATEDBY VARCHAR2 The OCID of the user who created the bucket
DEFINEDTAGS CLOB Defined tags for the resource
FREEFORMTAGS CLOB Free-form tags for the resource
ETAG VARCHAR2 The entity tag (ETag) for the bucket
ID VARCHAR2 The OCID of the bucket
ISREADONLY VARCHAR2 Whether or not this bucket is read only
KMSKEYID VARCHAR2 The OCID of a master encryption key
METADATA VARCHAR2 Arbitrary string keys and values for user-defined metadata
NAME VARCHAR2 The name of the bucket
OBJECTEVENTSENABLED VARCHAR2 Whether or not events are emitted for object state changes in this bucket
OBJECTLIFECYCLEPOLICYETAG VARCHAR2 The entity tag (ETag) for the live object lifecycle policy on the bucket
PUBLICACCESSTYPE VARCHAR2 The type of public access enabled on this bucket
REPLICATIONENABLED VARCHAR2 Whether or not this bucket is a replication source
STORAGETIER VARCHAR2 The storage tier type assigned to the bucket
TIMECREATED VARCHAR2 The date and time the bucket was created
VERSIONING VARCHAR2 The versioning status on the bucket

OCI_USAGE_DATA View

OCI_USAGE_DATA describes all the Oracle Cloud Infrastructure usage data for the Oracle Cloud Infrastructure tenancy obtained from the current Autonomous Database instance.

To query this view you need a dynamic group that includes your Autonomous Database instance and the following policy defined on that dynamic group:

Define tenancy usage-report as ocid1.tenancy.oc1..aaaaaaaaned4fkpkisbwjlr56u7cj63lf3wffbilvqknstgtvzub7vhqkggq
Endorse dynamic-group <group-name> to read objects in tenancy usage-report
Note

Do not replace the OCID in this policy with another OCID. This usage-report OCID provides the Oracle Cloud Infrastructure cost and usage data for your tenancy.
Column Datatype Description
REFERENCE_NUMBER VARCHAR2 Reference Number/Line identifier used for debugging and corrections
TENANT_ID VARCHAR2 The identifier (OCID) for the Oracle Cloud Infrastructure tenant
INTERVAL_USAGE_START TIMESTAMP The start time of the usage interval for the resource in UTC
INTERVAL_USAGE_END TIMESTAMP The end time of the usage interval for the resource in UTC
SERVICE_NAME VARCHAR2 The service that the resource is in
RESOURCE_NAME VARCHAR2 The resource name used by the metering system
COMPARTMENT_ID VARCHAR2 The ID of the compartment that contains the resource
COMPARTMENT_NAME VARCHAR2 The name of the compartment that contains the resource
REGION VARCHAR2 The region that contains the resource
AVAILABILITY_DOMAIN VARCHAR2 The availability domain that contains the resource
RESOURCE_ID VARCHAR2 The identifier for the resource
CONSUMED_QUANTITY VARCHAR2 The quantity of the resource that has been consumed over the usage interval
BILLED_QUANTITY VARCHAR2 The quantity of the resource that has been billed over the usage interval
CONSUMED_QUANTITY_UNITS VARCHAR2 The unit for the consumed quantity and billed quantity
CONSUMED_QUANTITY_MEASURE VARCHAR2 The measure for the consumed quantity and billed quantity
IS_CORRECTION VARCHAR2 Used if the current line is a correction
BACK_REFERENCE_NUMBER VARCHAR2 Data amendments and corrections reference
CREATED_BY VARCHAR2 The user who created the service
CREATED_ON TIMESTAMP The time when the service was created
FREE_TIER_RETAINED VARCHAR2 Is the service retained on free tier