csi-cephfs: how can I get ceph storage cluster available capacity from kubernetes

226 views Asked by At
  1. My goal is to get the capacity of ceph cluster by ceph-csi in kubernetes

  2. Same as the command in ceph 'ceph -s' usage: 10 Gib used, 12GiB /22 GiB avail

  3. Version is

     ceph-csi v3.6.0
    
     kubernetes v1.21.8
    
  4. I already hava open the kubernetes feature gate CSIVolumeHealth,but in prometheus I did not find any useful info,only kubelet_volume_stats_*,but that all about persistenceVolume,not ceph cluster capacity.

anyone can help? plz

1

There are 1 answers

0
Luca Tartarini On

Same for me, the following Prometheus query works well for all PVCs except for Ceph OSDs PVCs:

    (
      sum without(instance, node) (kubelet_volume_stats_used_bytes{job="kubelet",metrics_path="/metrics",persistentvolumeclaim=~".*"})
      /
      sum without(instance, node) (kubelet_volume_stats_capacity_bytes{job="kubelet", metrics_path="/metrics", persistentvolumeclaim=~".*"})
    ) * 100

Reference: https://github.com/redhat-cop/volume-expander-operator/issues/9