Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: json_v2 parser timestamp setting #10221

Merged
merged 1 commit into from
Dec 6, 2021
Merged
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
2 changes: 1 addition & 1 deletion plugins/parsers/json_v2/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ func (p *Parser) combineObject(result MetricNode) ([]telegraf.Metric, error) {
if err != nil {
return false
}
results = cartesianProduct(results, r)
results = cartesianProduct(r, results)
}

return true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
file,title=The\ Lord\ Of\ The\ Rings author="Tolkien",chapters="A Long-expected Party",name="Bilbo",species="hobbit",random=1
file,title=The\ Lord\ Of\ The\ Rings author="Tolkien",chapters="A Long-expected Party",name="Bilbo",species="hobbit",random=2
file,title=The\ Lord\ Of\ The\ Rings author="Tolkien",chapters="A Long-expected Party",name="Frodo",species="hobbit",random=1
file,title=The\ Lord\ Of\ The\ Rings author="Tolkien",chapters="A Long-expected Party",name="Frodo",species="hobbit",random=2
file,title=The\ Lord\ Of\ The\ Rings author="Tolkien",chapters="The Shadow of the Past",name="Bilbo",species="hobbit",random=1
file,title=The\ Lord\ Of\ The\ Rings author="Tolkien",chapters="The Shadow of the Past",name="Bilbo",species="hobbit",random=2
file,title=The\ Lord\ Of\ The\ Rings author="Tolkien",chapters="The Shadow of the Past",name="Frodo",species="hobbit",random=1
file,title=The\ Lord\ Of\ The\ Rings author="Tolkien",chapters="The Shadow of the Past",name="Frodo",species="hobbit",random=2
file,title=The\ Lord\ Of\ The\ Rings author="Tolkien",chapters="A Long-expected Party",name="Bilbo",random=1,species="hobbit"
file,title=The\ Lord\ Of\ The\ Rings author="Tolkien",chapters="The Shadow of the Past",name="Bilbo",random=1,species="hobbit"
file,title=The\ Lord\ Of\ The\ Rings author="Tolkien",chapters="A Long-expected Party",name="Frodo",random=1,species="hobbit"
file,title=The\ Lord\ Of\ The\ Rings author="Tolkien",chapters="The Shadow of the Past",name="Frodo",random=1,species="hobbit"
file,title=The\ Lord\ Of\ The\ Rings author="Tolkien",chapters="A Long-expected Party",name="Bilbo",random=2,species="hobbit"
file,title=The\ Lord\ Of\ The\ Rings author="Tolkien",chapters="The Shadow of the Past",name="Bilbo",random=2,species="hobbit"
file,title=The\ Lord\ Of\ The\ Rings author="Tolkien",chapters="A Long-expected Party",name="Frodo",random=2,species="hobbit"
file,title=The\ Lord\ Of\ The\ Rings author="Tolkien",chapters="The Shadow of the Past",name="Frodo",random=2,species="hobbit"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
metric,id=100 value=100.123 1609459199000000000
metric,id=101 value=200.001 1276605000000000000
metric,id=102 value=999.999 946684800000000000
19 changes: 19 additions & 0 deletions plugins/parsers/json_v2/testdata/object_timestamp/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"events": [
{
"id": 100,
"value": 100.123,
"time": "2020-12-31T23:59:59Z"
},
{
"id": 101,
"value": 200.001,
"time": "2010-06-15T12:30:00Z"
},
{
"id": 102,
"value": 999.999,
"time": "2000-01-01T00:00:00Z"
}
]
}
12 changes: 12 additions & 0 deletions plugins/parsers/json_v2/testdata/object_timestamp/telegraf.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[[inputs.file]]
files = ["./testdata/object_timestamp/input.json"]
data_format = "json_v2"

[[inputs.file.json_v2]]
measurement_name = "metric"

[[inputs.file.json_v2.object]]
path = "events"
tags = ["id"]
timestamp_key = "time"
timestamp_format = "2006-01-02T15:04:05Z"