This post was originally published on this site

Since the end of February there is a new Grafana plugin for Oracle Cloud Infrastructure available. With this plugin we can access and monitor OCI metrics and data. Grafana is an open-source platform for data visualization and monitoring. This blog post shows you how to install and configure the Grafana plugin based on the Oracle blog entry on an Oracle Enterprise Linux 7 server.

The OCI Grafana Plugin is a nice solution for companies who don’t have a full stack infrastructure monitoring environment up and running like the Enterprise Manager EM13c. But who want to know how their machines in the Oracle Cloud Infrastructure are performing.

Steps to configure the OCI Grafana Plugin

  1. Install and configure the Oracle Cloud Infrastructure CLI – by download or by YUM install
  2. Configure Group, User and Policy in Oracle Cloud Infrastructure Console
  3. Install Grafana and the OCI Plugin
  4. Create a new Dashboard based on OCI Metrics

Machine Requirements

The server needs access to the internet.

Install and configure the Oracle Cloud Infrastructure CLI

Method 1 – Download

In this step, the software will be installed an configured. The new created SSH public key has to be added in the OCI console for further actions.

As OS user root we create a new user for OCI actions. 

# groupadd oci
# useradd oci -g oci
# passwd oci

Login as user oci, execute the CLI download and installation script. Answer questions with Y / Enter to get the default installation.

$ bash -c "$(curl -L"

Default values:

installation directory /home/oci/lib/oracle-cli
executable directory /home/oci/bin
OCI scripts /home/oci/bin/oci-cli-scripts
shell/tab completion Y
path to rc file /home/oci/.bashrc


After the successful CLI installation, you have to configure it.

$ /home/oci/bin/oci setup config

Based on your OCI account, these information are required – let the config and key location on default values.

config location /home/oci/.oci/config
user OCID OCI > Identity > Users > [YOUR_USER] > OCID
tenancy OCID OCI > Administration > Tenancy Details > [YOUR_TENANCY] > OCID
region choose your region, e.g. eu-frankfurt-1
generate a new key pair Y
key directory /home/oci/.oci
key name oci_api_key


Test the CLI configuration – example to list all compartments in your tenant.

/home/oci/bin/oci iam compartment list --all | grep name
"name": "Compartment_Trivadis_BDS_MBg",
"name": "ManagedCompartmentForPaaS"

Show the content of the public key to add it in the OCI console to your user which you want to work with. Attention: Three different API keys are the limit!

# cat /home/oci/.oci/oci_api_key_public.pem
-----END PUBLIC KEY-----


Attention: Be sure that you add the public key to the user which you have used for the CLI configuration!

Method 2 – YUM Repository

Thanks to Sergio Leunissen from Oracle for his input, the Python SDK and oci utilities are is available in the YUM repository too and ready to install. Take a look at his blog post to see how to work with the Python SDK and OCI metadata:

Enable the repository

# yum-config-manager --enable ol7_developer

Show the OCI package information

# yum info python-oci-cli
Loaded plugins: langpacks, ulninfo
Available Packages
Name        : python-oci-cli
Arch        : noarch
Version     : 2.5.3
Release     : 1.el7
Size        : 670 k
Repo        : ol7_developer/x86_64
Summary     : Oracle Bare Metal Cloud Services CLI client
URL         :
License     : Apache2.0
Description : Python SDK for Oracle Bare Metal Cloud Services command line client utilities.

Configure Group, modify User and add a Policy in Oracle Cloud Infrastructure Web Interface

A new group is created for a better access control.


Create a new OCI group called Grafana. OCI > Identity > Groups.

Modify User

Add the selected user to the group – for example this is my user.

Add a Policy

Create a new policy called GrafanaPolicy. OCI > Identity > Policies with these two statements.

allow group grafana to read metrics in tenancy
allow group grafana to read compartments in tenancy

Install Grafana and the OCI Plugin

Login as user root and install the software.

# wget 
# yum localinstall grafana-6.0.0-1.x86_64.rpm

Enable auto start and start the Grafana server manually.

# systemctl enable grafana-server.service
# systemctl daemon-reload
# systemctl start grafana-server

Enable port 3000 (Grafana default port in firewall – the port can be changed in /etc/grafana/grafana.ini) to provide web access to Grafana.

# firewall-cmd --permanent --zone=public --add-port=3000/tcp
# firewall-cmd --reload
# firewall-cmd --permanent --zone=public --list-ports

Install the oci-datasource plugin.

# grafana-cli plugins install oci-datasource
# service grafana-server restart

The Grafana plugin directorya with the installed plugin.

# ls -la /var/lib/grafana/plugins
total 0
drwxr-xr-x. 3 grafana grafana 28 Mar 4 12:26 .
drwxr-xr-x. 4 grafana grafana 50 Mar 4 12:39 ..
drwxr-xr-x. 3 root root 18 Mar 4 12:26 oci-datasource

Grafana needs the configuration file and the SSH Key from the user oci. As user root, copy the files and modify the permissions.

# cp -r /home/oci/.oci /usr/share/grafana
# chown -R grafana:grafana cd

Change the path to the key file in /usr/share/grafana/.oci/config.

# vi /usr/share/grafana/.oci/config





Create a new Dashboard based on OCI Metrics

Login into Grafana with [SERVERNAME]:3000. Username and password are admin/admin. Please change your password after first login.

Add data source

Select Oracle Cloud Infrastructure

Configure the Data Source

Fill in your tenancy OCI, region and set Environment = Local. Test the connection. For troubleshooting see Grafana logfile in /var/log/grafana.

Create a new Dashboard and Add Query

Create a Query to visualize Data

In this dashboard example I used the region FRA, my compartment, the namespace oci_blockstorage and the metric VolumeWriteOps.

Available Metrics

For instance monitoring like CPU or Memory you have to enable the metric collection first and install the OCI Cloud Agent that the value is available in the namespace. Example, there are eight metrics are available for my compute instance. Learn more about metrics and monitoring in the OCI documentation here:


The OCI Grafana plugin is a nice solution to visualize cloud environments based on Open Source software. Take care that Grafana needs access to the OCI CLI SSH information for the Oracle Cloud Infrastructure connection.