- In the Red Hat OpenShift Container Platform console, select Operators > OperatorHub and search for the Grafana operator that is provided by Red Hat OpenShift.
- Install the Grafana operator for the openshift-user-workload-monitoring namespace.
- Create an instance of Grafana.
- Select Operator > OperatorHub > Grafana Operator and then select the Grafana tab.
- Click Create Grafana.
- On YAML tab, enter the following text:
apiVersion: integreatly.org/v1alpha1 kind: Grafana metadata: name: mas-grafana namespace: openshift-user-workload-monitoring spec: ingress: enabled: true dataStorage: accessModes: - ReadWriteOnce size: 10Gi class: ocs-storagecluster-cephfs config: log: mode: "console" level: "warn" security: admin_user: "root" admin_password: "secret" auth: disable_login_form: False disable_signout_menu: True auth.anonymous: enabled: True dashboardLabelSelector: - matchExpressions: - {key: app, operator: In, values: [grafana]}
A route is created, and the public URL is included in that route definition in the openshift-user-workload-monitoring namespace project.
- Remember to update the subscription.yaml file and add the following configuration so that Grafana scans for the dashboard across the whole cluster:
Config: env: - name: "DASHBOARD_NAMESPACES_ALL" value: "true"
After an update, the subscription.yaml file looks like the following:apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: name: grafana-operator namespace: "{{ grafana_namespace }}" labels: operators.coreos.com/grafana-operator.{{ grafana_namespace }}: '' spec: channel: v4 installPlanApproval: Automatic name: grafana-operator source: community-operators sourceNamespace: openshift-marketplace config: env: - name: "DASHBOARD_NAMESPACES_ALL" value: "true"
- Run the following command to grant the user permission.
oc adm policy add-cluster-role-to-user cluster-monitoring-view -z grafana-serviceaccount
- Run the following command to obtain the BEARER_TOKEN.
- oc serviceaccounts get-token grafana-serviceaccount -n openshift-user-workload-monitoring
- Create the GrafanaDataSource, which points to the Prometheus instance that you installed earlier.
- Select the Grafana Operator > Installed operators > GrafanaDataSource tab.
- Enter the following text and replace the
${BEARER_TOKEN}
value with the value that you obtained in a previous step.apiVersion: integreatly.org/v1alpha1 kind: GrafanaDataSource metadata: name: prometheus-grafanadatasource namespace: openshift-user-workload-monitoring spec: datasources: - access: proxy editable: true isDefault: true jsonData: httpHeaderName1: 'Authorization' timeInterval: 5s tlsSkipVerify: true name: Prometheus secureJsonData: httpHeaderValue1: 'Bearer ${BEARER_TOKEN}' type: prometheus url: 'https://thanos-querier.openshift-monitoring.svc.cluster.local:9091' name: prometheus-grafanadatasource.yaml
Reference Link : https://www.ibm.com/docs/en/mas-cd/continuous-delivery?topic=dashboards-installing-configuring-grafana