Skip to content

Commit

Permalink
feat: add CSI volume attributes to PV info metric
Browse files Browse the repository at this point in the history
Signed-off-by: João Vilaça <jvilaca@redhat.com>
  • Loading branch information
machadovilaca committed Oct 10, 2023
1 parent 48568ab commit 56eebc1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docs/persistentvolume-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
| kube_persistentvolume_status_phase | Gauge | | | `persistentvolume`=&lt;pv-name&gt; <br>`phase`=&lt;Bound\|Failed\|Pending\|Available\|Released&gt; | STABLE |
| kube_persistentvolume_claim_ref | Gauge | | | `persistentvolume`=&lt;pv-name&gt; <br>`claim_namespace`=&lt;<namespace>&gt; <br>`name`=&lt;<name>&gt; | STABLE |
| kube_persistentvolume_labels | Gauge | | | `persistentvolume`=&lt;persistentvolume-name&gt; <br> `label_PERSISTENTVOLUME_LABEL`=&lt;PERSISTENTVOLUME_LABEL&gt; | STABLE |
| kube_persistentvolume_info | Gauge | | | `persistentvolume`=&lt;pv-name&gt; <br> `storageclass`=&lt;storageclass-name&gt; <br> `gce_persistent_disk_name`=&lt;pd-name&gt; <br> `host_path`=&lt;path-of-a-host-volume&gt; <br> `host_path_type`=&lt;host-mount-type&gt; <br> `ebs_volume_id`=&lt;ebs-volume-id&gt; <br> `azure_disk_name`=&lt;azure-disk-name&gt; <br> `fc_wwids`=&lt;fc-wwids-comma-separated&gt; <br> `fc_lun`=&lt;fc-lun&gt; <br> `fc_target_wwns`=&lt;fc-target-wwns-comma-separated&gt; <br> `iscsi_target_portal`=&lt;iscsi-target-portal&gt; <br> `iscsi_iqn`=&lt;iscsi-iqn&gt; <br> `iscsi_lun`=&lt;iscsi-lun&gt; <br> `iscsi_initiator_name`=&lt;iscsi-initiator-name&gt; <br> `local_path`=&lt;path-of-a-local-volume&gt; <br> `local_fs`=&lt;local-volume-fs-type&gt; <br> `nfs_server`=&lt;nfs-server&gt; <br> `nfs_path`=&lt;nfs-path&gt; <br> `csi_driver`=&lt;csi-driver&gt; <br> `csi_volume_handle`=&lt;csi-volume-handle&gt; | STABLE |
| kube_persistentvolume_info | Gauge | | | `persistentvolume`=&lt;pv-name&gt; <br> `storageclass`=&lt;storageclass-name&gt; <br> `gce_persistent_disk_name`=&lt;pd-name&gt; <br> `host_path`=&lt;path-of-a-host-volume&gt; <br> `host_path_type`=&lt;host-mount-type&gt; <br> `ebs_volume_id`=&lt;ebs-volume-id&gt; <br> `azure_disk_name`=&lt;azure-disk-name&gt; <br> `fc_wwids`=&lt;fc-wwids-comma-separated&gt; <br> `fc_lun`=&lt;fc-lun&gt; <br> `fc_target_wwns`=&lt;fc-target-wwns-comma-separated&gt; <br> `iscsi_target_portal`=&lt;iscsi-target-portal&gt; <br> `iscsi_iqn`=&lt;iscsi-iqn&gt; <br> `iscsi_lun`=&lt;iscsi-lun&gt; <br> `iscsi_initiator_name`=&lt;iscsi-initiator-name&gt; <br> `local_path`=&lt;path-of-a-local-volume&gt; <br> `local_fs`=&lt;local-volume-fs-type&gt; <br> `nfs_server`=&lt;nfs-server&gt; <br> `nfs_path`=&lt;nfs-path&gt; <br> `csi_driver`=&lt;csi-driver&gt; <br> `csi_volume_handle`=&lt;csi-volume-handle&gt; <br> `csi_mounter`=&lt;csi-mounter&gt; <br> `csi_map_options`=&lt;csi-map-options&gt;| STABLE |
| kube_persistentvolume_created | Gauge | Unix Creation Timestamp | seconds | `persistentvolume`=&lt;persistentvolume-name&gt; <br> | EXPERIMENTAL |

12 changes: 12 additions & 0 deletions internal/store/persistentvolume.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ func persistentVolumeMetricFamilies(allowAnnotationsList, allowLabelsList []stri
iscsiTargetPortal, iscsiIQN, iscsiLun, iscsiInitiatorName,
nfsServer, nfsPath,
csiDriver, csiVolumeHandle,
csiMounter, csiMapOptions,
localFS, localPath,
hostPath, hostPathType string
)
Expand Down Expand Up @@ -219,6 +220,13 @@ func persistentVolumeMetricFamilies(allowAnnotationsList, allowLabelsList []stri
case p.Spec.PersistentVolumeSource.CSI != nil:
csiDriver = p.Spec.PersistentVolumeSource.CSI.Driver
csiVolumeHandle = p.Spec.PersistentVolumeSource.CSI.VolumeHandle
for k, v := range p.Spec.PersistentVolumeSource.CSI.VolumeAttributes {
if k == "mapOptions" {
csiMapOptions = v
} else if k == "mounter" {
csiMounter = v
}
}
case p.Spec.PersistentVolumeSource.Local != nil:
localPath = p.Spec.PersistentVolumeSource.Local.Path
if p.Spec.PersistentVolumeSource.Local.FSType != nil {
Expand Down Expand Up @@ -250,6 +258,8 @@ func persistentVolumeMetricFamilies(allowAnnotationsList, allowLabelsList []stri
"nfs_path",
"csi_driver",
"csi_volume_handle",
"csi_mounter",
"csi_map_options",
"local_path",
"local_fs",
"host_path",
Expand All @@ -271,6 +281,8 @@ func persistentVolumeMetricFamilies(allowAnnotationsList, allowLabelsList []stri
nfsPath,
csiDriver,
csiVolumeHandle,
csiMounter,
csiMapOptions,
localPath,
localFS,
hostPath,
Expand Down
Loading

0 comments on commit 56eebc1

Please sign in to comment.