fix: incorrect handling of json_v2 timestamp_path (#10618)
This commit is contained in:
parent
fe299d968e
commit
25e8b45284
|
|
@ -125,7 +125,7 @@ func (p *Parser) Parse(input []byte) ([]telegraf.Metric, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var err 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 {
|
if err != nil {
|
||||||
return nil, err
|
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'")
|
err := fmt.Errorf("use of 'timestamp_query' requires 'timestamp_format'")
|
||||||
return nil, err
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
file f="value" 1644434944000000000
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"when": "2022-02-09T19:29:04Z",
|
||||||
|
"f": "value"
|
||||||
|
}
|
||||||
|
|
@ -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"
|
||||||
Loading…
Reference in New Issue