Skip to content

Commit

Permalink
Reduce label cardinality
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 Aug 17, 2023
1 parent 01f7957 commit c7b0c08
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 26 deletions.
2 changes: 1 addition & 1 deletion docs/persistentvolume-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
| 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 |
| kube_persistentvolume_deletion_timestamp | Gauge | Unix deletion timestamp | seconds | `persistentvolume`=&lt;persistentvolume-name&gt; <br> | EXPERIMENTAL |

Expand Down
18 changes: 10 additions & 8 deletions internal/store/persistentvolume.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package store

import (
"context"
"fmt"
"strconv"

basemetrics "k8s.io/component-base/metrics"
Expand Down Expand Up @@ -180,9 +179,9 @@ func persistentVolumeMetricFamilies(allowAnnotationsList, allowLabelsList []stri
iscsiTargetPortal, iscsiIQN, iscsiLun, iscsiInitiatorName,
nfsServer, nfsPath,
csiDriver, csiVolumeHandle,
csiMounter, csiMapOptions,
localFS, localPath,
hostPath, hostPathType,
attributes string
hostPath, hostPathType string
)

switch {
Expand Down Expand Up @@ -223,10 +222,11 @@ func persistentVolumeMetricFamilies(allowAnnotationsList, allowLabelsList []stri
csiVolumeHandle = p.Spec.PersistentVolumeSource.CSI.VolumeHandle

for k, v := range p.Spec.PersistentVolumeSource.CSI.VolumeAttributes {
if len(attributes) != 0 {
attributes += ","
if k == "mapOptions" {
csiMapOptions = v
} else if k == "mounter" {
csiMounter = v
}
attributes += fmt.Sprintf("%s=%s", k, v)
}
case p.Spec.PersistentVolumeSource.Local != nil:
localPath = p.Spec.PersistentVolumeSource.Local.Path
Expand Down Expand Up @@ -259,11 +259,12 @@ func persistentVolumeMetricFamilies(allowAnnotationsList, allowLabelsList []stri
"nfs_path",
"csi_driver",
"csi_volume_handle",
"csi_mounter",
"csi_map_options",
"local_path",
"local_fs",
"host_path",
"host_path_type",
"attributes",
},
LabelValues: []string{
p.Spec.StorageClassName,
Expand All @@ -281,11 +282,12 @@ func persistentVolumeMetricFamilies(allowAnnotationsList, allowLabelsList []stri
nfsPath,
csiDriver,
csiVolumeHandle,
csiMounter,
csiMapOptions,
localPath,
localFS,
hostPath,
hostPathType,
attributes,
},
Value: 1,
},
Expand Down

0 comments on commit c7b0c08

Please sign in to comment.