Terraform is probably already the de-facto standard for cloud deployment. I use it on a daily basis deploying and destroying my tests and demo setups ... Read More
Keep Your Money in Check on the Oracle Infrastructure Cloud
With any cloud environment, it becomes easy to start a new resource whether it is a database or a compute instance. It is like walking to a giant department store with unlimited credit on your card. Too often we find that somebody has fired a new instance and left it forgotten to run over holidays or weekend. Sometimes it is left by purpose to run some tasks but in many cases, it is just forgotten. That ease of consumption of cloud resources can lead to unexpectedly high bills by the end of the month. It would be very much helpful to have some kind of visibility and control of our spendings there. In the Oracle Cloud Infrastructure (OCI), we have some tools and ways how to be notified about the usage of the resources. In this post, I am going to talk about the budget tool and monitoring.
Let’s start from the budget control. In Oracle Cloud Infrastructure you can create a budget for a compartment and setup notifications to alert you if you are too close to the budget limit or exceeding it. Let me show how it works for me. When I setup a new project whether it is a test or POC in the Oracle Cloud Infrastructure (OCI), I create a new compartment for that. In our case we are going to use the “Gleb” compartment. Let’s assume that we have already resources running there and need to limit our monthly expenses having $75 as the max budget. We need to go to the “Billing->Budgets” under “Governance and Administration” section in our OCI console.
There we are creating our budget with target max money to allow to spend.
And we can also setup the notification rule to email as if, for example, the spent money exceeds 85% of our budget.
After setting the budget it will be automatically updated after a while and if you have crossed the threshold you get the email. Here is an example of such email.
It definitely helps to be notified if you going over of planned expenses but what if you want to check yourself or your developers and have a reminder if some VMs have been left running on the weekend or were not shut down by the end of the day.
In such case the OCI monitoring can help to get some kind of alert. To enable it for a compute resource we go to the Monitoring page to the “Alarm definitions”
There we can create an alarm to notify us if CPU activity in the compartment is greater than 0.
After choosing the namespace and the metric
we setup the trigger rule condition to alert us if the CPU is greater than 0.
After that we need only define a topic for the notification or create a new one where we define our email or https for “PagerDuty” integration.
A couple of words in the end. The budget helps to keep the expenses in check and the monitoring may be useful as a reminder to shut down instances you don’t use. You may suppress the alarm to notify you only in certain hours and also repeat the notification. What I didn’t find was how to enable the same monitoring for database service. It was not yet among the namespaces. I tried different ways but didn’t find a fully reliable setup and decided to use VCN monitoring for any traffic. This is the current state in the Toronto region as of early May 2019. By the time you read this post, additional metric namespaces including DBCS metrics, may already exist.