<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>grafana | Spagno's Blog</title><link>/tag/grafana/</link><atom:link href="/tag/grafana/index.xml" rel="self" type="application/rss+xml"/><description>grafana</description><generator>Wowchemy (https://wowchemy.com)</generator><language>en-us</language><lastBuildDate>Wed, 01 Jan 2020 00:00:00 +0000</lastBuildDate><image><url>/images/icon_hua320044a33bf4566f6947aefcc55cba9_1117206_512x512_fill_lanczos_center_2.png</url><title>grafana</title><link>/tag/grafana/</link></image><item><title>Heketi Integrated Metrics with Prometheus and Grafana in OCP 3.11</title><link>/post/heketi-integrated-metrics-with-prometheus-and-grafana-in-ocp-311/</link><pubDate>Wed, 01 Jan 2020 00:00:00 +0000</pubDate><guid>/post/heketi-integrated-metrics-with-prometheus-and-grafana-in-ocp-311/</guid><description>&lt;p>Since I started using OCP with GlusterFS one of the bigger blocker was the lack of metrics for GlusterFS. Now we have GlusterFS 3.4.0 with heketi 7 which ships the integrated metrics endpoint for Prometheus.
Searching in our documentation, I found &lt;a href="https://redhatstorage.redhat.com/category/architects/" title="https://redhatstorage.redhat.com/category/architects/" target="_blank" rel="noopener">Architects – Red Hat Storage&lt;/a> but it doesn&amp;rsquo;t work for OCP 3.11 because the entire Prometheus framework has changed.
I found &lt;a href="https://bugzilla.redhat.com/show_bug.cgi?id=1644665" title="https://bugzilla.redhat.com/show_bug.cgi?id=1644665" target="_blank" rel="noopener">https://bugzilla.redhat.com/show_bug.cgi?id=1644665&lt;/a>  which brought me to an internal Redhat document and from here I started ordering all the pieces of the puzzle.&lt;/p>
&lt;p>In my lab I installed OCP 3.11.43 with RHGS 3.4.0 with 2 separate GlusterFS&lt;/p>
&lt;ul>
&lt;li>glusterfs&lt;/li>
&lt;/ul>
&lt;p>to provision PVC for the apps&lt;/p>
&lt;ul>
&lt;li>glusterfs_registry&lt;/li>
&lt;/ul>
&lt;p>to provision PVC for the infrastructure components&lt;/p>
&lt;pre>&lt;code>[glusterfs]
ocp-node-gluster1.example.com glusterfs_devices='[ &amp;quot;/dev/sdc&amp;quot;, &amp;quot;/dev/sdd&amp;quot; ]'
ocp-node-gluster2.example.com glusterfs_devices='[ &amp;quot;/dev/sdc&amp;quot;, &amp;quot;/dev/sdd&amp;quot; ]'
ocp-node-gluster3.example.com glusterfs_devices='[ &amp;quot;/dev/sdc&amp;quot;, &amp;quot;/dev/sdd&amp;quot; ]'
[glusterfs_registry]
ocp-node-gluster4.example.com glusterfs_devices='[ &amp;quot;/dev/sdc&amp;quot;, &amp;quot;/dev/sdd&amp;quot; ]'
ocp-node-gluster5.example.com glusterfs_devices='[ &amp;quot;/dev/sdc&amp;quot;, &amp;quot;/dev/sdd&amp;quot; ]'
ocp-node-gluster6.example.com glusterfs_devices='[ &amp;quot;/dev/sdc&amp;quot;, &amp;quot;/dev/sdd&amp;quot; ]'‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
&lt;/code>&lt;/pre>
&lt;p>I checked the Heketi metrics endpoint&lt;/p>
&lt;pre>&lt;code>[root@ocp-master1 ~]# oc get svc -n ocs-infra
NAME                           TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
heketi-db-registry-endpoints   ClusterIP   172.30.34.253   &amp;lt;none&amp;gt;        1/TCP      10h
heketi-registry                ClusterIP   172.30.17.135   &amp;lt;none&amp;gt;        8080/TCP   10h
[root@ocp-master1 ~]# curl 172.30.17.135:8080/metrics -s | head -n1
# HELP go_gc_duration_seconds A summary of the GC invocation durations.
[root@ocp-master1 ~]# oc get svc -n ocs-app
NAME                          TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE
heketi-db-storage-endpoints   ClusterIP   172.30.227.21    &amp;lt;none&amp;gt;        1/TCP      10h
heketi-storage                ClusterIP   172.30.138.116   &amp;lt;none&amp;gt;        8080/TCP   10h
[root@ocp-master1 ~]# curl 172.30.138.116:8080/metrics -s | head -n1
# HELP go_gc_duration_seconds A summary of the GC invocation durations.
[root@ocp-master1 ~]#‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
&lt;/code>&lt;/pre>
&lt;p>Prometheus uses servicemonitors, new resources introduced by the Prometheus Operator which describe the set of targets to be monitored in OCP 3.11 (more information about Prometheus Operator &lt;a href="https://coreos.com/operators/prometheus/docs/latest/user-guides/getting-started.html" target="_blank" rel="noopener">here&lt;/a>), so I had to create those objects:&lt;/p>
&lt;pre>&lt;code>[root@ocp-master1 ~]# cat heketi-infra-sm.yaml
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: heketi-infra
  labels:    k8s-app: heketi-infra
  namespace: openshift-monitoring
spec:
  endpoints:
  - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
    interval: 30s
    port: heketi
    scheme: http
    targetPort: 0
  namespaceSelector:
    matchNames:
    - ocs-infra
  selector:
    matchLabels:
      heketi: registry-service
[root@ocp-master1 ~]# oc create -f heketi-infra-sm.yaml -n openshift-monitoring
servicemonitor.monitoring.coreos.com/heketi-infra created
[root@ocp-master1 ~]#
[root@ocp-master1 ~]# cat heketi-app-sm.yaml
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: heketi-app
  labels:    k8s-app: heketi-app
  namespace: openshift-monitoring
spec:
  endpoints:
  - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
    interval: 30s
    port: heketi
    scheme: http
    targetPort: 0
  namespaceSelector:
    matchNames:
    - ocs-app
  selector:
    matchLabels:
      heketi: storage-service‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
[root@ocp-master1 ~]# oc create -f heketi-app-sm.yaml -n openshift-monitoring
servicemonitor.monitoring.coreos.com/heketi-app created
[root@ocp-master1 ~]#
&lt;/code>&lt;/pre>
&lt;p>The two selectors at line had been found in the heketi svc:&lt;/p>
&lt;pre>&lt;code>[root@ocp-master1 ~]# oc project ocs-infra
Now using project &amp;quot;ocs-infra&amp;quot;
[root@ocp-master1 ~]# oc describe svc heketi-registry
Name:              heketi-registry
Namespace:         ocs-infra
Labels:            glusterfs=heketi-registry-service
                  heketi=registry-service
...‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
[root@ocp-master1 ~]# oc project ocs-app
Now using project &amp;quot;ocs-app&amp;quot;
[root@ocp-master1 ~]# oc describe svc heketi-storage
Name:              heketi-storage
Namespace:         ocs-app
Labels:            glusterfs=heketi-storage-service
                   heketi=storage-service
...‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
&lt;/code>&lt;/pre>
&lt;p>Final, add the cluster role to the prometheus-k8s service account:&lt;/p>
&lt;pre>&lt;code>[root@ocp-master1 ~]# oc adm policy add-cluster-role-to-user cluster-reader system:serviceaccount:openshift-monitoring:prometheus-k8s -n openshift-monitoring
cluster role &amp;quot;cluster-reader&amp;quot; added: &amp;quot;system:serviceaccount:openshift-monitoring:prometheus-k8s&amp;quot;
[root@ocp-master1 ~]#‍‍‍‍‍‍
&lt;/code>&lt;/pre>
&lt;p>After about 1 minute, Prometheus loaded the new servicemonitors:
&lt;figure id="figure-targets">
&lt;a data-fancybox="" href="/post/heketi-integrated-metrics-with-prometheus-and-grafana-in-ocp-311/images/image01_hubdc518e8460738861c6421d1e826cdb8_51129_2000x2000_fit_lanczos_2.png" data-caption="targets">
&lt;img data-src="/post/heketi-integrated-metrics-with-prometheus-and-grafana-in-ocp-311/images/image01_hubdc518e8460738861c6421d1e826cdb8_51129_2000x2000_fit_lanczos_2.png" class="lazyload" alt="" width="1918" height="858">
&lt;/a>
&lt;figcaption>
targets
&lt;/figcaption>
&lt;/figure>
&lt;/p>
&lt;p>In the Grafana shipped with OCP 3.11, to have admin privileges you MUST have an user &amp;ldquo;admin&amp;rdquo; with cluster-admin cluster role. I created the user (htpasswd Identity Provider):&lt;/p>
&lt;pre>&lt;code>[root@ocp-master1 ~]# htpasswd /etc/origin/master/htpasswd admin
New password:Re-type new password:
Updating password for user admin
[root@ocp-master1 ~]#‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
&lt;/code>&lt;/pre>
&lt;p>And added it to the cluster role:&lt;/p>
&lt;pre>&lt;code>[root@ocp-master1 ~]# oc adm policy add-cluster-role-to-user cluster-admin admin
cluster role &amp;quot;cluster-admin&amp;quot; added: &amp;quot;admin&amp;quot;
[root@ocp-master1 ~]#‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
&lt;/code>&lt;/pre>
&lt;p>In the previous gdrive document you can find this mail &lt;a href="http://post-office.corp.redhat.com/archives/sme-storage/2018-October/msg00388.html" title="http://post-office.corp.redhat.com/archives/sme-storage/2018-October/msg00388.html" target="_blank" rel="noopener">http://post-office.corp.redhat.com/archives/sme-storage/2018-October/msg00388.html&lt;/a>  which contains a Grafana Dashboard for these metrics. I added some variables to manage more than 3 nodes and both GlusterFS clusters. Finally the new &lt;a href="https://drive.google.com/file/d/1kXNCS56jiQ6hX3meyWME1jc7ZlPnOI_E/view?usp=sharing" target="_blank" rel="noopener">dashboard&lt;/a> was imported:
&lt;figure id="figure-grafana">
&lt;a data-fancybox="" href="/post/heketi-integrated-metrics-with-prometheus-and-grafana-in-ocp-311/images/image02_hu31329ceddc522bd8a7741e03f5d4c9c6_112885_2000x2000_fit_lanczos_2.png" data-caption="grafana">
&lt;img data-src="/post/heketi-integrated-metrics-with-prometheus-and-grafana-in-ocp-311/images/image02_hu31329ceddc522bd8a7741e03f5d4c9c6_112885_2000x2000_fit_lanczos_2.png" class="lazyload" alt="" width="1911" height="823">
&lt;/a>
&lt;figcaption>
grafana
&lt;/figcaption>
&lt;/figure>
&lt;/p>
&lt;h2 id="please-note">Please Note&lt;/h2>
&lt;p>&lt;strong>Grafana uses ephemeral storage: if the pod is destroyed you MUST re-import this dashboard.&lt;/strong>&lt;/p>
&lt;p>Enjoy your metrics!&lt;/p></description></item></channel></rss>