5 Visualizing the Service Mesh 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's reserved for Grafana. You need this information to access the Grafana console.

  • Access the Grafana console.

  • View the default Istio dashboards to monitor and visualize the metrics that are retrieved and analyzed from Prometheus through the data source.

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 --namespace istio-system get svc grafana

    No NodePort is set up for the port on which the Grafana service is running. In this example, the port that's 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 a 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 --namespace istio-system -p '{"spec":{"type":"NodePort"}}'
  3. Verify that you see the service/grafana patched status message.

    You can now connect to Grafana through the NodePort.

  4. Enter the following command again:

    kubectl --namespace 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.

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 Getting the Grafana IP Address and Port Number.

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

Viewing Istio Dashboards

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

In this section, you access the default Istio dashboards provided with Grafana.

To display the Istio dashboards:

  1. In the Home Dashboard page, click the Search icon.

  2. A folder is displayed named Istio. Click The Istio folder.

  3. Several Istio dashboards are displayed. Click any of the dashboards to access them.