From ae6de6c89192291d91410f1aa90f74236cd65597 Mon Sep 17 00:00:00 2001 From: Rahul Date: Fri, 15 Sep 2023 19:32:11 +0530 Subject: [PATCH] fix: enable root aggregate power (#2363) * fix: enable root aggregate power --- cmd/collectors/restperf/plugins/disk/disk.go | 44 ++++++--------- cmd/collectors/zapiperf/plugins/disk/disk.go | 43 ++++++-------- grafana/dashboards/cmode/power.json | 59 ++++---------------- 3 files changed, 44 insertions(+), 102 deletions(-) diff --git a/cmd/collectors/restperf/plugins/disk/disk.go b/cmd/collectors/restperf/plugins/disk/disk.go index 3f1e49b63..5cc2a6b4d 100644 --- a/cmd/collectors/restperf/plugins/disk/disk.go +++ b/cmd/collectors/restperf/plugins/disk/disk.go @@ -65,7 +65,6 @@ type aggregate struct { isShared bool power float64 derivedType RaidAggrDerivedType - export bool } type disk struct { @@ -408,7 +407,6 @@ func (d *Disk) calculateAggrPower(data *matrix.Matrix, output []*matrix.Matrix) if totalTransfers == nil { return output, errs.New(errs.ErrNoMetric, "total_transfer_count") } - totaliops := make(map[string]float64) // calculate power for returned disks in perf response for _, instance := range data.GetInstances() { @@ -433,9 +431,7 @@ func (d *Disk) calculateAggrPower(data *matrix.Matrix, output []*matrix.Matrix) sh, ok := d.ShelfMap[shelfID] if ok { diskPower := v * sh.power / sh.iops - totaliops[shelfID] = totaliops[shelfID] + v - aggrPower := a.power + diskPower - a.power = aggrPower + a.power += diskPower } } else { d.Logger.Warn().Str("diskUUID", diskUUID). @@ -485,25 +481,24 @@ func (d *Disk) calculateAggrPower(data *matrix.Matrix, output []*matrix.Matrix) // fill aggr power matrix with power calculated above for k, v := range d.aggrMap { - if v.export { - instanceKey := k - instance, err := aggrData.NewInstance(instanceKey) - if err != nil { - d.Logger.Error().Err(err).Str("key", instanceKey).Msg("Failed to add instance") - continue - } - instance.SetLabel("aggr", k) - instance.SetLabel("derivedType", string(v.derivedType)) - instance.SetLabel("node", v.node) - - m := aggrData.GetMetric("power") - err = m.SetValueFloat64(instance, v.power) - if err != nil { - d.Logger.Error().Err(err).Str("key", instanceKey).Msg("Failed to set value") - continue - } + instanceKey := k + instance, err := aggrData.NewInstance(instanceKey) + if err != nil { + d.Logger.Error().Err(err).Str("key", instanceKey).Msg("Failed to add instance") + continue + } + instance.SetLabel("aggr", k) + instance.SetLabel("derivedType", string(v.derivedType)) + instance.SetLabel("node", v.node) + + m := aggrData.GetMetric("power") + err = m.SetValueFloat64(instance, v.power) + if err != nil { + d.Logger.Error().Err(err).Str("key", instanceKey).Msg("Failed to set value") + continue } } + output = append(output, aggrData) return output, nil @@ -605,7 +600,7 @@ func (d *Disk) getAggregates() error { query := "api/private/cli/aggr" - href := rest.BuildHref("", "aggregate,composite,node,uses_shared_disks,root,storage_type", nil, "", "", "", "", query) + href := rest.BuildHref("", "aggregate,composite,node,uses_shared_disks,storage_type", nil, "", "", "", "", query) records, err := rest.Fetch(d.client, href) if err != nil { @@ -625,11 +620,9 @@ func (d *Disk) getAggregates() error { aggrName := aggr.Get("aggregate").String() usesSharedDisks := aggr.Get("uses_shared_disks").String() isC := aggr.Get("composite").String() - isR := aggr.Get("root").String() aggregateType := aggr.Get("storage_type").String() nodeName := aggr.Get("node").String() isShared := usesSharedDisks == "true" - isRootAggregate := isR == "true" isComposite := isC == "true" derivedType := getAggregateDerivedType(aggregateType, isComposite, isShared) d.aggrMap[aggrName] = &aggregate{ @@ -637,7 +630,6 @@ func (d *Disk) getAggregates() error { isShared: isShared, derivedType: derivedType, node: nodeName, - export: !isRootAggregate, } } return nil diff --git a/cmd/collectors/zapiperf/plugins/disk/disk.go b/cmd/collectors/zapiperf/plugins/disk/disk.go index 7e4f27b39..5e2d7b924 100644 --- a/cmd/collectors/zapiperf/plugins/disk/disk.go +++ b/cmd/collectors/zapiperf/plugins/disk/disk.go @@ -66,7 +66,6 @@ type aggregate struct { isShared bool power float64 derivedType RaidAggrDerivedType - export bool } type disk struct { @@ -313,7 +312,6 @@ func (d *Disk) calculateAggrPower(data *matrix.Matrix, output []*matrix.Matrix) if totalTransfers == nil { return output, errs.New(errs.ErrNoMetric, "total_transfers") } - totaliops := make(map[string]float64) // calculate power for returned disks in zapiperf response for _, instance := range data.GetInstances() { @@ -335,9 +333,7 @@ func (d *Disk) calculateAggrPower(data *matrix.Matrix, output []*matrix.Matrix) sh, ok := d.ShelfMap[shelfID] if ok { diskPower := v * sh.power / sh.iops - totaliops[shelfID] = totaliops[shelfID] + v - aggrPower := a.power + diskPower - a.power = aggrPower + a.power += diskPower } } else { d.Logger.Warn().Str("diskUUID", diskUUID).Msg("Missing disk info") @@ -385,23 +381,21 @@ func (d *Disk) calculateAggrPower(data *matrix.Matrix, output []*matrix.Matrix) // fill aggr power matrix with power calculated above for k, v := range d.aggrMap { - if v.export { - instanceKey := k - instance, err := aggrData.NewInstance(instanceKey) - if err != nil { - d.Logger.Error().Err(err).Str("key", instanceKey).Msg("Failed to add instance") - continue - } - instance.SetLabel("aggr", k) - instance.SetLabel("derivedType", string(v.derivedType)) - instance.SetLabel("node", v.node) - - m := aggrData.GetMetric("power") - err = m.SetValueFloat64(instance, v.power) - if err != nil { - d.Logger.Error().Err(err).Str("key", instanceKey).Msg("Failed to set value") - continue - } + instanceKey := k + instance, err := aggrData.NewInstance(instanceKey) + if err != nil { + d.Logger.Error().Err(err).Str("key", instanceKey).Msg("Failed to add instance") + continue + } + instance.SetLabel("aggr", k) + instance.SetLabel("derivedType", string(v.derivedType)) + instance.SetLabel("node", v.node) + + m := aggrData.GetMetric("power") + err = m.SetValueFloat64(instance, v.power) + if err != nil { + d.Logger.Error().Err(err).Str("key", instanceKey).Msg("Failed to set value") + continue } } output = append(output, aggrData) @@ -553,7 +547,6 @@ func (d *Disk) getAggregates() error { aggrRaidAttributes.NewChildS("uses-shared-disks", "") aggrRaidAttributes.NewChildS("aggregate-type", "") aggrRaidAttributes.NewChildS("is-composite", "") - aggrRaidAttributes.NewChildS("is-root-aggregate", "") aggrAttributes.AddChild(aggrRaidAttributes) aggrAttributes.AddChild(aggrOwnerAttributes) desired.AddChild(aggrAttributes) @@ -584,21 +577,17 @@ func (d *Disk) getAggregates() error { nodeName = aggrOwnerAttr.GetChildContentS("home-name") } if aggrRaidAttr != nil { - isR := aggrRaidAttr.GetChildContentS("is-root-aggregate") - usesSharedDisks := aggrRaidAttr.GetChildContentS("uses-shared-disks") aggregateType := aggrRaidAttr.GetChildContentS("aggregate-type") isC := aggrRaidAttr.GetChildContentS("is-composite") isComposite := isC == "true" isShared := usesSharedDisks == "true" - isRootAggregate := isR == "true" derivedType := getAggregateDerivedType(aggregateType, isComposite, isShared) d.aggrMap[aggrName] = &aggregate{ name: aggrName, isShared: isShared, derivedType: derivedType, node: nodeName, - export: !isRootAggregate, } } } diff --git a/grafana/dashboards/cmode/power.json b/grafana/dashboards/cmode/power.json index eb8d59a3b..c53fb4c30 100644 --- a/grafana/dashboards/cmode/power.json +++ b/grafana/dashboards/cmode/power.json @@ -71,7 +71,7 @@ "gnetId": null, "graphTooltip": 1, "id": null, - "iteration": 1694453038642, + "iteration": 1694717870555, "links": [ { "asDropdown": true, @@ -1353,7 +1353,7 @@ "targets": [ { "exemplar": false, - "expr": "sum(aggr_disk_user_reads{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\",aggr=~\"$TopAggrPower\"} and on(aggr,cluster,node) aggr_labels{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\",aggr=~\"$TopAggrPower\"}) by (aggr,cluster,node)", + "expr": "sum(aggr_disk_user_reads{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\",aggr=~\"$TopAggrPower\"}) by (aggr,cluster,node)", "hide": false, "interval": "", "legendFormat": "Reads - {{aggr}} ({{cluster}})", @@ -1361,7 +1361,7 @@ }, { "exemplar": false, - "expr": "sum(aggr_disk_user_writes{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\",aggr=~\"$TopAggrPower\"} and on(aggr,cluster,node) aggr_labels{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\",aggr=~\"$TopAggrPower\"}) by (aggr,cluster,node)", + "expr": "sum(aggr_disk_user_writes{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\",aggr=~\"$TopAggrPower\"}) by (aggr,cluster,node)", "hide": false, "interval": "", "legendFormat": "Writes - {{aggr}} ({{cluster}})", @@ -1635,7 +1635,7 @@ "h": 8, "w": 24, "x": 0, - "y": 52 + "y": 57 }, "id": 91, "interval": "1m", @@ -1664,37 +1664,7 @@ }, { "exemplar": false, - "expr": "aggr_space_total{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\"}", - "format": "table", - "hide": false, - "instant": true, - "interval": "", - "legendFormat": "", - "refId": "D" - }, - { - "exemplar": false, - "expr": "aggr_space_used{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\"}", - "format": "table", - "hide": false, - "instant": true, - "interval": "", - "legendFormat": "", - "refId": "E" - }, - { - "exemplar": false, - "expr": "aggr_space_used_percent{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\"}", - "format": "table", - "hide": false, - "instant": true, - "interval": "", - "legendFormat": "", - "refId": "F" - }, - { - "exemplar": false, - "expr": "sum(aggr_disk_total_transfers{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\"} and on(aggr,cluster,node) aggr_labels{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\"}) by (aggr,cluster,node)", + "expr": "sum(aggr_disk_total_transfers{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\"}) by (aggr,cluster,node)", "format": "table", "hide": false, "instant": true, @@ -1704,23 +1674,13 @@ }, { "exemplar": false, - "expr": "sum(aggr_disk_total_data{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\"} and on(aggr,cluster,node) aggr_labels{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\"}) by (aggr,cluster,node)", + "expr": "sum(aggr_disk_total_data{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\"}) by (aggr,cluster,node)", "format": "table", "hide": false, "instant": true, "interval": "", "legendFormat": "", "refId": "G" - }, - { - "exemplar": false, - "expr": "aggr_new_status{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\"}", - "format": "table", - "hide": false, - "instant": true, - "interval": "", - "legendFormat": "", - "refId": "A" } ], "timeFrom": null, @@ -2849,7 +2809,7 @@ "h": 7, "w": 24, "x": 0, - "y": 58 + "y": 60 }, "id": 81, "interval": "1m", @@ -2861,6 +2821,7 @@ "pluginVersion": "8.1.8", "targets": [ { + "exemplar": false, "expr": "shelf_labels{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\"}", "format": "table", "instant": true, @@ -2890,7 +2851,7 @@ }, { "exemplar": false, - "expr": "shelf_power{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\"}", + "expr": "shelf_power{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\"} * on(datacenter,cluster,shelf) shelf_labels{datacenter=~\"$Datacenter\",cluster=~\"$Cluster\",isEmbedded=\"No\"}", "format": "table", "hide": false, "instant": true, @@ -3399,5 +3360,5 @@ "timezone": "", "title": "ONTAP: Power", "uid": "", - "version": 11 + "version": 12 }