Skip to content

Commit

Permalink
add PV/PVC Namespace for PowerStore capacity metrics (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
YianZong authored Aug 5, 2022
1 parent fd6b412 commit da0d1cb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
4 changes: 4 additions & 0 deletions internal/service/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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),
Expand Down
3 changes: 3 additions & 0 deletions internal/service/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
}

Expand Down
14 changes: 8 additions & 6 deletions internal/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 8 additions & 6 deletions internal/service/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit da0d1cb

Please sign in to comment.