From 1f2d601663416ee7658d52fa296ae1b7397dc05f Mon Sep 17 00:00:00 2001 From: Chris Grindstaff Date: Thu, 2 Mar 2023 13:11:44 -0500 Subject: [PATCH 1/2] fix: REST fabricpool metric label should match ZAPI --- .../restperf/plugins/fabricpool/fabricpool.go | 44 +++++++++++++++++++ cmd/collectors/restperf/restperf.go | 3 ++ .../9.12.0/wafl_comp_aggr_vol_bin.yaml | 3 ++ 3 files changed, 50 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..5f8f01636 --- /dev/null +++ b/cmd/collectors/restperf/plugins/fabricpool/fabricpool.go @@ -0,0 +1,44 @@ +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) { + verbs := []string{ + "delete", + "get", + "head", + "list", + "put", + "unknown", + } + metrics := []string{ + "cloud_bin_op#", + "cloud_bin_op_latency_average#", + } + + for _, verb := range verbs { + for _, metricName := range metrics { + metric := data.GetMetric(metricName + verb) + if metric == nil { + continue + } + v := metric.GetLabel("metric") + 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..16a6ceeb7 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 From f6bb3667439702f64a1e41602d2de342e2db51f5 Mon Sep 17 00:00:00 2001 From: Chris Grindstaff Date: Thu, 2 Mar 2023 13:36:55 -0500 Subject: [PATCH 2/2] fix: REST fabricpool metric label should match ZAPI --- .../restperf/plugins/fabricpool/fabricpool.go | 26 +++++-------------- .../9.12.0/wafl_comp_aggr_vol_bin.yaml | 2 +- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/cmd/collectors/restperf/plugins/fabricpool/fabricpool.go b/cmd/collectors/restperf/plugins/fabricpool/fabricpool.go index 5f8f01636..33a5a9539 100644 --- a/cmd/collectors/restperf/plugins/fabricpool/fabricpool.go +++ b/cmd/collectors/restperf/plugins/fabricpool/fabricpool.go @@ -16,26 +16,12 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin { // Run converts Rest lowercase metric names to uppercase to match ZapiPerf func (f *FabricPool) Run(data *matrix.Matrix) ([]*matrix.Matrix, error) { - verbs := []string{ - "delete", - "get", - "head", - "list", - "put", - "unknown", - } - metrics := []string{ - "cloud_bin_op#", - "cloud_bin_op_latency_average#", - } - - for _, verb := range verbs { - for _, metricName := range metrics { - metric := data.GetMetric(metricName + verb) - if metric == nil { - continue - } - v := metric.GetLabel("metric") + for _, metric := range data.GetMetrics() { + if !metric.IsArray() { + continue + } + v := metric.GetLabel("metric") + if v != "" { metric.SetLabel("metric", strings.ToUpper(v)) } } 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 16a6ceeb7..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 @@ -10,7 +10,7 @@ counters: - cloud_bin_op_latency_average plugins: - - FabricPool: + - FabricPool export_options: instance_keys: