Adding Grafana Dashboard in the Red Hat OpenShift Cluster

    Procedure
  1. Setup CRC OpenShift cluster, For more information, see Setup CRC OpenShift Cluster.

  2. To enable cluster monitoring, use the crc config set enable-cluster-monitoring true command and then stop and start the CRC

  3. Use the following commands to install Grafana.

    $> helm repo add grafana https://grafana.github.io/helm-charts
    
    $> helm repo update
    $> helm install grafana grafana/grafana --set securityContext.runAsUser=Null,securityContext.fsGroup=Null -n <namespace>
  4. Edit Grafana service using the oc edit svc grafana command and update type from clusterIP to NodePort as shown in the following section.

    $> oc edit svc grafana
    spec:
    type: NodePort
  5. To get the port number of Grafana, use the following command.

    $> oc get svc
  6. Access the Grafana UI. http://<hostname>:30052/

    If you are running locally, then use http://localhost:30052/

  7. Connect the Prometheus to our Custom Grafana, use the following command.

    $> oc adm policy add-cluster-role-to-user cluster-monitoring-view -z grafana
  8. The bearer token for the service account is used to authenticate access to Prometheus in the openshift-monitoring namespace. Use the following command to display the token.

     $> oc create token grafana --duration=8760h -n <namespace>
  9. Navigate to Home > Connection > Data sources and select the default DS as Prometheus.

  10. Add the following values to connect with Prometheus:

    • Prometheus server URL: https://thanos-querier.openshift-monitoring.svc.cluster.local:9091

    • In Auth section, enable the Skip TLS Verify.

    • In Custom HTTP Headers section, type Header as Authorization and value as for example "Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6Ik9ILThhblJjdTlqU ..........".

    • Click Save and Test. Check it should be successful.

  11. Navigate to Home -> Dashboards. Click the New button dropdown and select Import.

  12. Add Grafana ID in Import via grafana.com section, select default Data Source - Prometheus and click Load.