Skip to content

Commit

Permalink
feat: Tiering data changes for volume - template change (#2343)
Browse files Browse the repository at this point in the history
* feat: Tiering data changes for volume - template change

* feat: Tiering data changes for volume - dashboard change

* feat: Tiering data changes for aggr - template change
  • Loading branch information
Hardikl authored Sep 29, 2023
1 parent 566f070 commit cf314d9
Show file tree
Hide file tree
Showing 9 changed files with 1,552 additions and 59 deletions.
84 changes: 77 additions & 7 deletions cmd/collectors/zapi/plugins/aggregate/aggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,47 @@ func (a *Aggregate) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, er
if err := a.getCloudStores(); err != nil {
if errors.Is(err, errs.ErrNoInstance) {
a.Logger.Debug().Err(err).Msg("Failed to collect cloud store data")
return nil, nil
}
return nil, err
}

aggrFootprintMap, err := a.getAggrFootprint()
if err != nil {
a.Logger.Error().Err(err).Msg("Failed to update footprint data")
// clean the map in case of the error
clear(aggrFootprintMap)
}

// update aggregate instance label with cloud stores info
if len(a.aggrCloudStoresMap) > 0 {
for aggrUUID, aggr := range data.GetInstances() {
if !aggr.IsExportable() {
continue
for aggrUUID, aggr := range data.GetInstances() {
if !aggr.IsExportable() {
continue
}
aggr.SetLabel("cloud_stores", strings.Join(a.aggrCloudStoresMap[aggrUUID], ","))

// Handling aggr footprint metrics
aggrName := aggr.GetLabel("aggr")
if af, ok := aggrFootprintMap[aggrName]; ok {
for afKey, afVal := range af {
vfMetric := data.GetMetric(afKey)
if vfMetric == nil {
if vfMetric, err = data.NewMetricFloat64(afKey); err != nil {
a.Logger.Error().Err(err).Str("metric", afKey).Msg("add metric")
continue
}
}

if afVal != "" {
vfMetricVal, err := strconv.ParseFloat(afVal, 64)
if err != nil {
a.Logger.Error().Err(err).Str(afKey, afVal).Msg("parse")
continue
}
if err = vfMetric.SetValueFloat64(aggr, vfMetricVal); err != nil {
a.Logger.Error().Err(err).Str(afKey, afVal).Msg("set")
continue
}
}
}
aggr.SetLabel("cloud_stores", strings.Join(a.aggrCloudStoresMap[aggrUUID], ","))
}
}
return nil, nil
Expand Down Expand Up @@ -124,3 +153,44 @@ func (a *Aggregate) getCloudStores() error {
}
return nil
}

func (a *Aggregate) getAggrFootprint() (map[string]map[string]string, error) {
var (
result []*node.Node
aggrFootprintMap map[string]map[string]string
err error
)

aggrFootprintMap = make(map[string]map[string]string)
request := node.NewXMLS("aggr-space-get-iter")
request.NewChildS("max-records", collectors.DefaultBatchSize)
desired := node.NewXMLS("desired-attributes")
spaceInfo := node.NewXMLS("space-information")
spaceInfo.NewChildS("aggregate", "")
spaceInfo.NewChildS("volume-footprints", "")
spaceInfo.NewChildS("volume-footprints-percent", "")
desired.AddChild(spaceInfo)
request.AddChild(desired)

if result, err = a.client.InvokeZapiCall(request); err != nil {
return nil, err
}

if len(result) == 0 {
return aggrFootprintMap, nil
}

for _, footprint := range result {
footprintMetrics := make(map[string]string)
aggr := footprint.GetChildContentS("aggregate")
performanceTierUsed := footprint.GetChildContentS("volume-footprints")
performanceTierUsedPerc := footprint.GetChildContentS("volume-footprints-percent")
if performanceTierUsed != "" || performanceTierUsedPerc != "" {
footprintMetrics["space_performance_tier_used"] = performanceTierUsed
footprintMetrics["space_performance_tier_used_percent"] = performanceTierUsedPerc
aggrFootprintMap[aggr] = footprintMetrics
}
}

return aggrFootprintMap, nil
}
84 changes: 81 additions & 3 deletions cmd/collectors/zapi/plugins/volume/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,25 @@ func (v *Volume) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, error
}

volumeCloneMap, err := v.getVolumeCloneInfo()

if err != nil {
v.Logger.Error().Err(err).Msg("Failed to update clone data")
}

volumeFootprintMap, err := v.getVolumeFootprint()
if err != nil {
v.Logger.Error().Err(err).Msg("Failed to update footprint data")
// clean the map in case of the error
clear(volumeFootprintMap)
}

// update volume instance labels
v.updateVolumeLabels(data, volumeCloneMap)
v.updateVolumeLabels(data, volumeCloneMap, volumeFootprintMap)

v.currentVal++
return nil, nil
}

func (v *Volume) updateVolumeLabels(data *matrix.Matrix, volumeCloneMap map[string]volumeClone) {
func (v *Volume) updateVolumeLabels(data *matrix.Matrix, volumeCloneMap map[string]volumeClone, volumeFootprintMap map[string]map[string]string) {
var err error
for _, volume := range data.GetInstances() {
if !volume.IsExportable() {
Expand Down Expand Up @@ -143,6 +149,31 @@ func (v *Volume) updateVolumeLabels(data *matrix.Matrix, volumeCloneMap map[stri
continue
}
}

// Handling volume footprint metrics
if vf, ok := volumeFootprintMap[key]; ok {
for vfKey, vfVal := range vf {
vfMetric := data.GetMetric(vfKey)
if vfMetric == nil {
if vfMetric, err = data.NewMetricFloat64(vfKey); err != nil {
v.Logger.Error().Err(err).Str("metric", vfKey).Msg("add metric")
continue
}
}

if vfVal != "" {
vfMetricVal, err := strconv.ParseFloat(vfVal, 64)
if err != nil {
v.Logger.Error().Err(err).Str(vfKey, vfVal).Msg("parse")
continue
}
if err = vfMetric.SetValueFloat64(volume, vfMetricVal); err != nil {
v.Logger.Error().Err(err).Str(vfKey, vfVal).Msg("set")
continue
}
}
}
}
}
}

Expand Down Expand Up @@ -186,6 +217,53 @@ func (v *Volume) getVolumeCloneInfo() (map[string]volumeClone, error) {
return volumeCloneMap, nil
}

func (v *Volume) getVolumeFootprint() (map[string]map[string]string, error) {
var (
result []*node.Node
volumeFootprintMap map[string]map[string]string
err error
)

volumeFootprintMap = make(map[string]map[string]string)
request := node.NewXMLS("volume-footprint-get-iter")
request.NewChildS("max-records", collectors.DefaultBatchSize)
desired := node.NewXMLS("desired-attributes")
footprintInfo := node.NewXMLS("footprint-info")
footprintInfo.NewChildS("volume", "")
footprintInfo.NewChildS("vserver", "")
footprintInfo.NewChildS("volume-blocks-footprint-bin0", "")
footprintInfo.NewChildS("volume-blocks-footprint-bin0-percent", "")
footprintInfo.NewChildS("volume-blocks-footprint-bin1", "")
footprintInfo.NewChildS("volume-blocks-footprint-bin1-percent", "")
desired.AddChild(footprintInfo)
request.AddChild(desired)

if result, err = v.client.InvokeZapiCall(request); err != nil {
return nil, err
}

if len(result) == 0 {
return volumeFootprintMap, nil
}

for _, footprint := range result {
footprintMetrics := make(map[string]string)
volume := footprint.GetChildContentS("volume")
svm := footprint.GetChildContentS("vserver")
performanceTierFootprint := footprint.GetChildContentS("volume-blocks-footprint-bin0")
performanceTierFootprintPerc := footprint.GetChildContentS("volume-blocks-footprint-bin0-percent")
capacityTierFootprint := footprint.GetChildContentS("volume-blocks-footprint-bin1")
capacityTierFootprintPerc := footprint.GetChildContentS("volume-blocks-footprint-bin1-percent")
footprintMetrics["performance_tier_footprint"] = performanceTierFootprint
footprintMetrics["performance_tier_footprint_percent"] = performanceTierFootprintPerc
footprintMetrics["capacity_tier_footprint"] = capacityTierFootprint
footprintMetrics["capacity_tier_footprint_percent"] = capacityTierFootprintPerc
volumeFootprintMap[volume+svm] = footprintMetrics
}

return volumeFootprintMap, nil
}

func (v *Volume) getEncryptedDisks() ([]string, error) {
var (
result []*node.Node
Expand Down
2 changes: 2 additions & 0 deletions conf/rest/9.10.0/aggr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ counters:
- space.efficiency_without_snapshots.savings => efficiency_savings_wo_snapshots
- space.efficiency_without_snapshots_flexclones.logical_used => logical_used_wo_snapshots_flexclones
- space.efficiency_without_snapshots_flexclones.savings => efficiency_savings_wo_snapshots_flexclones
- space.footprint => space_performance_tier_used
- space.footprint_percent => space_performance_tier_used_percent
- space.snapshot.available => snapshot_size_available
- space.snapshot.reserve_percent => snapshot_reserve_percent
- space.snapshot.total => snapshot_size_total
Expand Down
10 changes: 10 additions & 0 deletions conf/rest/9.10.0/volume.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ endpoints:
- filter:
- privilege_level=diagnostic

- query: api/private/cli/volume/footprint
counters:
- ^^volume
- ^^vserver => svm
- volume_blocks_footprint_bin0 => performance_tier_footprint
- volume_blocks_footprint_bin0_percent => performance_tier_footprint_percent
- volume_blocks_footprint_bin1 => capacity_tier_footprint
- volume_blocks_footprint_bin1_percent => capacity_tier_footprint_percent


plugins:
- Volume:
schedule:
Expand Down
2 changes: 2 additions & 0 deletions conf/rest/9.12.0/aggr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ counters:
- space.efficiency_without_snapshots.savings => efficiency_savings_wo_snapshots
- space.efficiency_without_snapshots_flexclones.logical_used => logical_used_wo_snapshots_flexclones
- space.efficiency_without_snapshots_flexclones.savings => efficiency_savings_wo_snapshots_flexclones
- space.footprint => space_performance_tier_used
- space.footprint_percent => space_performance_tier_used_percent
- space.snapshot.available => snapshot_size_available
- space.snapshot.reserve_percent => snapshot_reserve_percent
- space.snapshot.total => snapshot_size_total
Expand Down
10 changes: 10 additions & 0 deletions conf/rest/9.9.0/volume.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ endpoints:
- filter:
- privilege_level=diagnostic

- query: api/private/cli/volume/footprint
counters:
- ^^volume
- ^^vserver => svm
- volume_blocks_footprint_bin0 => performance_tier_footprint
- volume_blocks_footprint_bin0_percent => performance_tier_footprint_percent
- volume_blocks_footprint_bin1 => capacity_tier_footprint
- volume_blocks_footprint_bin1_percent => capacity_tier_footprint_percent


plugins:
- Volume:
schedule:
Expand Down
1 change: 0 additions & 1 deletion conf/zapi/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,3 @@ objects:
Support: support.yaml
SVM: svm.yaml
Volume: volume.yaml

Loading

0 comments on commit cf314d9

Please sign in to comment.