diff --git a/cmd/collectors/rest/templating.go b/cmd/collectors/rest/templating.go index fc68a5dd4..421e5c7ab 100644 --- a/cmd/collectors/rest/templating.go +++ b/cmd/collectors/rest/templating.go @@ -39,6 +39,10 @@ func (r *Rest) InitCache() error { r.Prop.Object = strings.ToLower(r.Object) } + if shouldIgnore := r.Params.GetChildContentS("ignore"); shouldIgnore == "true" { + return nil + } + if e := r.Params.GetChildS("export_options"); e != nil { r.Matrix[r.Object].SetExportOptions(e) } diff --git a/cmd/poller/poller.go b/cmd/poller/poller.go index 05cd6151f..87f38ba67 100644 --- a/cmd/poller/poller.go +++ b/cmd/poller/poller.go @@ -822,6 +822,10 @@ func (p *Poller) loadCollectorObject(ocs []objectCollector) error { ) } } else { + if shouldIgnore := col.GetParams().GetChildContentS("ignore"); shouldIgnore == "true" { + logger.Debug("ignoring collector", slog.String("collector", oc.class), slog.String("object", oc.object)) + continue + } collectors = append(collectors, col) logger.Debug( "initialized collector-object", diff --git a/cmd/tools/template/template.go b/cmd/tools/template/template.go index c616c5f82..93982ff5b 100644 --- a/cmd/tools/template/template.go +++ b/cmd/tools/template/template.go @@ -22,6 +22,7 @@ type Model struct { Name string `yaml:"name"` Query string `yaml:"query"` Object string `yaml:"object"` + Ignore string `yaml:"ignore"` ExportData string `yaml:"export_data"` Endpoints []*Endpoint `yaml:"endpoints"` ExportOptions struct { @@ -80,6 +81,15 @@ func unmarshalModel(data []byte) (Model, error) { return tm, errs.New(errs.ErrConfig, "template file is empty or does not exist") } contentNode := root.Content[0] + ignoreNode := searchNode(contentNode, "ignore") + if ignoreNode != nil && ignoreNode.Value == "true" { + tm.Ignore = ignoreNode.Value + nameNode := searchNode(contentNode, "name") + if nameNode != nil { + tm.Name = nameNode.Value + } + return tm, nil + } err = readNameQueryObject(&tm, contentNode) if err != nil { return tm, err diff --git a/cmd/tools/template/template_test.go b/cmd/tools/template/template_test.go index abc861dff..e723d8f9b 100644 --- a/cmd/tools/template/template_test.go +++ b/cmd/tools/template/template_test.go @@ -372,6 +372,9 @@ func (m Metric) pathString() string { func TestQueryPrefix(t *testing.T) { visitTemplates(t, func(path string, model Model) { + if model.Ignore == "true" { + return + } if !strings.HasPrefix(model.Query, "api/") { t.Errorf("query should be prefixed with api/, got=%s path=[%s]", model.Query, shortPath(path)) } diff --git a/conf/rest/9.6.0/aggr_efficiency.yaml b/conf/rest/9.6.0/aggr_efficiency.yaml new file mode 100644 index 000000000..1d23f473d --- /dev/null +++ b/conf/rest/9.6.0/aggr_efficiency.yaml @@ -0,0 +1,7 @@ +name: AggregateEfficiency +# This template exists to prevent double exporting of aggregate efficiency metrics when +# using both the Rest and Zapi collectors, in that order. +# The Zapi collector exports aggregate efficiency objects via the AggregateEfficiency template +# while the REST collector exports them via the Aggregate template. That means the normal object/collector dedup logic +# won't handle these metrics. +ignore: true diff --git a/conf/rest/default.yaml b/conf/rest/default.yaml index 6e1791c48..258357c71 100644 --- a/conf/rest/default.yaml +++ b/conf/rest/default.yaml @@ -10,6 +10,7 @@ schedule: objects: Aggregate: aggr.yaml + AggregateEfficiency: aggr_efficiency.yaml # The CIFSSession template may slow down data collection due to a high number of metrics. # CIFSSession: cifs_session.yaml # CIFSShare: cifs_share.yaml