Skip to content

Commit

Permalink
fix(parsers/xpath): Reduce debug messages when empty selection is all…
Browse files Browse the repository at this point in the history
…owed (#11302)
  • Loading branch information
Hipska authored and MyaLongmire committed Jul 6, 2022
1 parent c0e381a commit 9cf0d72
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions plugins/parsers/xpath/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,9 @@ func (p *Parser) Parse(buf []byte) ([]telegraf.Metric, error) {
if err != nil {
return nil, err
}
if len(selectedNodes) < 1 || selectedNodes[0] == nil {
if (len(selectedNodes) < 1 || selectedNodes[0] == nil) && !p.AllowEmptySelection {
p.debugEmptyQuery("metric selection", doc, config.Selection)
if !p.AllowEmptySelection {
return metrics, fmt.Errorf("cannot parse with empty selection node")
}
return metrics, fmt.Errorf("cannot parse with empty selection node")
}
p.Log.Debugf("Number of selected metric nodes: %d", len(selectedNodes))

Expand Down

0 comments on commit 9cf0d72

Please sign in to comment.