Adding Grafana Dashboard in the Red Hat OpenShift Cluster
- Procedure
-
Setup CRC OpenShift cluster, For more information, see Setup CRC OpenShift Cluster.
-
To enable cluster monitoring, use the
crc config set enable-cluster-monitoring true
command and then stop and start the CRC -
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> -
Edit Grafana service using the
oc edit svc grafana
command and updatetype
fromclusterIP
toNodePort
as shown in the following section.$> oc edit svc grafana
spec:
type: NodePort -
To get the port number of Grafana, use the following command.
$> oc get svc
-
Access the Grafana UI. http://<hostname>:30052/
If you are running locally, then use http://localhost:30052/
-
Connect the Prometheus to our Custom Grafana, use the following command.
$> oc adm policy add-cluster-role-to-user cluster-monitoring-view -z grafana
-
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>
-
Navigate to Home > Connection > Data sources and select the default DS as Prometheus.
-
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.
-
-
Navigate to Home -> Dashboards. Click the New button dropdown and select Import.
-
Add Grafana ID in Import via grafana.com section, select default Data Source - Prometheus and click Load.