From 2871d4c233df91998aec5655254bc9df42158741 Mon Sep 17 00:00:00 2001 From: Chris Grindstaff Date: Tue, 7 Mar 2023 11:26:37 -0500 Subject: [PATCH] fix: REST fabricpool metric label should match ZAPI (#1794) * fix: REST fabricpool metric label should match ZAPI * fix: REST fabricpool metric label should match ZAPI --- .../restperf/plugins/fabricpool/fabricpool.go | 30 +++++++++++++++++++ cmd/collectors/restperf/restperf.go | 3 ++ .../9.12.0/wafl_comp_aggr_vol_bin.yaml | 3 ++ 3 files changed, 36 insertions(+) create mode 100644 cmd/collectors/restperf/plugins/fabricpool/fabricpool.go diff --git a/cmd/collectors/restperf/plugins/fabricpool/fabricpool.go b/cmd/collectors/restperf/plugins/fabricpool/fabricpool.go new file mode 100644 index 000000000..33a5a9539 --- /dev/null +++ b/cmd/collectors/restperf/plugins/fabricpool/fabricpool.go @@ -0,0 +1,30 @@ +package fabricpool + +import ( + "github.com/netapp/harvest/v2/cmd/poller/plugin" + "github.com/netapp/harvest/v2/pkg/matrix" + "strings" +) + +type FabricPool struct { + *plugin.AbstractPlugin +} + +func New(p *plugin.AbstractPlugin) plugin.Plugin { + return &FabricPool{AbstractPlugin: p} +} + +// Run converts Rest lowercase metric names to uppercase to match ZapiPerf +func (f *FabricPool) Run(data *matrix.Matrix) ([]*matrix.Matrix, error) { + for _, metric := range data.GetMetrics() { + if !metric.IsArray() { + continue + } + v := metric.GetLabel("metric") + if v != "" { + metric.SetLabel("metric", strings.ToUpper(v)) + } + } + + return nil, nil +} diff --git a/cmd/collectors/restperf/restperf.go b/cmd/collectors/restperf/restperf.go index 1a57c1362..764dbb3b1 100644 --- a/cmd/collectors/restperf/restperf.go +++ b/cmd/collectors/restperf/restperf.go @@ -3,6 +3,7 @@ package restperf import ( rest2 "github.com/netapp/harvest/v2/cmd/collectors/rest" "github.com/netapp/harvest/v2/cmd/collectors/restperf/plugins/disk" + "github.com/netapp/harvest/v2/cmd/collectors/restperf/plugins/fabricpool" "github.com/netapp/harvest/v2/cmd/collectors/restperf/plugins/fcp" "github.com/netapp/harvest/v2/cmd/collectors/restperf/plugins/headroom" "github.com/netapp/harvest/v2/cmd/collectors/restperf/plugins/nic" @@ -1094,6 +1095,8 @@ func (r *RestPerf) LoadPlugin(kind string, p *plugin.AbstractPlugin) plugin.Plug return disk.New(p) case "Vscan": return vscan.New(p) + case "FabricPool": + return fabricpool.New(p) default: r.Logger.Info().Str("kind", kind).Msg("no Restperf plugin found") } diff --git a/conf/restperf/9.12.0/wafl_comp_aggr_vol_bin.yaml b/conf/restperf/9.12.0/wafl_comp_aggr_vol_bin.yaml index c3b9cc3ad..39fad18df 100644 --- a/conf/restperf/9.12.0/wafl_comp_aggr_vol_bin.yaml +++ b/conf/restperf/9.12.0/wafl_comp_aggr_vol_bin.yaml @@ -9,6 +9,9 @@ counters: - cloud_bin_op => cloud_bin_operation - cloud_bin_op_latency_average +plugins: + - FabricPool + export_options: instance_keys: - svm