The software described in this documentation is either no longer supported or is in extended support.
Oracle recommends that you upgrade to a current supported release.

Chapter 3 Using Grafana

When Grafana is deployed, a data source is configured for a Prometheus time-series database. A data source is Grafana's link to the database. Because this data source is configured, Grafana can retrieve and analyze the metrics of a Kubernetes cluster that are gathered and stored in the Prometheus database.

In this chapter, you learn how to:

  • Get the IP address of the node on which Grafana is deployed and the port number that is reserved for Grafana. You need this information to access the Grafana console.

  • Access the Grafana console.

  • Create a dashboard in Grafana to monitor and visualize the metrics that are retrieved and analyzed from Prometheus through the data source.

  • Formulate a query for the dashboard to fine-tune how the metrics for Prometheus appear in Grafana.

3.1 Getting the Grafana IP Address and Port Number

In this section, you get the IP address of the node on which Grafana is deployed and the port number for Grafana.

  1. At the prompt of the machine where you installed the Istio module, enter the following command:

    kubectl -n istio-system get svc grafana

    There is no NodePort set up for the port on which the Grafana service is running. In this example, the port that is reserved for Grafana is 9090.

    NAME         TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)      AGE
    grafana      ClusterIP   10.104.245.12   <none>        9090/TCP     6d1h

    A NodePort is an open port on every node of your Kubernetes cluster. By opening a NodePort for Grafana, Kubernetes transparently routes incoming traffic on the NodePort to the Grafana service. The NodePort is assigned from a pool of cluster-configured NodePort ranges (typically 30000–32767).

  2. Enter the following command to set up a NodePort for the Grafana service:

    kubectl patch svc grafana -n istio-system -p '{"spec":{"type":"NodePort"}}'
  3. Verify that you see the service/grafana patched status message.

    You can now connect to Grafana via the NodePort.

  4. Enter the following command again:

    kubectl -n istio-system get svc grafana

    This time, you can see that a NodePort is set up for the Grafana container. You can use this NodePort to connect to the service.

    NAME         TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)      AGE
    grafana      ClusterIP   10.104.245.12   <none>        9090/30921   6d1h

    In this example, the NodePort is 30921, which maps to the service port of 9090.

  5. Enter the following command to get the IP address of either a control plane node or the IP address of the worker node on which the Grafana container is running:

    ip addr

Make a note of the IP address and NodePort that you obtained in this procedure because you need these values to access the Grafana console.

3.2 Accessing the Grafana Console

As part of deploying Grafana, a user account is created, and the Admin role is assigned to the account. This account has superuser permissions in Grafana and can create dashboards and generate queries for the dashboards.

In this section, you access the Grafana console.

  1. Open a web browser.

  2. In the Address field, enter http://[IP_address]:[NodePort]

    You obtained the IP address and NodePort in Section 3.1, “Getting the Grafana IP Address and Port Number”.

After you provide the Grafana URL, you are taken to the Home Dashboard page. This page provides a workflow to help you configure Grafana, including creating a dashboard in Grafana and generating a query for the dashboard.

3.3 Creating a Dashboard

In Grafana, a dashboard is how you monitor and visualize the metrics that are retrieved from a data source such as Prometheus. The dashboard is a grouping of one or more panels, prearranged into rows.

In this section, you create a dashboard and select the Graph panel for it. The Graph panel is the main panel in Grafana, and has a rich set of graphing options.

As part of creating your dashboard, you use the query editor feature to formulate a query for the dashboard. A query is used to fine-tune how the metrics for Prometheus appear in Grafana. For this procedure, you specify the prometheus_engine_query_duration_seconds query, which allows Grafana to graph the metrics that Prometheus collects about itself.

  1. In the Home Dashboard page, click the Create your first dashboard icon.

  2. In the New dashboard page, click the Choose Visualization icon.

  3. In the Visualization field, enter Graph.

  4. Click the Queries icon. This icon appears to the left of the Visualization field and looks like a database.

  5. In the Query field, select the Prometheus data source that was added as part of deploying Grafana.

  6. In the query editor field, which appears to the right of the Metrics drop-down menu, enter the prometheus_engine_query_duration_seconds query, and then click the Disable/enable query button. This button appears to the right of the query that you entered and looks like an eye.

  7. Verify that data associated with the metric appears, and then click Save dashboard.

  8. In the Save As dialog box, give the dashboard a new name, select a folder location for the dashboard, and then click Save.

  9. Verify that you see the Dashboard saved status message and a graph that displays information about the metric that you entered.