Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix extractor date converters #11750

Merged
merged 11 commits into from Dec 8, 2021
Merged

Fix extractor date converters #11750

merged 11 commits into from Dec 8, 2021

Conversation

patrickmann
Copy link
Contributor

#11149 introduced a regression with regard to date converter. This breaks scenarios that use the date converter to assign a non-standard date to the timestamp field.

With this PR, the date converter again works as it did in 4.1, while preserving the newly added functionality from 4.2 (with regard to timestamp).

Resolves #11495

@mpfz0r mpfz0r self-assigned this Dec 6, 2021
If the converter fails for a timestamp value,
run the fallback timestamp conversion, to ensure that a Message
always has a valid timestamp.
Showing only the details is not helpful in some cases.
We don't need to call removeField before addField.
It will just overwrite the value anyway.
This avoids having to recalculate the message size twice.

Only null values don't get set. Those we need to remove explicitly.
@mpfz0r mpfz0r changed the title Fix regression when using date converter #11495 Fix extractor date converters Dec 8, 2021
Copy link
Member

@mpfz0r mpfz0r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍 Thanks for fixing this

@mpfz0r mpfz0r merged commit d12d846 into master Dec 8, 2021
@mpfz0r mpfz0r deleted the converter_compat branch December 8, 2021 12:01
mpfz0r pushed a commit that referenced this pull request Dec 8, 2021
* Fix regression when using date converter #11495

* get tests passing

* Run timestamp fallback conversion

If the converter fails for a timestamp value,
run the fallback timestamp conversion, to ensure that a Message
always has a valid timestamp.

* Add tests

* Improve gl2_processing_error message

Showing only the details is not helpful in some cases.

* Improve converter code

We don't need to call removeField before addField.
It will just overwrite the value anyway.
This avoids having to recalculate the message size twice.

Only null values don't get set. Those we need to remove explicitly.

* adjust test to new processing error output

* improve comments

Co-authored-by: Marco Pfatschbacher <marco@graylog.com>
(cherry picked from commit d12d846)
patrickmann added a commit that referenced this pull request Dec 9, 2021
* Fix regression when using date converter #11495

* get tests passing

* Run timestamp fallback conversion

If the converter fails for a timestamp value,
run the fallback timestamp conversion, to ensure that a Message
always has a valid timestamp.

* Add tests

* Improve gl2_processing_error message

Showing only the details is not helpful in some cases.

* Improve converter code

We don't need to call removeField before addField.
It will just overwrite the value anyway.
This avoids having to recalculate the message size twice.

Only null values don't get set. Those we need to remove explicitly.

* adjust test to new processing error output

* improve comments

Co-authored-by: Marco Pfatschbacher <marco@graylog.com>
(cherry picked from commit d12d846)

Co-authored-by: Patrick Mann <patrickmann@users.noreply.github.com>
linuspahl pushed a commit that referenced this pull request Dec 13, 2021
* Fix regression when using date converter #11495

* get tests passing

* Run timestamp fallback conversion

If the converter fails for a timestamp value,
run the fallback timestamp conversion, to ensure that a Message
always has a valid timestamp.

* Add tests

* Improve gl2_processing_error message

Showing only the details is not helpful in some cases.

* Improve converter code

We don't need to call removeField before addField.
It will just overwrite the value anyway.
This avoids having to recalculate the message size twice.

Only null values don't get set. Those we need to remove explicitly.

* adjust test to new processing error output

* improve comments

Co-authored-by: Marco Pfatschbacher <marco@graylog.com>
linuspahl pushed a commit that referenced this pull request Dec 13, 2021
* Fix regression when using date converter #11495

* get tests passing

* Run timestamp fallback conversion

If the converter fails for a timestamp value,
run the fallback timestamp conversion, to ensure that a Message
always has a valid timestamp.

* Add tests

* Improve gl2_processing_error message

Showing only the details is not helpful in some cases.

* Improve converter code

We don't need to call removeField before addField.
It will just overwrite the value anyway.
This avoids having to recalculate the message size twice.

Only null values don't get set. Those we need to remove explicitly.

* adjust test to new processing error output

* improve comments

Co-authored-by: Marco Pfatschbacher <marco@graylog.com>
mpfz0r added a commit that referenced this pull request Dec 28, 2021
With #11149 we introduced a change that ensured that a message will
have a valid DateTime as the timestamp field.
The conversion or fallback (plus recording errors) was performed when
setting the `timestamp` field.

This caused problems (#11495) with date converters on extractors.
They work by first assiging the non-converted timestamp string to the
message, and then use this string in the date converter.
A fix for this was done in #11750

However, looking at another user's issue with a json extractor
(#11495 (comment))
made me rethink the previous approach.

Our processing works by mutating a Message object and thus passing field
values from one processing step to another.
Enforcing a DateTime object on the timestamp field in the middle of the
processing has the potential to break configurations where multiple
steps are taken to convert a field.
E.g. the json extractor will just assign a tempoarary timestamp string,
which will later be converted using a pipeline rule.

Therefore, we only perform timestamp conversion/fallback under two
circumstances:

 - The processing is completed
 - An explicit call to Message.getTimestamp() is made
patrickmann pushed a commit that referenced this pull request Jan 4, 2022
With #11149 we introduced a change that ensured that a message will
have a valid DateTime as the timestamp field.
The conversion or fallback (plus recording errors) was performed when
setting the `timestamp` field.

This caused problems (#11495) with date converters on extractors.
They work by first assiging the non-converted timestamp string to the
message, and then use this string in the date converter.
A fix for this was done in #11750

However, looking at another user's issue with a json extractor
(#11495 (comment))
made me rethink the previous approach.

Our processing works by mutating a Message object and thus passing field
values from one processing step to another.
Enforcing a DateTime object on the timestamp field in the middle of the
processing has the potential to break configurations where multiple
steps are taken to convert a field.
E.g. the json extractor will just assign a tempoarary timestamp string,
which will later be converted using a pipeline rule.

Therefore, we only perform timestamp conversion/fallback under two
circumstances:

 - The processing is completed
 - An explicit call to Message.getTimestamp() is made
mpfz0r added a commit that referenced this pull request Jan 5, 2022
With #11149 we introduced a change that ensured that a message will
have a valid DateTime as the timestamp field.
The conversion or fallback (plus recording errors) was performed when
setting the `timestamp` field.

This caused problems (#11495) with date converters on extractors.
They work by first assiging the non-converted timestamp string to the
message, and then use this string in the date converter.
A fix for this was done in #11750

However, looking at another user's issue with a json extractor
(#11495 (comment))
made me rethink the previous approach.

Our processing works by mutating a Message object and thus passing field
values from one processing step to another.
Enforcing a DateTime object on the timestamp field in the middle of the
processing has the potential to break configurations where multiple
steps are taken to convert a field.
E.g. the json extractor will just assign a tempoarary timestamp string,
which will later be converted using a pipeline rule.

Therefore, we only perform timestamp conversion/fallback under two
circumstances:

 - The processing is completed
 - An explicit call to Message.getTimestamp() is made

(cherry picked from commit 7bdef92)
patrickmann pushed a commit that referenced this pull request Jan 5, 2022
With #11149 we introduced a change that ensured that a message will
have a valid DateTime as the timestamp field.
The conversion or fallback (plus recording errors) was performed when
setting the `timestamp` field.

This caused problems (#11495) with date converters on extractors.
They work by first assiging the non-converted timestamp string to the
message, and then use this string in the date converter.
A fix for this was done in #11750

However, looking at another user's issue with a json extractor
(#11495 (comment))
made me rethink the previous approach.

Our processing works by mutating a Message object and thus passing field
values from one processing step to another.
Enforcing a DateTime object on the timestamp field in the middle of the
processing has the potential to break configurations where multiple
steps are taken to convert a field.
E.g. the json extractor will just assign a tempoarary timestamp string,
which will later be converted using a pipeline rule.

Therefore, we only perform timestamp conversion/fallback under two
circumstances:

 - The processing is completed
 - An explicit call to Message.getTimestamp() is made

(cherry picked from commit 7bdef92)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

processing error after migrating to 4.2.0-3
2 participants