Repository navigation
filter_parser: describe how reserve_data handles invalid records - #733
Merged
Watson1978 merged 2 commits intoNov 30, 2026
Merged
Conversation
The emit_invalid_record_to_error section listed the three invalid cases, but did not say that reserve_data changes what happens to the record. In filter_parser, with reserve_data true, a record whose key_name does not exist is passed through as it is, and so is a record whose value the parser returns no record for. A record whose parsing raises an error, such as a time field that does not match time_format, is still discarded. Since emit_invalid_record_to_error is true by default, a record passed through is also emitted to the @error label. Add a table of the behavior per case, explain the cases and the duplication with the default emit_invalid_record_to_error, and show a configuration that only passes the records through. Also point to it from the reserve_data section. Fixes fluent#442 Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com>
👷 Deploy request for fluentd-docs pending review.Visit the deploys page to approve it
|
Watson1978
requested changes
Nov 29, 2026
Watson1978
left a comment
Contributor
There was a problem hiding this comment.
Thanks for documenting this. I checked the table, the example output, and the hash_value_field note against Fluentd v1.20.1 and the current master, and they match. The four links also match the heading anchors on docs.fluentd.org.
One part needs a fix. The invalid byte sequence example of "an unexpected error" depends on the parser, and it does not apply to the json parser. The other comment is optional.
The invalid byte sequence example of an unexpected error applies to the regexp parser, not to the json parser, which treats such a value as not matched or parses it. Name the regexp parser for it, and say that the json and regexp parsers raise when the time field cannot be parsed with time_format. Also note that a key_name field whose value is null is handled as a missing key, that with emit_invalid_record_to_error false a record whose parsing raises an error is dropped without an error event or a log, and that the record emitted to @error does not get the empty hash_value_field hash. Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com>
Watson1978
approved these changes
Nov 30, 2026
Watson1978
left a comment
Contributor
There was a problem hiding this comment.
Thanks for applying both suggestions. I reran the cases from my previous review on Fluentd v1.20.1 and the current master, and the results match the updated text. LGTM.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The
emit_invalid_record_to_errorsection of the parser filter article lists the three invalid cases. It does not say thatreserve_datachanges what happens to the record. This adds the explanation planned in #442:reserve_data falseandreserve_data true. Withreserve_data true, a record whosekey_nameis missing passes through as is. So does a record whose value the parser returns no record for. A record whose parsing raises an error is still discarded. Akey_namefield whose value isnullcounts as a missing key.jsonandregexpparsers yield no record for a value. The second is when the parser raises, for example on a time field that cannot be parsed withtime_format, or, with theregexpparser, on an invalid byte sequence whilereplace_invalid_sequenceisfalse.emit_invalid_record_to_errordefaults totrue, so a record passed through withreserve_data trueis also emitted to@ERROR. The section shows a configuration that only passes the records through, with its result. With that configuration, a record whose parsing raises an error is dropped without an error event or a log.hash_value_field, a record passed through gets an empty hash in that field. The record emitted to@ERRORdoes not get the empty hash.reserve_datasection now points to this explanation.The behavior described comes from
filter_stream,filter_one_recordandhandle_parsedinlib/fluent/plugin/filter_parser.rb. Parse errors from time parsing come fromParser#parse_time.Fixes #442