From da0d1cbb52613444ebc37e5a521d510682de6ff5 Mon Sep 17 00:00:00 2001 From: YianZong <63342088+YianZong@users.noreply.github.com> Date: Fri, 5 Aug 2022 16:28:49 +0800 Subject: [PATCH] add PV/PVC Namespace for PowerStore capacity metrics (#39) --- internal/service/metrics.go | 4 ++++ internal/service/metrics_test.go | 3 +++ internal/service/service.go | 14 ++++++++------ internal/service/types.go | 14 ++++++++------ 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/internal/service/metrics.go b/internal/service/metrics.go index 4dd3c94..8500370 100644 --- a/internal/service/metrics.go +++ b/internal/service/metrics.go @@ -234,6 +234,8 @@ func (mw *MetricsWrapper) RecordSpaceMetrics(ctx context.Context, meta interface attribute.String("FileSystemID", v.ID), attribute.String("ArrayID", v.ArrayID), attribute.String("PersistentVolumeName", v.PersistentVolumeName), + attribute.String("PersistentVolumeClaimName", v.PersistentVolumeClaimName), + attribute.String("Namespace", v.Namespace), attribute.String("StorageClass", v.StorageClass), attribute.String("Driver", v.Driver), attribute.String("Protocol", v.Protocol), @@ -246,6 +248,8 @@ func (mw *MetricsWrapper) RecordSpaceMetrics(ctx context.Context, meta interface attribute.String("VolumeID", v.ID), attribute.String("ArrayID", v.ArrayID), attribute.String("PersistentVolumeName", v.PersistentVolumeName), + attribute.String("PersistentVolumeClaimName", v.PersistentVolumeClaimName), + attribute.String("Namespace", v.Namespace), attribute.String("StorageClass", v.StorageClass), attribute.String("Driver", v.Driver), attribute.String("Protocol", v.Protocol), diff --git a/internal/service/metrics_test.go b/internal/service/metrics_test.go index 445db49..2d6dc2f 100644 --- a/internal/service/metrics_test.go +++ b/internal/service/metrics_test.go @@ -884,6 +884,9 @@ func Test_Space_Metrics_Label_Update(t *testing.T) { expectedLables := []attribute.KeyValue{ attribute.String("VolumeID", metaSecond.ID), + attribute.String("PersistentVolumeName", metaSecond.PersistentVolumeName), + attribute.String("PersistentVolumeClaimName", metaSecond.PersistentVolumeClaimName), + attribute.String("Namespace", metaSecond.Namespace), attribute.String("PlotWithMean", "No"), } diff --git a/internal/service/service.go b/internal/service/service.go index d792bfd..d1c43bd 100644 --- a/internal/service/service.go +++ b/internal/service/service.go @@ -355,12 +355,14 @@ func (s *PowerStoreService) gatherSpaceVolumeMetrics(ctx context.Context, volume protocol := volumeProperties[2] spaceMeta := &SpaceVolumeMeta{ - ID: volumeID, - PersistentVolumeName: volume.PersistentVolume, - ArrayID: arrayID, - StorageClass: volume.StorageClass, - Driver: volume.Driver, - Protocol: protocol, + ID: volumeID, + PersistentVolumeName: volume.PersistentVolume, + PersistentVolumeClaimName: volume.VolumeClaimName, + Namespace: volume.Namespace, + ArrayID: arrayID, + StorageClass: volume.StorageClass, + Driver: volume.Driver, + Protocol: protocol, } goPowerStoreClient, err := s.getPowerStoreClient(ctx, arrayID) diff --git a/internal/service/types.go b/internal/service/types.go index eed2adf..c18f970 100644 --- a/internal/service/types.go +++ b/internal/service/types.go @@ -24,12 +24,14 @@ type VolumeMeta struct { // SpaceVolumeMeta is the details of a volume in an SDC type SpaceVolumeMeta struct { - ID string - PersistentVolumeName string - ArrayID string - StorageClass string - Driver string - Protocol string + ID string + PersistentVolumeName string + PersistentVolumeClaimName string + Namespace string + ArrayID string + StorageClass string + Driver string + Protocol string } // TransportType differentiates different SCSI transport protocols (FC, iSCSI, Auto, None)