The Oracle Cloud Infrastructure (OCI) offers several monitoring metrics for each service. Its UI is efficient but not the most fancy display one can have.
Grafana, on the other end, not only offers better display capabilities but it also:
“allows you to query, visualize, alert on and understand your metrics no matter where they are stored. Create, explore, and share dashboards with your team…”
There are several pages out there to help out with setting this all up. This post is to document my experience.
Step 1: Create a VM
https://github.com/oracle/oci-grafana-plugin/blob/master/docs/linuxoci.md
Create a Linux Virtual Machine with public access to the internet (VCN with the proper ingress ports open)
Step 2: Add Policies for Grafana
https://github.com/oracle/oci-grafana-plugin/blob/master/docs/linuxoci.md
This policy + the dynamic groups are crucial – do not skip this step.
Policy at root level.
allow dynamicgroup grafana to read metrics in tenancy
allow dynamicgroup grafana to read compartments in tenancy
Dynamic group to allow access to the instance where Grafana will be installed
All {instance.id = 'ocid1.instance.oc1.eu-frankfurt-1.antheljxxxxxxxxxxxxx'}
Step 3: Install Grafana
https://grafana.com/docs/grafana/latest/installation/rpm/
sudo yum update
sudo vi /etc/yum.repos.d/grafana.repo
[grafana]
name=grafana
baseurl=https://packages.grafana.com/enterprise/rpm
repo_gpgcheck=1
enabled=1
gpgcheck=1
gpgkey=https://packages.grafana.com/gpg.key
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
sudo yum install grafana-enterprise
Start Server
sudo systemctl daemon-reload
sudo systemctl start grafana-server
sudo systemctl status grafana-server
Step 4: Install OCI Metrics Plugin
This part caused me some trouble, mainly because there are 2 OCI plugins, one of which is deprecated…and guess what, that was the one I tried to install 🙂
The issue with the above plugin is that it allows to be installed, but then on a later stage it does not allow to create a data source.
Once you have the correct installation command all is solved. Refer to the proper plugin page here.
grafana-cli plugins install oci-metrics-datasource
For Grafana 7 there is an extra step:
Go to – /etc/grafana/grafana. ini
[plugins]
;enable_alpha = false
;app_tls_skip_verify_insecure = false
allow_loading_unsigned_plugins = "oci-datasource"
The instructions also refer to the old plugin. Add instead “oci-metrics-datasource”
allow_loading_unsigned_plugins = "oci-metrics-datasource"
Step 5: Create an SSH tunnel
Grafana is now running, but it’s not possible to access the dashboard locally.
For that we need to create an ssh tunnel.
sudo ssh opc@<public_IP_of VM> -i /home/daniel/sshkeys/ssh_key -L 3000:localhost:3000
The instructions mention the need to create a tunnel but they omit the need to specify the SSH key in the port forwarding command. This is the private key paired with the public key used to create the VM.
Once the tunnel is enabled you can open Grafana at localhost:3000 with user admin and password admin.
Go to Add Data Source, and search for OCI Metrics.
Configure accordingly.
And that’s it. At this point we can create panels and dashboards using the metrics and dimensions available for the OCI resources.
Above is a very simple screen that shows me all the REST requests made against the Oracle Integration Cloud for a certain connection. Very niche report I know.
Below you can find something visually more interesting, which was taken from the github repository here.
Conclusion
In this post I covered my experience following the setup of the necessary steps to configure Grafana for the Oracle Cloud Infrastructure. This process does not take that much time. Granted that I found a couple of tricky parts ( deprecated plugin for example), but overall it was quick.
If your organization already have Grafana in-house, then this configuration is even faster and it allows for monitoring consolidation.