This post was originally published on this site
In September 2019 I wrote a blog post how to monitor an Oracle Cloud Infrastructure Autonomous database with Grafana plugin oci-datasource. But some weeks after publication, the plugin was not available on the Grafana page anymore. And only Oracle and Grafana had a clue why.
Now everything will be fine now. Since the 6th of October, there are two new Grafana plugins available for download. They both don’t require a Grafana enterprise account.
The first one is a successor of the former oci-datasource plugin, the second allows to get logs from OCI resources like Compute or Storage. As an infrastructure guy, let’s install the Oracle Cloud Infrastructure Metrics on an local Oracle Enterprise Linux 8 installation!
Install and configure the OCI CLI
Link: https://docs.cloud.oracle.com/en-us/iaas/Content/API/SDKDocs/cliinstall.htm
OS User oci and Installer
As OS user root, create a new user mentioned oci, change to new created user oci.
# groupadd oci # useradd oci -g oci # su - oci
Run the installer script.
$ bash -c "$(curl -L https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh)"
In this demo case, I use the default settings and the tab completion. After some seconds, all packages are installed and the OCI CLI is ready to configure.
-- Installation successful. -- Run the CLI with /home/oci/bin/oci --help
Configure the OCI CLI
If you have already a created SSH key pair from a former OCI action, then you can use it here. Otherwise this setup process creates a new private and public key for you. Take care, the public key has to be in the PEM format!
Required values to finish the setup:
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-zurich-1 |
generate a new API signing RSA key pair | Y -> only if you don’t have already an existing key pair |
key directory | /home/oci/.oci |
key name | oci_api_key_07102020 |
Run the setup.
$ /home/oci/bin/oci setup config
OCI Console API Key
The content of the created public key has to be added in OCI Console as API key – just copy and paste it. OCI Console >> Identity >> Users >> User Details >> API Keys >> Add Public Key.
How to: https://docs.cloud.oracle.com/Content/API/Concepts/apisigningkey.htm#How2
OCI CLI Configuration Test
Verify the configuration by execute a CLI command. Example to list images based on Oracle Linux.
$ export var_compartment_id= [YOUR_COMPARTMENT_OCID] $ oci compute image list --compartment-id $var_compartment_id --query "data[?"operating-system"=='Oracle Linux']".{"name:"display-name",os:"operating-system""} --output table +----------------------------------------+--------------+ | name | os | +----------------------------------------+--------------+ | Oracle-Linux-8.2-2020.09.23-0 | Oracle Linux | | Oracle-Linux-8.2-2020.08.27-0 | Oracle Linux | | Oracle-Linux-8.2-2020.07.28-0 | Oracle Linux | | Oracle-Linux-7.8-Gen2-GPU-2020.09.23-0 | Oracle Linux | | Oracle-Linux-7.8-Gen2-GPU-2020.08.27-0 | Oracle Linux | | Oracle-Linux-7.8-Gen2-GPU-2020.07.28-0 | Oracle Linux | | Oracle-Linux-7.8-2020.09.23-0 | Oracle Linux | | Oracle-Linux-7.8-2020.08.26-0 | Oracle Linux | | Oracle-Linux-7.8-2020.07.28-0 | Oracle Linux | | Oracle-Linux-7.8-2020.05.26-0 | Oracle Linux | | Oracle-Linux-6.10-2020.09.22-0 | Oracle Linux | | Oracle-Linux-6.10-2020.09.03-0 | Oracle Linux | | Oracle-Linux-6.10-2020.07.28-0 | Oracle Linux | +----------------------------------------+--------------+
OCI Console Group Policy
If your user is not part of the Administrator group, a new group and a group policy is needed which has the permissions to read tenant metrics. OCI Console >> Identity >> Groups >> Create Group.
Create the policy in the root compartment of your tenant. OCI Console >> Identity >> Policy>> Create Policy.
Install and configure Grafana and the Oracle Cloud Infrastructure Metrics Data Source Plugin
Grafana
Link: https://docs.cloud.oracle.com/en-us/iaas/Content/API/SDKDocs/grafana.htm
# wget https://dl.grafana.com/oss/release/grafana-7.2.0-1.x86_64.rpm # yum install grafana-7.2.0-1.x86_64.rpm
Start and enable the service.
# systemctl daemon-reload # systemctl enable grafana-server.service # systemctl start grafana-server.service
Don’t forget to open the firewall port 3000 for the Grafana UI.
# firewall-cmd --permanent --zone=public --add-port=3000/tcp # firewall-cmd --reload
Oracle Cloud Infrastructure Metrics Data Source Plugin
List the available OCI Grafana plugins.
# grafana-cli plugins list-remote | grep oci id: oci-logs-datasource version: 1.1.0 id: oci-metrics-datasource version: 2.0.0
Install the metric plugin.
# grafana-cli plugins install oci-metrics-datasource installing oci-metrics-datasource @ 2.0.0 from: https://grafana.com/api/plugins/oci-metrics-datasource/versions/2.0.0/download into: /var/lib/grafana/pluginsInstalled oci-metrics-datasource successfully Restart grafana after installing plugins . <service grafana-server restart>
Restart Grafana Server.
# service grafana-server restart Restarting grafana-server (via systemctl): [ OK ]
Grafana Data Source Configuration
RSA Key Configuration
Grafana needs the configuration file and the RSA Key from the user oci. One solution: as user root, copy the files and set the ownership to OS user grafana.
# cp -r /home/oci/.oci /usr/share/grafana # chown -R grafana:grafana /usr/share/grafana/.oci
Change the path to the key file in /usr/share/grafana/.oci/config.
from:
key_file=/home/oci/.oci/oci_api_key_07102020.pem
to:
key_file=/usr/share/grafana/.oci/oci_api_key_07102020.pem
Add a new Data Source
Login into the Grafana server by address <server-ip>:3000. The initial username and password is admin. It’s recommended to change the password at the first login. Add a new data source. Configuration >> Data Sources >> Add data source.
Filter by oracle and select the Oracle Cloud Infrastructure Metrics plugin.
Set Tenancy OCID, select your Default Region and set the Environment to local. Press Save & Test to verify the functionality.
Create a new Dashboard and add a new panel.
Now you can query the data, for example the VPN bandwidth for region eu-zurich1 in my personal compartment. Feel free to add new panels based on the available metrics.
Example
Summary
Great to have the Oracle Cloud Infrastructure Grafana plugins back. To get an idea, which metrics are all available, verify it in the OCI Console >> Monitoring >> Metrics Explorer. The free ADB is not available in the collected metrics. But this is a general issue.
This was a review of the first OCI plugin. In the next week I will take a deeper look into the Oracle Cloud Infrastructure Logging Data Source plugin.