Cost Analysis
Cost Analysis is an easy-to-use visualization tool to help you track and optimize your Oracle Cloud Infrastructure spending. You can generate charts, and download accurate, reliable tabular reports of aggregated cost data on your Oracle Cloud Infrastructure consumption.
Use Cost Analysis for spot checks of spending trends and for generating reports. Common scenarios you might be interested in include:
- Viewing monthly costs for compartment X and its children, grouped by service or by tag.
- Viewing daily costs for tag key A and tag key B, values X, Y and Z, grouped by service and product description (SKU).
- Viewing hourly costs for service = compute or database, grouped by compartment name.
You can choose from one of the predefined, default reports from the Reports menu, and you can choose the dates you're interested in. By default, the Costs by Service report is shown when the Cost Analysis page first opens. Use the Filters menu to filter by the specific tags, compartments, services, or other filter you want, and pick how you want it grouped using the Grouping dimensions menu. As a result, a chart and corresponding data table are generated, and can also be downloaded as a CSV data table, PDF, or chart image. You can also save a custom set of dates, filters, and grouping dimensions into a saved report. Up to 10 custom reports can be saved, and on each saved report, you can add up to five custom tabs, which allow you to create custom charts and tables of cost data using different combinations of grouping dimensions. See Cost Analysis Query Fields and Viewing and Working with the Chart Data for more information on the related Cost Analysis query settings. You can also estimate future usage and consumption information, based on past usage data.
If you want to re-create the breakdown provided by the former Classic Version of the Cost Analysis tool, apply the SKU (Part Number) grouping dimension in the current version of Cost Analysis. To explore your costs in new ways, we recommended viewing your costs based on Service, or Service and Product Description. If you are doing cost tracking, we recommended grouping by Compartment or Tag.
All tags, not only cost tracking tags, are supported.
Costs for tags are based on the date at which the tag was associated with a resource. It does not work retroactively for resources on which these tags are applied.
Required IAM Policy
To use Oracle Cloud Infrastructure, you must be granted security access in a policy by an administrator. This access is required whether you're using the Console or the REST API with an SDK, CLI, or other tool. If you get a message that you don't have permission or are unauthorized, verify with your administrator what type of access you have and which compartment to work in.
If you're new to policies, see Getting Started with Policies and Common Policies.
To use Cost Analysis, the following policy statement is required:
Allow group <group_name> to read usage-report in tenancy
To use Saved Reports, the following policy statement is required:
Allow group <group_name> to manage usage-report in tenancy
Authentication and Authorization
Each service in Oracle Cloud Infrastructure integrates with IAM for authentication and authorization, for all interfaces (the Console, SDK or CLI, and REST API).
An administrator in your organization needs to set up groups , compartments , and policies that control which users can access which services, which resources, and the type of access. For example, the policies control who can create new users, create and manage the cloud network, launch instances, create buckets, download objects, and so on. For more information, see Getting Started with Policies. For specific details about writing policies for each of the different services, see Policy Reference.
If you're a regular user (not an administrator) who needs to use the Oracle Cloud Infrastructure resources that your company owns, contact your administrator to set up a user ID for you. The administrator can confirm which compartment or compartments you should be using.
Cost Analysis Query Fields
The following table describes the Cost Analysis query fields.
Field | Description |
---|---|
Reports | Select from one of the Default Reports:
After you have created some saved reports, they are listed in this menu under Saved Reports. |
Start/End Date (UTC) |
Select the start and end date according to the UTC time zone. After clicking either of the calendar icons, you can also query and
select predefined time ranges for data available in the usage
store:
These preset time ranges are crucial for saved reports, because they will automatically change the time range every time a saved report is launched. For example, if the current date was March 18, and you created a saved report with 7D as the time period, the report shows data from March 11 to March 18. When you launch the same report the next day (March 19), the date range switches to March 12 to March 19. Lastly, when setting the time period, it is also indicated above the chart in Time Period. Note: Historical data is currently being back-filled for tenancies and may not appear immediately. As the process completes, up to twelve months of past consumption data will become available. |
Granularity |
Granularity (hourly, daily, monthly) is based on the requested date range size. The logic is the following:
|
Show |
Allows you to view the report in terms of Cost (the default) or Usage. For a virtual machine cluster with pluggable databases, select Attributed cost or Attributed usage. Otherwise, for all other resources, use Cost or Usage. Also, selecting Attributed cost or Attributed usage for any non-VM cluster resource generates the same output as Cost or Usage. For more information, see Viewing Cost and Usage from Virtual Machine Cluster Pluggable Databases. |
Show Forecast | Allows estimating future usage and consumption information, based on past usage data. See Forecasting Costs for prerequisites and usage information. When Show Forecast is selected, the End Date (UTC) field changes to End Forecast Date (UTC). Note:When viewing forecast data, you can choose dates from End Date (UTC) after the current day, but you can not do this when Show Forecast isn't selected. |
Cumulative | Select this option to change the values so that they're cumulative for the selected time period. For example, consider if you were looking at 10 days of data, cumulatively, and the values for each day are $5. In such a case, selecting Cumulative displays values of 5, 10, 15, 20, 25, 30, 35, 40, 45, and 50 across the 10 days, respectively. In a non-cumulative chart, the values display as 5, 5, 5, 5, 5, 5, 5, 5, 5, 5. |
Filters |
Allows filtering on the following:
See Filters for more information on adding, editing, and removing filters, and filter logic. |
Grouping Dimensions |
Allows visualizing the data in terms of the particular grouping. A grouping dimension by Service is displayed by default. You can view only one grouping dimension at a time.
See Grouping Dimensions for more information on viewing and changing grouping dimensions. |
Viewing and Working with the Chart Data
When the Cost Analysis page first opens, the default view is to show the Costs by Service report, grouped by Service and with Daily granularity. The default date range is from the first day of the month to the current day. The Cost Analysis chart is organized in terms of the date (UTC) on the X-axis, and the cost amount on the Y-axis. When viewing a chart, you can hover the mouse over a data point in the chart to see more details. The tooltip shows the cost value summary for the particular Y-axis item at a particular time, whether you're viewing the chart as either a Bars (the default), Lines, or Stacked Lines chart.
You can start by viewing the chart data in terms of the predefined reports, by selecting one from the Reports menu, and then adjust the date range, granularity, and then add or remove filters and grouping dimensions (or both, that is, view the cost data according to one or more filters, or in terms of both filters and a single grouping dimension).
You can also save your adjustments as a saved report that you can view later, alongside the predefined reports. See Saving Reports for more information on saving reports.
To the right of the chart, the Legend box shows all the data by default, and each item is color-coded. You can click any of the Legend items to switch the chart data on or off for that item. For example, when viewing a chart with various services and their costs, the Legend box includes all the impacted services related to the query. Toggling one or more of the services shows or hides them dynamically from the chart output. Toggling the Legend data, however, doesn't change the data shown in the table view, or what is downloaded.
A tabular view of the chart is also provided under the chart, which is updated as you apply different time period, filtering, and grouping dimension options. When viewing the table data, you can click any of the column headers to sort in ascending or descending order.
To help find out what is driving costs, see the following topics:
- Using Multiple Filters to View Costs
- Identifying a Resource that is Consuming Costs
- Grouping by Service and SKU, or Service and Product Description to Identify Costs
Data can take up to 48 hours to appear in Cost Analysis.
Viewing Query History
You can view your Cost Analysis query history at any time by clicking the Query History link at the top of page. After clicking this link, the Oracle Cloud Infrastructure Logging Audit page opens.
The Audit page is pre-filtered to show the Cost Analysis-related audit events.
Under the Explore events tab, you can view the query parameters from
any Cost Analysis query event, which are of the
com.oraclecloud.UsageApi.GetUsage
type. Expand the JSON view for an event
entry to view the query parameters, which are available under the
"additionalDetails"
node.
The following are the query fields that are displayed:
- endTime
- granularity
- queryType
- startTime
- tenantId
For example:
{
"datetime": 1650325072577,
"logContent": {
"data": {
"additionalDetails": {
"endTime": "<time>"
"granularity": "<granularity>"
"queryType": "<type>"
"startTime": "<date-time>"
"tenantId": "<unique_ID>"
}
Filters
See the following for instructions on how to add, edit, and remove filters, as well filter logic.
- Open the navigation menu and click Billing & Cost Management. Under Cost Management, click Cost Analysis.
- From Start/End Date (UTC), select a time period.
- From Show, select whether you want to view Cost or Usage.
- From Filters, select a filter. A dialog specific to the chosen filter is displayed. For example, if you chose Service, select a service from the list. You can add several services if preferred, or click the X icon to remove service filters. Click Select when you're finished selecting filtering criteria.
- Click Apply to apply the changes and reload the chart and table with the selected filters.
- To edit the filter after it has already been applied to the chart, click the filter. The filter's dialog box is displayed.
- From the filter dialog menu, select one or more filters, and click Select.
- Click Apply to apply the changes and reload the chart and table with the selected filters.
- To remove the filter after it has been applied to the chart, click Clear all filters, or click the filter's X icon next to Filters.
- Click Apply to apply the changes and reload the chart and table without the selected filters.
- Open the navigation menu and click Billing & Cost Management. Under Cost Management, click Cost Analysis.
- From Reports, select one of the predefined reports, or create a new one.
- In Start date (UTC), select a start date.
- In End date (UTC), select an ending date.Note
Historical data is currently being back-filled for tenancies and may not appear immediately. As the process completes, up to twelve months of past consumption data will become available. - Click Apply.
- Open the navigation menu and click Billing & Cost Management. Under Cost Management, click Cost Analysis.
- From Reports, select one of the predefined reports, or create a new one.
- From Filters, select the Tag filter.
- In the Tag dialog box, complete the following. See Overview of Tagging for descriptions of these fields.
-
Tag Namespace
-
Tag Key
-
Tag Value
-
- Click Select.
- Click Apply.
- Open the navigation menu and click Billing & Cost Management. Under Cost Management, click Cost Analysis.
- From Filters, select the Compartment filter.
- In the Compartment dialog box, under Filter Compartments, select a compartment filtering option:
- By name
- By OCID
- By Path (for example, root/compartmentname/compartmentname)
Note
Filtering by compartment displays usage and costs attributed to all resources in the selected compartments, and their child compartments. - Click Apply.
- When you filter costs, a label appears next to Filters with the name of the tag or compartment filter. To clear the filter, click the X icon, or click Clear all filters.
Filter Logic
Filters are ORed within each specific filter, and ANDed between filters. For example, a filter for Service = Compute, Block Storage, Object Storage, Database, and Tag = Tag Key "MyKey" displays data that is for (Compute OR Block Storage OR Object Storage OR Database) AND Tag Key "MyKey".
The Tag filter, however, is a unique case. You can add multiple Tag filters, which function as a joined OR.
Only ten Tag Key values are retrieved and shown in the list when you try to select a possible Tag Key value. Or, you can manually type in the Tag Key value you want to filter on.
Using Multiple Filters to View Costs
You can start by filtering the Cost Analysis chart data based on a single filter, and then add additional filters. For example:
- Set your Grouping Dimensions to Service, to view your costs by service.
- From Filters, add a filter by Tag.
- Select a Tag Namespace (this example uses "Financial" as the selected namespace).
- Select a Tag Key (this example uses "Owner" as the selected key).
- Specify whether to Match any value (AND condition), or
Match any of the following (OR condition).
For example, assuming the value "alpha" is the value, and if Match any of the following is chosen, it means show all services that have "alpha" as the owner. Conversely, assuming multiple values "alpha" and "beta" are chosen, and if Match any of the following is selected, this corresponds to an OR condition (meaning, filter to show the costs from all the services from the "Financial" namespace, with the Tag Key "Owner", that matches either the "alpha" or "beta" values).
- Click Select, then Apply to reload the Cost Analysis chart with the filtered information.
You can also add another filter by tag, to break the data down further. For example:
- From Filters, add a filter by Tag.
- Select a Tag Namespace and Tag Key (for example, the "Cost Center" namespace).
- Select Match any of the following, and for example, filter
for any "Cost Center" values of "1234" or "5678".
After clicking Select, then Apply, this filter shows the costs from all the services with the tag filter you just created, plus this second tag filter ("Financial" namespace, Tag Key "Owner", "alpha" or "beta" values + "Cost Center" namespace with the values of "1234" or "5678"). The two tag filters together amount to an AND with the previous filter (the two filters are shown adjacent to the Add Filter drop-down list).
Alternatively, instead of the second Tag filter ("Cost Center" namespace with the values of "1234" or "5678"), you could add a Service filter (NETWORK), and that would show the costs from all the services from the "Financial" namespace, with the Tag Key "Owner", that matches both the "alpha" or "beta" values, and is filtered by the NETWORK service type.
Grouping Dimensions
Grouping dimensions change the way data is aggregated, but don't change the sum. If a resource doesn't have a value for a particular field, a "no value" column is displayed, which reflects the sum of those resources. Products which are GEN_1 often don't have an Availability domain, compartment, or resource ID.
- Open the navigation menu and click Billing & Cost Management. Under Cost Management, click Cost Analysis.
- From Start/End Date (UTC), select a time period.
- From Show, select whether you want to view Cost or Usage.
- From Grouping Dimensions, select the preferred grouping dimension. If Compartment or Tag is chosen, additional compartment or tag selection fields appear.
- Click Apply to apply the changes and reload the chart and table with the selected grouping dimension.
- To change the grouping dimension, select it from Grouping Dimensions.
- Click Apply to apply the changes and reload the chart and table with the new grouping dimension.
Identifying a Resource that is Consuming Costs
If you have noticed a large amount of, for example, Database service usage that has appeared in a chart, and you wanted to identify which resource was responsible, you can group by Resource OCID from the Grouping Dimensions list. Next, from Filters, add a filter for the service type (Database in this example), and click Apply to reload the chart.
The chart reloads to show which resource OCIDs were driving the Database cost, both when hovering over the data point in the chart, and in the Legend box. These resource OCIDs are also displayed in the data table below the chart. If desired, you can save this information by clicking Tab Actions, and then selecting Download Table as CSV or Download Chart.
The Legend box is set to a default size when the charts first loads, but you can click and drag the box to more easily read lengthy items within the box (such as OCIDs).
To find more information about the resource, copy the OCID and enter it in the Console's Search box, to pinpoint which resource is driving costs.
Grouping by Service and SKU, or Service and Product Description to Identify Costs
In some instances you may see multiple SKU numbers for a service. When grouping by Service and SKU (Part Number), multiple SKU numbers for the same service appear in the Legend box. For example, if you had multiple Compute entries in the Legend box but they have different SKUs, it means there is one resource using multiple underlying infrastructure components. This case is actually most common for Block Storage (where multiple Block Storage entries appear with different SKUs). Specifically, for the Block Storage case, you are charged for storage itself, but you are also charged for any data transfers out of Block Storage. As a result, you will see multiple "Block Storage" items listed with different SKU numbers in the Legend box. For example:
Block Storage / <SKU number 1>
Block Storage / <SKU number 2>
Block Storage / <SKU number 3>
Block Storage / <SKU number 4>
Another way of looking at this same type of data is to use the Service and Product Description grouping dimension. The Legend box is sorted in the same manner, but presents the data differently. That is, according to the actual product descriptions, versus the SKUs that these are associated with. For example:
Block Storage / Block Volume - Backup
Block Storage / Block Volume - Free
Block Storage / Block Volume - Performance Units
Block Storage / Block Volume - Storage
By default, these longer descriptions may not be visible, and so you should resize the Legend box to view them.
The Database service is also a useful example. There could be different instances of a database and you could also be charged for Block Storage within the Database service. For example, this entry could appear in the Legend for such a case:
Database / DBaaS - Attached Block Storage Volume - Standard Performance
You could also be charged in the Database service for network transfer. For example:
Database / Oracle Autonomous Data Warehouse - Exadata Storage
Charges for licensing of the application version can also occur:
Database / Database Cloud Service - Enterprise Edition High Performance
Cost and Usage reports are a good way to further slice such information you have noticed in the Cost Analysis charts. For example, in a cost report you might notice a SKU number that's associated with Compute, and also see the same SKU number that's associated with Block Storage. As a result, you may wonder if you were double-billed (though this is actually not the case). To investigate the actual cost, you can first filter the cost CSV spreadsheet by the SKU. Once you have applied a filter to the CSV using a particular SKU, you can see which services are consuming from the product/Description column. For example, a SKU could be using a lot of "Block Volume - Performance Units", but you also notice that "DBaaS - Attached Block Storage Volume" appears in this column.
When viewing a cost report, the cost/productSku and product/Description columns map to one another, and are adjacent columns in the CSV. For more information on these fields and other fields that appear in the reports, see Cost and Usage Reports.
Downloading Your Cost Details Data
From the Tab Actions menu on any Cost details tab:
- Select the Download table as CSV option to download a CSV file of the data from the current Cost details tab. In the Export Confirmation that opens, click Confirm. You can then download a CSV file with the current date included in the file name.
- Select Download current tab as PDF option to export the chart and table data to PDF. In the Export Confirmation that opens, click Confirm. You can then save a PDF file with the Cost details by date tab name, along with the current timestamp included in the PDF file name.
- Select Download chart to download a PNG image of the chart from the current Cost details tab, with the current date included in the file name. The chart image includes the legend items, and reflects the selected time range, applied filters, and grouping dimensions.
Saving Reports
Use the Report actions menu in Cost Analysis to create a saved report. You can later access the report after leaving the Console and returning to Cost Analysis, without needing to respecify your set of dates, filters, granularity, or grouping dimensions. After a report has been saved, it can later be renamed, updated, or deleted. A maximum of 10 reports can be saved.
You can create a saved report by modifying one of the predefined Cost Analysis reports, and then save your custom settings as a new report. Your new reports can have your own set of filters, grouping dimensions, granularity, and date range settings.
To save reports, ensure you also have the correct policy. See Required IAM Policy for more information.
To save a Cost Analysis report:
The new saved report is now available for future selection from the Reports menu under Saved Reports. You can also use the Scheduled Reports page to run a saved report based on a schedule. See Scheduled Reports for more information.
When the ten-report limit has been exceeded, you must select a pre-existing report from the Overwrite existing report box that you want to be overwritten with the new one.
After a report has been saved, you can rename it, reset in-progress changes, update it, or delete it.
- Select the report from the Reports menu.
- From Report actions, select Rename. The Edit report name dialog is displayed.
- In Name, enter the new report name, and click Save. A notification is displayed that the report has been updated and renamed.
- Select the report from the Reports menu.
- After making changes that you want to revert, from Report actions, select Reset. The (edited) text next to the report name disappears, to indicate that you have reset the report back to its original state.
- Click Apply to reload the chart and table data.
- Select the report from the Reports menu.
- Make the preferred changes to dates, filters, granularity, or grouping dimensions.
- From Report actions, select Update. A notification is displayed that the report has been successfully updated.
- Click Apply to reload the chart and table data.
- Select the report from the Reports menu.
- From Report actions, select Delete. A delete confirmation is displayed.
- In the confirmation, click Delete to delete the report. A notification is displayed that the report has been deleted and the associated chart and table data disappears.
- Select another report from the Reports menu or create a new custom report.
Adding Custom Tabs to Reports
By default, Cost Analysis displays time series-based charts and tabular output. With custom tabs, you can customize the reports by adding extra tabs with both chart and tabular output, based on your preferred combination of grouping dimensions.
If you navigate away from the Cost Analysis section of the Console and don't save your custom tabs to a saved report, or if you sign out and don't save them, they will not be available when you return to Cost Analysis.
The custom tab and custom report are now saved. The new tab's chart and tabular data output is available for analysis (also see Viewing and Working with the Chart Data).
For example, if you wanted to view which services were driving costs by region, select Region as the Table Rows, and Service in the Table Columns settings for the custom tab. Under Costs by Region, the X-axis of the chart would display the regions, in terms of the service usage, while the Y-axis displays the costs. Under Details, the tabular output lists each region in each row of the table, while each column displays each service's costs for the particular region.
After the custom tab is saved, you can add more tabs (up to five total per report), edit or delete the tab, or download the data from the custom tab.
Follow the same steps for adding a new custom tab. When a new tab is created, it is added automatically to the saved report you are working with.
- Select the report with your custom tabs from the Reports menu.
- Under Cost details, click the custom tab.
- If required, make any changes to dates, filters, or granularity. Grouping dimensions cannot be changed since they are determined by the custom tab settings.
- From Tab Actions, select Edit Tab. The Name, Table Rows, and Table Columns fields can be modified.
- Click Save. A notification is displayed and the custom tab data is refreshed to display your changes.
- Select the report with your custom tabs from the Reports menu.
- Under Cost details, click the custom tab.
- From Tab Actions, select Delete. A Delete Custom Tab delete confirmation is displayed.
- To delete the tab, click Delete. A notification is displayed that the tab has been deleted.
Forecasting Costs
You can use Cost Analysis to estimate future usage and consumption information, based on past usage data.
Forecasted values are just estimates based on past usage trends, and likely to differ from actual usage.
See Cost Analysis Query Fields for a description of the Cost Analysis search settings, and Viewing and Working with the Chart Data for more information on performing searches.
Forecasting is currently not supported with custom tabs. If a forecasted time range is used on the Cost details by date tab, it gets reverted to a query till <date> without forecasting.
Forecasting in Cost Analysis has the following characteristics:
- Exponential smoothing is used for forecasting.
- You need at least ten days of historical data to be able to do forecasting with Daily granularity. The date range fields (Start/End Date (UTC)) adjust accordingly to this.
- You need at least three months of historical data to do forecasting with Monthly granularity. As with Daily granularity, the date range fields (Start/End Date (UTC)) adjust accordingly.
- You can only forecast to the extent you have actual usage. For example, if you only have 15 days of historical data, you can only forecast for 15 days. If you have only four months of data, you can forecast only for four months in the future.
- The maximum limit for forecasting with Daily granularity is 93 days. The Monthly forecasting maximum limit is 12 months.
- Since there is a built-in 24-hour delay, the most recent 24 hours are always forecast. Similarly, in monthly forecasting mode, the current month is always forecast, irrespective of how far the current month has progressed.
- You can only do forecasting from continuous dates with actual usage. Namely, if today is March 26, your date range must start with at least March 24.
To view forecast costs:
- Open the navigation menu and click Billing & Cost Management. Under Cost Management, click Cost Analysis.
- Optionally, modify any search parameters, and then select Show Forecast. You can also select Show Forecast first, and then select search settings. In either case, you can view forecast data.
- Click Apply.
The chart reloads with the forecast data. For all chart types (whether Bars, Lines, or Stacked Lines), a Forecast section is displayed (in a grayed out portion) in the right-most end of the chart. In addition, a Total (includes forecast) cost total field is added to the top of the chart, after the Time Period and Cost To Date fields. Lastly, the forecast data is also displayed in the tabular view of the chart (the forecast columns are added as grayed out rows).
You can choose to save your settings, including the forecast data, as a saved report. You can also download a CSV file of the data, or a PNG file of the chart, which includes the forecast data.
Viewing Subscription Details and Costs
Tenancies can view their subscription details, depending on the type of tenancy. You can also use the Subscription ID grouping dimension to view costs in terms of a tenancy's subscription.
You can view the details of your subscription, but only for certain types of tenancies:
- If a tenancy is a parent tenancy in an organization, then a View subscription details link is available at the top of the Cost Analysis page, which allows you to view subscription details for the parent and any child tenancies.
- If a tenancy is a child tenancy in an organization, then no such link is available, since child tenancies cannot view their subscription details in Cost Analysis.
- If a tenancy is a standalone tenancy that is not part of an organization, then the View subscription details link is available. You can view subscription details, similar to parent tenancies that are in an organization, with some minor differences.
After clicking View subscription details for an eligible tenancy, the Subscription Details panel is displayed, with the details listed in tabular format. The table has the following fields:
- Subscription IDNote
For parent tenancies in an organization only. This field is not present for a standalone tenancy. - Type
- Start Date
- End Date
- Commitment (<currency>)
- Consumption (<currency>)
- Balance (<currency>)
- Days elapsed in billing
When viewing the Subscription Details panel for a parent tenancy in an organization, the first row in the table corresponds to the parent tenancy's subscription, while subsequent rows correspond to child tenancy subscriptions. The Subscription Details panel, meanwhile, for a standalone tenancy only has a single row that displays the subscription detail information for the standalone tenancy.
Viewing Costs by Subscription
You can use the Subscription ID grouping dimension to filter by a specific subscription and determine which subscription a tenancy's usage was attributed against. As a result, you can view the costs associated with a particular subscription (for the standalone tenancy case), or the costs for multiple subscriptions (for the parent tenancy with child tenancies case). The subscription IDs are indicated on the X-axis of the chart, and are also listed in the Legend box.
For example, using the default Costs by Service report, and ensuring to select Subscription ID as the grouping dimension, the Cost Analysis chart and table can display costs by one or more subscription IDs. Later you can save a custom report that focuses on such subscription ID usage.
For more information, see Cost Analysis Query Fields, Viewing and Working with the Chart Data, and Grouping Dimensions.
Viewing Cost and Usage from Virtual Machine Cluster Pluggable Databases
You can use Cost Analysis and OCI proprietary Cost Reports to view the cost and usage for pluggable databases within a virtual machine cluster.
In Cost Analysis, querying a date range before the availability of this feature returns null values.
To view pluggable database costs in Cost Analysis:
- Open the navigation menu and click Billing & Cost Management. Under Cost Management, click Cost Analysis.
- See Cost Analysis Query Fields and Viewing and Working with the Chart Data for an orientation to the query fields, the Cost Analysis interface, and information on creating reports.
- Select a preferred start and end date, and granularity.
- From Show, select Attributed cost.
- From Filters, select Tag.
- In the Tag window, select the orcl-cloud tag namespace, parent_resource_id_1 tag key, and after selecting Match any of the following, enter the virtual machine cluster OCID.
- Click Select.
- From Grouping dimensions, select Resource OCID.
- Click Apply.
The chart and table on the Cost details by date tab displays the pluggable database costs.
The chart Legend shows the parent virtual machine cluster and each pluggable database. In the chart, you can only visualize the cost data for each pluggable database returned by the report query (the parent virtual machine cluster itself doesn't appear, only the pluggable databases).
In the Details table, you can view the cost data for each pluggable database by date.
To view pluggable database costs in Cost Reports:
- Follow the instructions in Downloading a Cost or Usage Report to download the cost report.Note
Virtual machine cluster pluggable database costs aren't supported in FOCUS cost reports, and are only available in OCI proprietary cost reports. For more information, see OCI Proprietary Cost Report Schema. -
In the cost report CSV, you can filter the
tags/
column by the virtual machine cluster OCID, and thelineItem/intervalUsageStart
column by a particular date.The cost report indicates the total cost for the parent virtual machine cluster and its pluggable databases. For the parent virtual machine cluster, the total costs are shown in thecost/myCost
column. Thecost/attributedCost
andusage/attributedUsage
columns in the parent virtual machine cluster row indicate a value of zero, while the individual cost values for each pluggable database under the virtual machine cluster are split under thecost/attributedCost
andusage/attributedUsage
columns.Note
Thecost/attributedCost
andusage/attributedUsage
columns aren't present in cost reports that were generated before the availability of this feature.
Using the API
For information about using the API and signing requests, see REST API documentation and Security Credentials. For information about SDKs, see SDKs and the CLI.
Use the following operations to manage saved reports:
- Query based on different granularity, for example, MONTHLY or DAILY.
- Specify
queryType
, for example, COST, USAGE. - Filter and group by different dimension/tags, functioning like an SQL query.
- Use up to four
groupBy
parameters.
The following is a sample Usage endpoint URI that conforms to the schema:
- https://usageapi.<region>.oci.oraclecloud.com/20200107/usage
For more information about the API and to view the full list of endpoints, see the Usage API.
The Usage API supports: MONTLY, DAILY, and HOURLY granularity. All
startTime
are inclusive, and endTime
are
exclusive, the same as a Java substring.
- For HOURLY, only a maximum 36-hour time period is supported, with no more precision than an hour. This means no minutes or seconds in the input time.
-
For MONTHLY, only the first date of the month to another first date of the month is supported. For example, 2020-06-01T00:00:00Z, a maximum 12-month period.
-
For DAILY, no more precision than a day is supported, with a maximum 90-day period. You must enter this as 00:00:00. For example, 2020-06-01T00:00:00Z.
In an API response, dimension is only shown in terms of groupBy
. For
example, if "service" isn't in groupBy
, the "service" field in the
response will be empty.
Only four
groupBy
parameters can be used at a time.- If a
groupBy
list is empty, "currency" will be added intogroupBy
. - If the
queryType
is "Usage", "unit" will be add intogroupBy
. - If the
queryType
is "COST" or "empty", "currency" will be add intogroupBy
. computedAmount
works as expected only when "currency" is ingroupBy
.computedQuantity
works as expected only when "unit" is ingroupBy
.
The API can query USAGE or COST. computedQuantity
represents usage
and computedAmount
represents cost. For getting the expected usage,
you need to set queryType
to USAGE or add "unit" in
groupByKey
. This is due to the fact that usage is
aggregated/grouped correctly when grouping by unit.
Nested filtering in API requests is supported. The list of filters are evaluated by the operator. In each filter, all dimensions and tags are evaluated by the operator. Simultaneous evaluation of the filter list and dimension/tags is not supported, which means dimensions or tags and the filter list can't be non-empty at the same time.
Supported operators are AND, OR. These two filters below are equal:
"filter": {
"operator": "AND",
"dimensions": [
{
"key": "service",
"value": "compute"
},
{
"key": "compartmentPath",
"value": "abc/cde"
}
],
"tags": [
{
"namespace": "compute",
"key": "created",
"value": "string"
}
],
"filters": null
}
or
"filter": {
"operator": "AND",
"dimensions": [],
"tags": [],
"filters": [{
"operator": "AND",
"dimensions": [{
"key": "service",
"value": "compute"
}],
"tags": null,
"filters": null
}, {
"operator": "AND",
"dimensions": [{
"key": "compartmentPath",
"value": "abc/cde"
}],
"tags": null,
"filters": null
},
{
"operator": "AND",
"dimensions": null,
"tags": [{
"namespace": "compute",
"key": "created",
"value": "string"
}],
"filters": null
}
]
}
Invalid
example because dimensions and filters are non-empty at the same
time:"filter": {
"operator": "AND",
"dimensions": [{
"key": "compartmentPath",
"value": "abc/cde"
}],
"tags": [],
"filters": [{
"operator": "AND",
"dimensions": [{
"key": "service",
"value": "compute"
}],
"tags": null,
"filters": null
},
{
"operator": "AND",
"dimensions": null,
"tags": [{
"namespace": "compute",
"key": "created",
"value": "string"
}],
"filters": null
}
]
}
As mentioned previously, we only show the field in groupBy
. So you
need to add tag related fields in groupBy
. For example:
"tagNamespace", "tagKey", "tagValue"
If you add tagKey
, all items in the response will have a
tagKey
. tagKey
also can be empty even if you
add a tagKey
. This is because some of your resources don't have a
tagKey
. We suggested adding all three of these in
groupBy
, so you can see a complete tag in the response:
"tagNamespace", "tagKey", "tagValue"
If you want to filter by tag, you need to add the tag in the filter object. This can be filtered by any tagKey/Namespace/value combination of any tagKey/Namespace/value.
"tagNamespace", "tagKey", "tagValue", "service", "skuName", "skuPartNumber", "unit",
"compartmentName", "compartmentPath", "compartmentId", "platform", "region", "logicalAd",
"resourceId", "tenantId", "tenantName"
Only up to four
groupBy
parameters can be used in an API
call."tenantId"
and "tenantName"
are not currently
supported.
"service", "skuName", "skuPartNumber", "unit", "compartmentName", "compartmentPath", "compartmentId",
"platform", "region", "logicalAd", "resourceId", "tenantId", "tenantName"
"tenantId"
and
"tenantName"
are not currently supported.groupBy
compartment-related keys
("compartmentName"
, "compartmentPath"
,
"compartmentId"
) are different than the other
groupBy
keys.
To get an expected result, you must request with compartmentDepth
.
compartmentDepth
is >=1 and <=6.
groupBy
compartment means all compartments usage or costs with a
higher depth will be aggregated to the compartment with the given depth. For
example:
Root 1
B C 2
D E 3
F 4
If the depth is 1, it means all usage or costs are grouped to the root compartment.
If the depth is 2, it means all compartments with depth 2 will contain the usage or costs with all its children. In the response, the root will contain its own usage, B will aggregate (B, D, E, F), and C will contain C.
The fields will show up only when the fields are in groupBy
. Not all
fields in the response are currently available. Only the fields mentioned in Valid groupBy example are
supported.
This can be set as null. Currently not supported.
The best way to understand how the API works is checking how the Console uses the API. You can find the request body in the web browser's debug mode.
{
"tenantId": "ocid1.tenancy.oc1..<unique_ID>",
"timeUsageStarted": "2020-04-01T00:00:00.000Z",
"timeUsageEnded": "2020-07-01T00:00:00.000Z",
"granularity": "MONTHLY",
"queryType": "COST",
"groupBy": [
"tagNamespace",
"tagKey",
"tagValue",
"service",
"compartmentPath"
],
"compartmentDepth": 2,
"filter": null
}
After you make a request without any filter, you can see what the dimension/tags' value can be. Subequently, you can make a request with a filter and a correct dimension value.
{
"tenantId": "ocid1.tenancy.oc1..<unique_ID>",
"timeUsageStarted": "2020-04-01T00:00:00.000Z",
"timeUsageEnded": "2020-07-01T00:00:00.000Z",
"granularity": "MONTHLY",
"groupBy": ["tagNamespace","tagKey","tagValue", "service", "compartmentPath"],
"compartmentDepth": 2,
"filter": {
"operator": "AND",
"dimensions": [],
"tags": [],
"filters": [{
"operator": "AND",
"dimensions": [{
"key": "service",
"value": "compute"
}],
"tags": null,
"filters": null
}, {
"operator": "AND",
"dimensions": [{
"key": "compartmentPath",
"value": "abc/cde"
}],
"tags": null,
"filters": null
},
{
"operator": "AND",
"dimensions": null,
"tags": [{
"namespace": "compute",
"key": "created",
"value": "string"
}],
"filters": null
}
]
}
}
If you write a customized script, Oracle does not support or assist with debugging your script. Only the CLI, SDK, and Terraform are supported. See Command Line Interface (CLI) for more information. For example:
oci raw-request --http-method POST --target-uri https://usageapi.us-ashburn-1.oci.oraclecloud.com/20200107/usage
--request-body file:///<system_path>SimpleRequestSummarizedUsagesDetails.json
--config-file ~/Downloads/clitest.conf
SimpleRequestSummarizedUsagesDetails.json:{
"tenantId": "ocid1.tenancy.oc1..<unique_ID>",
"timeUsageStarted": "2020-03-19T17:00:00.000000-07:00",
"timeUsageEnded": "2020-03-21T00:00:00Z",
"granularity": "DAILY",
"groupBy": [],
"compartmentDepth": null,
"filter": null,
"nextPageToken": "string"
}
clitest.conf:[DEFAULT]
user=ocid1.user.oc1..<unique_ID>
fingerprint=<MAC_ID>
key_file=<system_path>/oci_api_key.pem
#tenancy=ocid1.tenancy.oc1..<unique_ID>
tenancy=ocid1.tenancy.oc1..<unique_ID>
region=us-ashburn-1
Also see the Oracle Cloud Infrastructure SDK at https://github.com/oracle/oci-java-sdk , https://github.com/oracle/oci-python-sdk.