Skip to content

Commit 9e639b2

Browse files
committed
Add host path metrics, fix table formatting
Signed-off-by: m.nabokikh <[email protected]>
1 parent 9939059 commit 9e639b2

File tree

3 files changed

+93
-23
lines changed

3 files changed

+93
-23
lines changed

docs/persistentvolume-metrics.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# PersistentVolume Metrics
22

3-
| Metric name | Metric type | Description | Unit (where applicable) | Labels/tags | Status |
4-
| ----------- | ----------- | ----------- | ----------- |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| ------------ |
5-
| kube_persistentvolume_annotations | Gauge | | | `persistentvolume`=&lt;persistentvolume-name&gt; <br> `annotation_PERSISTENTVOLUME_ANNOTATION`=&lt;PERSISTENTVOLUME_ANNOTATION&gt; | EXPERIMENTAL |
6-
| kube_persistentvolume_capacity_bytes | Gauge | | | `persistentvolume`=&lt;pv-name&gt; | STABLE |
7-
| kube_persistentvolume_status_phase | Gauge | | | `persistentvolume`=&lt;pv-name&gt; <br>`phase`=&lt;Bound\ |Failed\|Pending\|Available\|Released&gt; | STABLE |
8-
| kube_persistentvolume_claim_ref | Gauge | | | `persistentvolume`=&lt;pv-name&gt; <br>`claim_namespace`=&lt;<namespace>&gt; <br>`name`=&lt;<name>&gt; | STABLE |
9-
| kube_persistentvolume_labels | Gauge | | | `persistentvolume`=&lt;persistentvolume-name&gt; <br> `label_PERSISTENTVOLUME_LABEL`=&lt;PERSISTENTVOLUME_LABEL&gt; | STABLE |
10-
| 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> `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 |
11-
| kube_persistentvolume_created | Gauge | Unix Creation Timestamp | seconds | `persistentvolume`=&lt;persistentvolume-name&gt; <br> | EXPERIMENTAL |
3+
| Metric name | Metric type | Description | Unit (where applicable) | Labels/tags | Status |
4+
| ----------- | ----------- | ----------- | ----------- | ----------- | ------------ |
5+
| kube_persistentvolume_annotations | Gauge | | | `persistentvolume`=&lt;persistentvolume-name&gt; <br> `annotation_PERSISTENTVOLUME_ANNOTATION`=&lt;PERSISTENTVOLUME_ANNOTATION&gt; | EXPERIMENTAL |
6+
| kube_persistentvolume_capacity_bytes | Gauge | | | `persistentvolume`=&lt;pv-name&gt; | STABLE |
7+
| kube_persistentvolume_status_phase | Gauge | | | `persistentvolume`=&lt;pv-name&gt; <br>`phase`=&lt;Bound\|Failed\|Pending\|Available\|Released&gt; | STABLE |
8+
| kube_persistentvolume_claim_ref | Gauge | | | `persistentvolume`=&lt;pv-name&gt; <br>`claim_namespace`=&lt;<namespace>&gt; <br>`name`=&lt;<name>&gt; | STABLE |
9+
| kube_persistentvolume_labels | Gauge | | | `persistentvolume`=&lt;persistentvolume-name&gt; <br> `label_PERSISTENTVOLUME_LABEL`=&lt;PERSISTENTVOLUME_LABEL&gt; | STABLE |
10+
| 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 |
11+
| kube_persistentvolume_created | Gauge | Unix Creation Timestamp | seconds | `persistentvolume`=&lt;persistentvolume-name&gt; <br> | EXPERIMENTAL |
1212

internal/store/persistentvolume.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,17 @@ func persistentVolumeMetricFamilies(allowAnnotationsList, allowLabelsList []stri
164164
metric.Gauge,
165165
"",
166166
wrapPersistentVolumeFunc(func(p *v1.PersistentVolume) *metric.Family {
167-
var gcePDDiskName, ebsVolumeID, azureDiskName, fcWWIDs, fcLun, fcTargetWWNs, iscsiTargetPortal, iscsiIQN, iscsiLun, iscsiInitiatorName, nfsServer, nfsPath, csiDriver, csiVolumeHandle, localFS, localPath string
167+
var (
168+
gcePDDiskName,
169+
ebsVolumeID,
170+
azureDiskName,
171+
fcWWIDs, fcLun, fcTargetWWNs,
172+
iscsiTargetPortal, iscsiIQN, iscsiLun, iscsiInitiatorName,
173+
nfsServer, nfsPath,
174+
csiDriver, csiVolumeHandle,
175+
localFS, localPath,
176+
hostPath, hostPathType string
177+
)
168178

169179
switch {
170180
case p.Spec.PersistentVolumeSource.GCEPersistentDisk != nil:
@@ -207,6 +217,11 @@ func persistentVolumeMetricFamilies(allowAnnotationsList, allowLabelsList []stri
207217
if p.Spec.PersistentVolumeSource.Local.FSType != nil {
208218
localFS = *p.Spec.PersistentVolumeSource.Local.FSType
209219
}
220+
case p.Spec.PersistentVolumeSource.HostPath != nil:
221+
hostPath = p.Spec.PersistentVolumeSource.HostPath.Path
222+
if p.Spec.PersistentVolumeSource.HostPath.Type != nil {
223+
hostPathType = string(*p.Spec.PersistentVolumeSource.HostPath.Type)
224+
}
210225
}
211226

212227
return &metric.Family{
@@ -230,6 +245,8 @@ func persistentVolumeMetricFamilies(allowAnnotationsList, allowLabelsList []stri
230245
"csi_volume_handle",
231246
"local_path",
232247
"local_fs",
248+
"host_path",
249+
"host_path_type",
233250
},
234251
LabelValues: []string{
235252
p.Spec.StorageClassName,
@@ -249,6 +266,8 @@ func persistentVolumeMetricFamilies(allowAnnotationsList, allowLabelsList []stri
249266
csiVolumeHandle,
250267
localPath,
251268
localFS,
269+
hostPath,
270+
hostPathType,
252271
},
253272
Value: 1,
254273
},

0 commit comments

Comments
 (0)