Skip to content

Commit

Permalink
fix: don't double export aggregate efficiency metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
cgrinds committed Oct 24, 2024
1 parent 2c619b0 commit 7f1dae4
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/collectors/rest/templating.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 4 additions & 0 deletions cmd/poller/poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 10 additions & 0 deletions cmd/tools/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions cmd/tools/template/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
7 changes: 7 additions & 0 deletions conf/rest/9.6.0/aggr_efficiency.yaml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions conf/rest/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7f1dae4

Please sign in to comment.