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
@timestampas a String. It now parses ISO8601 strings into a Timestamp, matching JSON codec behavior. On parse failure, adds_timestampparsefailureand preserves the original value in"_@timestamp".What does this PR do?
@timestampinEvent.setField()@timestampset viasetFieldis converted to aTimestamp@timestamphandling between JSON codec and JSON filter@timestampto a Timestamp objectWhy is it important/What is the impact to the user?
@timestamphandling across input (codec) and filter paths@timestampby removing the need for a separatedatefilter in common casesImplementation notes
FieldReference.TIMESTAMP_REFERENCE("@timestamp") insideEvent.setField()and uses the sameinitTimestamp()logic used by the constructor, then callssetTimestamp()_timestampparsefailureand stores the original value in"_@timestamp"@timestamp; no impact to other fields or[@metadata]Checklist
Author's Checklist
initTimestamp) as the constructor@timestampand no impact to[@metadata]@timestampcoerced to Timestamp as intended)How to test this PR locally
Input:
{"@timestamp":"2023-12-01T10:30:00.000Z","foo":"bar"}Expected:
@timestamp: 2023-12-01T10:30:00.000Z (Timestamp object)foo: "bar"With the same input, should produce the same result as Pipeline (A).
{"@timestamp":"invalid-timestamp","foo":"bar"}Expected:
tagsincludes_timestampparsefailure"_@timestamp"contains"invalid-timestamp"@timestampis set to the current timeRelated issues
Use cases
@timestampcan rely on consistent application of the timestamp without a separatedatefilterScreenshots
Logs
@timestampappears as a time object (e.g.,2023-12-01T10:30:00.000Z)_timestampparsefailureintags, original value preserved in"_@timestamp"