Oracle Cloud Infrastructure Documentation

Grafana Plug-in

This topic provides instructions for installing, configuring, and using Oracle Cloud Infrastructure Data Source for Grafana, otherwise referenced as the Grafana Plug-in.

Grafana Plug-in Overview

Grafana is an open-source visualization and alerting tool that you can use for analytics and monitoring of time-series data (metrics). While metrics from Oracle Cloud Infrastructure Monitoring are visible in metrics charts through the Console, you can use Oracle Cloud Infrastructure Data Source for Grafana ("the Grafana Plug-in") to view metrics from resources across providers on a single Grafana dashboard.

Prerequisites for Using the Grafana Plug-in

  • An Oracle Cloud Infrastructure account.
  • A user in that account, in a security group with an IAM policy that grants necessary permissions for working with resources in the account compartments. The policy must give you access to the metric namespaces emitting metrics (such as Compute) as well as the related resources (such as a set of Compute instances). If you try to perform an action and get a message that you don’t have permission or are unauthorized, confirm with your administrator the type of access you've been granted and which A collection of related resources that can be accessed only by certain groups that have been given permission by an administrator in your organization. you should work in. Administrators: For common policies that give groups access to metrics, see Let users view metric definitions in a compartment and Restrict user access to a specific metric namespace. To authorize resources, such as instances, to make API calls, add the resources to a dynamic group through its matching rules, and then create a policy that allows that dynamic group access to metrics. To allow access across compartments, create the policy in the tenancy. Because of the concept of policy inheritance, instances in the indicated dynamic group can then access metrics in any compartment. To reduce the scope of access to a particular compartment, specify that compartment instead of the tenancy. See Let instances make API calls to access monitoring metrics in the tenancy.
  • Compute instances: To emit metrics, Compute instances must be monitoring-enabled. OracleCloudAgent software installation may also be required. For more information, see Enabling Monitoring for Compute Instances.
  • Required keys and Oracle Cloud Infrastructure IDs (OCIDs). For guidance, see Required Keys and OCIDs.

Download and Install the Grafana Plug-in

This section provides instructions for downloading and installing the Grafana Plug-in, either locally (Linux or Mac) or by Terraform script. Use Terraform script to provision a Compute instance that runs Grafana in Oracle Cloud Infrastructure.

Authentication for metric access depends on where Grafana is running. If you are running Grafana on a local machine outside Oracle Cloud Infrastructure, you must call the Monitoring API using the Command Line Interface (CLI). If you are running Grafana on the new Compute instance created by the Terraform script, use the script-generated dynamic group. If you are running Grafana on an Oracle Cloud Infrastructure Compute instance that you created, then you can add the instance to a dynamic group by configuring a matching rule. In all scenarios, you have the option of calling the API using the CLI.

Local: Download and Install the Plug-in

To install the Grafana Plug-in (Oracle Cloud Infrastructure Data Source for Grafana), see https://grafana.com/plugins/oci-datasource/installation. After installation, you're ready to configure the Grafana Plug-in.

Terraform Script: Create a Grafana environment

This section describes how to use Terraform scripts to create a Grafana environment on your virtual machine.

The Terraform scripts create a dynamic group using the name you specify, configure an IAM policy named "grafana_policy," provision a Compute instance named "TFInstance0" (in the compartment and VCN that you specify), and download and install both Grafana and the Grafana Plug-in onto the instance.

Terraform Script Prerequisites
To download and run the Terraform scripts

Configure the Grafana Plug-in

This section describes how to add the Grafana Plug-in and set up a dashboard.

To configure the Grafana Plug-in

Troubleshoot the Plug-In

If the dashboard query ("Metrics") fails to populate with options, or if you have other issues accessing metrics, then the IAM policy used to access metrics may be malformed, or it may not include all required matching rules for your dynamic group (Terraform script).

To resolve this issue, do the following.

  • Review your IAM policy to ensure that it matches prerequisites.
  • For Terraform, consider adding the following matching rule to your dynamic group: 

    matching_rule = "ANY {instance.compartment.id = '${var.compartment_ocid}'}"

  • If you updated your IAM policy, then restart the Grafana server and refresh the Grafana homepage.

Terraform: Remove the environment

If you ran the Terraform script to create a Grafana environment on your virtual machine, you may want to remove the environment after your work is done. Follow the instructions in this section to do so.

To remove your Grafana environment