Introduction

In this short note I want to describe how to enable Oracle Cloud Infrastructure (OCI) Monitoring using Grafana

What does it mean?

It means that you can set up a VM on Oracle Cloud Infrastructure, where you install Grafana and OCI plugin for Grafana and you can enable OCI monitoring. Therefore you can create a set of Dashboards, inside Grafana, showing, for example, CPU and Memory utilization of your VM.

What you need.

  • an OCI VM with Ubuntu 18
  • ssh access to the VM
  • Grafana installed
  • OCI plugin for Grafana installed

Grafana installation on Ubuntu 18

Grafana installation is easy. These are the steps:

Create a file /etc/apt/sources.list.d/grafana.list and add the following line to it:

deb https://packages.grafana.com/oss/deb stable main

 Add Grafana GPG key

curl https://packages.grafana.com/gpg.key | sudo apt-key add -

Update your repository

sudo apt-get update

Install Grafana

sudo apt-get install grafana

Enable Grafana server start at boot

sudo systemctl enable grafana-server.service

Start Grafana

systemctl daemon-reload
systemctl start grafana-server
systemctl status grafana-server

Enable remote access

At this point you need to enable access, from your browser, to port 3000. This is the easy way.

Open the port 3000 on the internal firewall. The easiest way is to modify the file:

/etc/iptables/rules.v4

and add the following line

-A INPUT -p tcp -m state --state NEW -m tcp --dport 3000 -j ACCEPT

then reboot the VM.

You can do this operation also using some simple command, avoiding manual editing of the file:

sudo iptables -I INPUT -p tcp -s 0.0.0.0/0 --dport 3000 -j ACCEPT
sudo service netfilter-persistent save

Then, you need to add a stateful rule to the Security list of your VCN, to enable access from Internet to port 3000. This operation can be done using OCI Web UI

This is the result (the rule is the last one)

Check Grafana

At this point you should be able to access Grafana on port 3000

http://<your public IP VM>:3000

The default password for admin is admin. Change to a more secure password (you are on Internet now!)

Enable OCI Monitoring

Install OCI Grafana plugin using this command:

sudo grafana-cli plugins install oci-datasource

At this point, if everything is OK, you should see a nice new DataSource inside Grafana: Oracle Cloud Infrastructure

 

We've almost arrived. We need only to set up some policies in OCI in order to enable Grafana OCI Monitoring plugin to access Monitoring Metrics.

If you're inside OCI (as we're assuming) the easiest way is to create a Dynamic Group, add the VM you want to monitor to it and create some policies.

First of all, you need to create a Dynamic Group we're you place the rules defining resources under monitoring. For example, in my case:

 

 

In Matching Rules, you can specify ALL the instances belonging to a Compartment, identified by its OCID. In this way whenever you add a new VM to the Compartment it is automatically added to the monitored VMs.

Second, you need to add some policies for the DynamicGroup (in my case, named GrafanaHosts), defined inside the root compartment:

 

These steps are all described, with more details and some nice animations, in this article:

https://medium.com/@nalixandru/monitoring-oracle-cloud-infrastructure-with-grafana-f0e2945d2eec

After, you should be able to configure OCI plugin in Grafana and create your Dashboards.

An example

This is an example of a Dashboard that you can create. You need only to choose the visualization format and the metrics you want to display.

 

 

 

Monitoring Oracle Autonomous DWH

(section added on December 3rd)

I have today discovered that new features have been added. For example, now you can monitor all Autonomous Database included in a compartment. Many metrics are available

For more information

https://grafana.com/blog/2019/02/25/oracle-cloud-infrastructure-as-a-data-source-for-grafana/

https://github.com/oracle/oci-grafana-plugin/blob/master/Readme.md

https://medium.com/@nalixandru/monitoring-oracle-cloud-infrastructure-with-grafana-f0e2945d2eec