fix: json_v2 parser timestamp setting (#10221)

This commit is contained in:
Joshua Powers 2021-12-06 12:18:06 -07:00 committed by GitHub
parent 7049967fa9
commit f9d719d636
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 43 additions and 9 deletions

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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"
}
]
}

View File

@ -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"