Allow JSON data format to contain zero metrics (#3268)
(cherry picked from commit 22a9ffbb9d)
This commit is contained in:
committed by
Daniel Nelson
parent
0e0da57b9a
commit
47b2d04d5b
@@ -67,6 +67,10 @@ func (p *JSONParser) parseObject(metrics []telegraf.Metric, jsonOut map[string]i
|
||||
}
|
||||
|
||||
func (p *JSONParser) Parse(buf []byte) ([]telegraf.Metric, error) {
|
||||
buf = bytes.TrimSpace(buf)
|
||||
if len(buf) == 0 {
|
||||
return make([]telegraf.Metric, 0), nil
|
||||
}
|
||||
|
||||
if !isarray(buf) {
|
||||
metrics := make([]telegraf.Metric, 0)
|
||||
|
||||
Reference in New Issue
Block a user