Oracle Cloud Infrastructure (OCI) Costs—Part One: Budgets and Forecasting

Posted in: Oracle, Technical Track

Cost is a crucial part of selecting a cloud service provider. It’s important to understand the capabilities of different providers to maintain control of your costs.

This blog post assumes the reader is familiar with OCI CLI (Command Line Interface). If you’re new to OCI CLI, I suggest you check out my earlier post to get started on OCI CLI: https://blog.pythian.com/the-ocidtab-a-solution-to-make-oci-cli-scripting-easier.

Note: The examples I’m showing in this post use the OCI CLI (Command Line Interface). I’m avoiding screen shots because the UI for cloud consoles keeps changing over time; the CLI is my first preference of querying any kind of cloud metrics as it’s repeatable in its usage. CLI commands, and the resulting output can also be incorporated into other scripts and ingested into other systems—for example, for long-term capture, trending over time or third-party reporting.

Cost management

Cost management is typically the primary concern of cloud administrators who are responsible for controlling cloud costs. While cost management can be delegated to other OCI Console users, for the purpose of this post, I’m assuming that an administrator user is responsible for the cloud spend costs. 

You can only do cost management and spend analysis in the home region where Oracle creates your tenancy, however, you can access resource usage and costs from all regions.

Budgets

As the name implies, budgets keep track of how much you can spend on resources.

Oracle Cloud Documentation describes it here in a more technical way: 

“A budget can be used to set soft limits on your Oracle Cloud Infrastructure spending. You can set alerts on your budget to let you know when you might exceed your budget, and you can view all of your budgets and spending from one single place in the Oracle Cloud Infrastructure console.”

OCI Documentation indicates we can set the limit of our budget and set up alerts accordingly (I’ll explain how to set up the alerts in a subsequent section of this post).

Forecasting

To set up forecasting you first need to configure a budget. You can configure your budget under “Cost Management” in the OCI Console as follows:

  • Cost Management > Budgets > Create Budget  to create or update the required budget.
  • Cost Management > Budgets > Create Budget > Create Budget Alert Rule to configure the email alerts according to the required thresholds.

Reminder: You can only run this in the home region—the CLI profile for which can be specified under ~.oci/config.

Here’s an example of budget alert rules already defined through the web console:

$ oci budgets alert-rule list --budget-id $BUDGET_OCID \
--query "data [*].{\"message\":\"message\",\"recipients\":\"recipients\",\"threshold-type\":\"threshold-type\",\"type\":\"type\"}" \
--profile $HOME-PROFILE --output table --all

Budget alert rules.

Why budgets and forecasts are important

The single most important part of budgeting is to get a forecast for spending. For example, you might have added more OCI resources for a temporary project then missed removing them. This would keep adding to your costs.

Below is how you can identify your current costs using the OCI CLI. Let’s assume the configured budget is $900; the forecast below is within the configured budget:

$ oci budgets budget list \
--query "data [*].{\"actual-spend\":\"actual-spend\",\"forecasted-spend\":\"forecasted-spend\",amount:amount,\"time-updated\":\"time-updated\"}" \
-c $TENANCY_OCID --profile $HOME-PROFILE --output table

Configured budget forecast.

If you create more compute instances without budgeting for them, you could see something like this the next day, where the forecast is above the configured budget:

Forecast above configured budget.

This essentially indicates that your cloud tenancy will spend more than forecasted. There are different ways to receive the forecast alerts. One is by OCI-configured thresholds. You can also be creative by having a shell/python script retrieve the OCI CLI forecast as a mail alert to allow administrators to keep track of forecasting on a daily basis.

Why forecasting is more important than spend analysis

OCI provides monitoring metrics on historical spend analysis, but this only shows what you’ve already spent. The smart move is to identify and reduce costs before you actually incur them, hence, forecasting is an important tool for an OCI cloud administrator to have an eye on so they can keep the cloud owner—who’s actually paying for the tenancy—updated on the associated costs. 

The next part of this series will provide a better understanding of historical spend analysis.

If you have any questions or thoughts, please feel free to leave them in the comments!

email
Want to talk with an expert? Schedule a call with our team to get the conversation started.

About the Author

Abhilash Kumar is a Pythian Laureate and a Reliability Engineer , he has a rich Oracle Database experience and has implemented cloud migrations projects to Oracle Cloud Infrastructure (OCI). Abhilash has worked as a BigQuery Developer for GCP projects and has been involved with projects on Amazon RDS. He has a sound scripting techniques and always looks to automate things. Abhilash believes in sharing experiences by giving back to the community and is regularly involved with colleges to conduct Technical Bootcamps and is an active participant in AIOUG. Feel free to reach out to Abhilash on Social Media.

No comments

Leave a Reply

Your email address will not be published. Required fields are marked *