fix(parsers/xpath): Reduce debug messages when empty selection is allowed (#11302)

This commit is contained in:
Thomas Casteleyn 2022-06-15 21:10:02 +02:00 committed by GitHub
parent 05285a1fdb
commit 2424852aa7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 4 deletions

View File

@ -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))