diff --git a/plugins/parsers/json_v2/parser.go b/plugins/parsers/json_v2/parser.go index bb538d1bf..de977fafc 100644 --- a/plugins/parsers/json_v2/parser.go +++ b/plugins/parsers/json_v2/parser.go @@ -145,7 +145,7 @@ func (p *Parser) Parse(input []byte) ([]telegraf.Metric, error) { if result.Type == gjson.Null { p.Log.Debugf("Message: %s", input) - return nil, fmt.Errorf("the timestamp path %s returned NULL", c.TimestampPath) + return nil, fmt.Errorf("the timestamp path %q returned NULL", c.TimestampPath) } if !result.IsArray() && !result.IsObject() { if c.TimestampFormat == "" { @@ -218,7 +218,7 @@ func (p *Parser) processMetric(input []byte, data []DataSet, tag bool, timestamp } if result.IsObject() { - p.Log.Debugf("Found object in the path: %s, ignoring it please use 'object' to gather metrics from objects", c.Path) + p.Log.Debugf("Found object in the path %q, ignoring it please use 'object' to gather metrics from objects", c.Path) continue } @@ -704,11 +704,11 @@ func (p *Parser) checkResult(result gjson.Result, path string, optional bool) (b if !result.Exists() { if optional { // If path is marked as optional don't error if path doesn't return a result - p.Log.Debugf("the path %s doesn't exist", path) + p.Log.Debugf("the path %q doesn't exist", path) return true, nil } - return false, fmt.Errorf("the path %s doesn't exist", path) + return false, fmt.Errorf("the path %q doesn't exist", path) } return false, nil diff --git a/plugins/parsers/json_v2/testdata/wrong_path/expected.err b/plugins/parsers/json_v2/testdata/wrong_path/expected.err index 184a7ed7d..7da56bdd6 100644 --- a/plugins/parsers/json_v2/testdata/wrong_path/expected.err +++ b/plugins/parsers/json_v2/testdata/wrong_path/expected.err @@ -1,6 +1,6 @@ -the path wrong doesn't exist -the path wrong doesn't exist -the path wrong doesn't exist -the timestamp path wrong returned NULL -the path wrong doesn't exist -the path wrong doesn't exist +the path "wrong" doesn't exist +the path "wrong" doesn't exist +the path "wrong" doesn't exist +the timestamp path "wrong" returned NULL +the path "wrong" doesn't exist +the path "wrong" doesn't exist