Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions plugins/parsers/json_v2/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,10 @@ func (p *Parser) processObjects(input []byte, objects []Object, timestamp time.T
for _, c := range objects {
p.objectConfig = c

// The path results of a previous object are relative to that object's
// JSON and must not be matched against this one.
p.subPathResults = nil

if c.Path == "" {
return nil, errors.New("the GJSON path is required")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
energy production=100
energy consumption=200
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"production": {
"eim": {
"wattHoursLifetime": 100
}
},
"consumption": {
"eim": {
"wattHoursLifetime": 200
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Example taken from: https://github.com/influxdata/telegraf/issues/16361

[[inputs.file]]
files = ["./testdata/object_fields_with_same_path/input.json"]
data_format = "json_v2"
[[inputs.file.json_v2]]
measurement_name = "energy"
[[inputs.file.json_v2.object]]
path = "production.eim"
disable_prepend_keys = true
[[inputs.file.json_v2.object.field]]
path = "wattHoursLifetime"
rename = "production"
[[inputs.file.json_v2.object]]
path = "consumption.eim"
disable_prepend_keys = true
[[inputs.file.json_v2.object.field]]
path = "wattHoursLifetime"
rename = "consumption"
Loading