Fix JSON filter @timestamp parsing to match JSON codec behavior #17932
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Type of change
Release notes
@timestamp
as a String. It now parses ISO8601 strings into a Timestamp, matching JSON codec behavior. On parse failure, adds_timestampparsefailure
and preserves the original value in"_@timestamp"
.What does this PR do?
@timestamp
inEvent.setField()
@timestamp
set viasetField
is converted to aTimestamp
@timestamp
handling between JSON codec and JSON filter@timestamp
to a Timestamp objectWhy is it important/What is the impact to the user?
@timestamp
handling across input (codec) and filter paths@timestamp
by removing the need for a separatedate
filter in common casesImplementation notes
FieldReference.TIMESTAMP_REFERENCE
("@timestamp"
) insideEvent.setField()
and uses the sameinitTimestamp()
logic used by the constructor, then callssetTimestamp()
_timestampparsefailure
and stores the original value in"_@timestamp"
@timestamp
; no impact to other fields or[@metadata]
Checklist
Author's Checklist
initTimestamp
) as the constructor@timestamp
and no impact to[@metadata]
@timestamp
coerced to Timestamp as intended)How to test this PR locally
Input:
Expected:
@timestamp
: 2023-12-01T10:30:00.000Z (Timestamp object)foo
: "bar"With the same input, should produce the same result as Pipeline (A).
Expected:
tags
includes_timestampparsefailure
"_@timestamp"
contains"invalid-timestamp"
@timestamp
is set to the current timeRelated issues
Use cases
@timestamp
can rely on consistent application of the timestamp without a separatedate
filterScreenshots
Logs
@timestamp
appears as a time object (e.g.,2023-12-01T10:30:00.000Z
)_timestampparsefailure
intags
, original value preserved in"_@timestamp"