Grafana is a popular technology that makes it easy to visualize metrics. The Oracle Cloud Infrastructure Data Source for Grafana is used to extend Grafana by adding OCI as a data source. The plugin enables you to visualize metrics related to a number of OCI resources: Compute, Networking, Storage, and custom metrics.
This walkthrough is intended for use by people who would like to deploy Grafana and the OCI Data Source for Grafana on a virtual machine in OCI.
Make sure you have access to the Monitoring Service and that metrics have been enabled for the resources you are trying to monitor.
Provision an Oracle Linux virtual machine in OCI connected to a Virtual Cloud Network with access to the public internet. If you do not already have access to a Virtual Cloud Network with access to the public internet you can navigate to Virtual Cloud Networks under Networking and click Create Virtual Cloud Network. Choosing the CREATE VIRTUAL CLOUD NETWORK PLUS RELATED RESOURCES
option will result in a VCN with an Internet Routing Gateway and Route Tables configured for access to the public internet. Three subnets will be created: one in each availability domain in the region.
After creating your VM, the next step is to create a dynamic group used to group virtual machine or bare metal compute instances as “principals” (similar to user groups).
Next, create a policy named “grafana_policy” in the root compartment of your tenancy to permit instances in the dynamic group to make API calls against Oracle Cloud Infrastructure services. Add the following policy statements:
-
allow dynamicgroup grafana to read metrics in tenancy
-
allow dynamicgroup grafana to read compartments in tenancy
To install OCI Metrics Plugin make sure you are running Grafana 8** or above. The latest version of the plugin 5.x.x is available on Grafana Catalogue. Go to Administration on main Grafana menu, and choose plugin. Then you can search for oracle and you will find the plugin:
Click on the metrics plugin to install. The plugin will be installed into your Grafana plugins directory, which by default is located at /var/lib/grafana/plugins. Here is more information on the CLI tool.
Alternatively, you can manually download the .tar file and unpack it into your /grafana/plugins directory. To do so, change to the Grafana plugins directory: cd /usr/local/var/lib/grafana/plugins
. Download the OCI Grafana Plugin: wget https://github.com/oracle/oci-grafana-plugin/releases/download/<v.version#>/plugin.tar
. Create a directory and install the plugin: mkdir oci && tar -C oci -xvf plugin.tar
and then remove the tarball: rm plugin.tar
.
Additional step for Grafana 7. Make sure plugin version is <= 2.2.4 . Open the grafana configuration grafana.ini file and add the
allow_loading_unsigned_plugins = "oci-datasource"
in the plugins section.
Example
[plugins]
;enable_alpha = false
;app_tls_skip_verify_insecure = false
allow_loading_unsigned_plugins = "oci-datasource"
To start the Grafana server, run: sudo systemctl start grafana-server
.
Navigate to the Grafana homepage at http://localhost:3000.
The next step is to configure the plugin.
You can use a manual configuration or a programatic configuration. In case you want to use the datasource.yaml based plugin configuration you can refers to this document: Data source configuration using yaml file
To find the IP address of the newly-created instance, navigate to Compute > Instances > [Your Instance]. The Public IP address is listed under the Primary VNIC Information section. Connect to Grafana via port forward by running ssh opc@[Instance Public IP] -L 3000:localhost:3000
.
Navigate to the Grafana homepage at http://localhost:3000.
Log in with the default username admin
and the password admin
. You will be prompted to change your password. Click Skip or Save to continue.
On the Home Dashboard click the gear icon on the left side of the page.
Click Add data source.
Choose Oracle Cloud Infrastructure Metrics as your data source type.
For Authentication Provider choose OCI Instance (please note that multitenancy mode is not yet supported with OCI Instance as Authentication Provider).
You do not need to configure the Cross Tenancy OCID, unless you want to use the Cross Tenancy queries using instance principals and AssumeRole capability of OCI, in case you want to redirect metrics queries to another different Tenancy which is allowed to receive queries from an endorsed tenancy. When the user provides a custom tenancy OCID, the plugin will use this value instead of the default tenancy taken from the instance to direct metric queries across all plugin functions (dashboard, alert, explore, and test). More information on AssumeRole in OCI is available here: https://blogs.oracle.com/cloud-infrastructure/post/cross-tenancy-access-assumerole-in-oci
Click Save & Test to return to the home dashboard.
Check out how to use the newly installed and configured plugin in our Using Grafana with Oracle Cloud Infrastructure Data Source walkthrough.