feat(parsers/json_v2): Improve json path log messages (#13994)
This commit is contained in:
parent
21e8f9cc54
commit
f58c9555dd
|
|
@ -145,7 +145,7 @@ func (p *Parser) Parse(input []byte) ([]telegraf.Metric, error) {
|
||||||
|
|
||||||
if result.Type == gjson.Null {
|
if result.Type == gjson.Null {
|
||||||
p.Log.Debugf("Message: %s", input)
|
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 !result.IsArray() && !result.IsObject() {
|
||||||
if c.TimestampFormat == "" {
|
if c.TimestampFormat == "" {
|
||||||
|
|
@ -218,7 +218,7 @@ func (p *Parser) processMetric(input []byte, data []DataSet, tag bool, timestamp
|
||||||
}
|
}
|
||||||
|
|
||||||
if result.IsObject() {
|
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
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -704,11 +704,11 @@ func (p *Parser) checkResult(result gjson.Result, path string, optional bool) (b
|
||||||
if !result.Exists() {
|
if !result.Exists() {
|
||||||
if optional {
|
if optional {
|
||||||
// If path is marked as optional don't error if path doesn't return a result
|
// 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 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
|
return false, nil
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
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 path "wrong" doesn't exist
|
||||||
the timestamp path wrong returned NULL
|
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
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue