fix: incorrect handling of json_v2 timestamp_path (#10618)

This commit is contained in:
Mark Rushakoff 2022-02-15 10:08:53 -05:00 committed by GitHub
parent fe299d968e
commit 25e8b45284
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 2 deletions

View File

@ -125,7 +125,7 @@ func (p *Parser) Parse(input []byte) ([]telegraf.Metric, error) {
}
var err error
p.timestamp, err = internal.ParseTimestamp(c.TimestampFormat, result.Raw, c.TimestampTimezone)
p.timestamp, err = internal.ParseTimestamp(c.TimestampFormat, result.String(), c.TimestampTimezone)
if err != nil {
return nil, err
}
@ -327,7 +327,7 @@ func (p *Parser) expandArray(result MetricNode) ([]telegraf.Metric, error) {
err := fmt.Errorf("use of 'timestamp_query' requires 'timestamp_format'")
return nil, err
}
timestamp, err := internal.ParseTimestamp(p.objectConfig.TimestampFormat, result.Raw, p.objectConfig.TimestampTimezone)
timestamp, err := internal.ParseTimestamp(p.objectConfig.TimestampFormat, result.String(), p.objectConfig.TimestampTimezone)
if err != nil {
return nil, err
}

View File

@ -0,0 +1 @@
file f="value" 1644434944000000000

View File

@ -0,0 +1,4 @@
{
"when": "2022-02-09T19:29:04Z",
"f": "value"
}

View File

@ -0,0 +1,8 @@
[[inputs.file]]
files = ["./testdata/timestamp_rfc3339/input.json"]
data_format = "json_v2"
[[inputs.file.json_v2]]
timestamp_path = "when"
timestamp_format = "rfc3339"
[[inputs.file.json_v2.field]]
path = "f"