Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Tiering data changes for volume - template change #2343

Merged
merged 13 commits into from
Sep 29, 2023
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
aggrFootprintMap = make(map[string]map[string]string)
Hardikl marked this conversation as resolved.
Show resolved Hide resolved
}

// 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")
Hardikl marked this conversation as resolved.
Show resolved Hide resolved
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
volumeFootprintMap = make(map[string]map[string]string)
Hardikl marked this conversation as resolved.
Show resolved Hide resolved
}

// 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")
Hardikl marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -37,4 +37,3 @@ objects:
Support: support.yaml
SVM: svm.yaml
Volume: volume.yaml

Loading
Loading