<p>I have a K8s 1.7 cluster using <strong>vSphere</strong> as persistent storage provider. I have also deployed <strong>Prometheus</strong>, <strong>node_exporter</strong> and <strong>kube-state-metrics</strong>.<p>
I'm trying to find a way to monitor a persistent volume's usage using <strong>Prometheus</strong>. I have added custom labels to some PVs, eg. <code>app=rabbitmq-0</code>, etc. </p>

<p>How can I combine <code>kube_persistentvolume_labels</code> with <code>node_filesystem_size</code> metrics so that I can query PV usage using my custom label?</p>

<p>PS.<br>
I know that K8s 1.8 directly exposes these metrics from kubelet as mentioned in <a href="https://stackoverflow.com/questions/44718268/how-to-monitor-disk-usage-of-kubernetes-persistent-volumes">How to monitor disk usage of kubernetes persistent volumes?</a> but currently a cluster upgrade is not an option.</p>

Jedi6
<p>There are cases when hostpath cannot be mount to pod or node will not be accessible to a project (namespace) in that case node exporter cannot be deployed, in such cases <a href="https://github.com/mnadeem/volume_exporter" rel="nofollow noreferrer">volume_exporter</a> would be useful.</p>
<p>You can just add it as a side car</p>
<pre><code>      - name: volume-exporter
      image:  mnadeem/volume_exporter
      imagePullPolicy: &quot;Always&quot;
      args:
        - --volume-dir=prometheus:/prometheus
      ports:
      - name: metrics-volume
        containerPort: 9888
      volumeMounts:
      - mountPath: /prometheus
        name: prometheus-data
        readOnly: true
</code></pre>
<p>It will generate the metrics</p>
<pre><code>        # HELP volume_bytes_free Free size of the volume/disk
        # TYPE volume_bytes_free gauge
        volume_bytes_free{volume_name=&quot;bin&quot;,volume_path=&quot;/bin&quot;} 4.341569536e+10
        volume_bytes_free{volume_name=&quot;etc&quot;,volume_path=&quot;/etc&quot;} 4.341569536e+10
        # HELP volume_bytes_total Total size of the volume/disk
        # TYPE volume_bytes_total gauge
        volume_bytes_total{volume_name=&quot;bin&quot;,volume_path=&quot;/bin&quot;} 6.391887872e+10
        volume_bytes_total{volume_name=&quot;etc&quot;,volume_path=&quot;/etc&quot;} 6.391887872e+10
        # HELP volume_bytes_used Used size of volume/disk
        # TYPE volume_bytes_used gauge
        volume_bytes_used{volume_name=&quot;bin&quot;,volume_path=&quot;/bin&quot;} 2.050318336e+10
        volume_bytes_used{volume_name=&quot;etc&quot;,volume_path=&quot;/etc&quot;} 2.050318336e+10
        # HELP volume_exporter_build_info A metric with a constant '1' value labeled by version, revision, branch, and goversion from which volume_exporter was built.
        # TYPE volume_exporter_build_info gauge
        volume_exporter_build_info{branch=&quot;&quot;,goversion=&quot;go1.15&quot;,revision=&quot;&quot;,version=&quot;&quot;} 1
        # HELP volume_percentage_used Percentage of volume/disk Utilization
        # TYPE volume_percentage_used gauge
        volume_percentage_used{volume_name=&quot;bin&quot;,volume_path=&quot;/bin&quot;} 32.07688208958619
        volume_percentage_used{volume_name=&quot;etc&quot;,volume_path=&quot;/etc&quot;} 32.07688208958619
</code></pre>
<p>Refer <a href="https://github.com/mnadeem/volume_exporter/wiki/Running" rel="nofollow noreferrer">this</a> for more details</p>
<p>Disclaimer : I am the owner</p>
