[9.4](backport #52077) Fix silent event drop when a parser clears message content#52197
Open
mergify[bot] wants to merge 1 commit into
Open
[9.4](backport #52077) Fix silent event drop when a parser clears message content#52197mergify[bot] wants to merge 1 commit into
mergify[bot] wants to merge 1 commit into
Conversation
* Fix silent event drop when a parser clears message content * Update 1784536512-fix-awss3-readfile-drops-parser-fields.yaml * linter fixes * linter fixes (cherry picked from commit 786fbdc)
Contributor
🤖 GitHub commentsJust comment with:
|
|
Pinging @elastic/obs-ds-hosted-services (Team:obs-ds-hosted-services) |
6 tasks
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.
Proposed commit message
Fix silent event drop when a parser clears message content
A parser can move the decoded data into the event fields and clear the
content, for example an ndjson parser configured without a message_key. When
such an object was read through the readFile path (any content-type other than
application/json or application/x-ndjson), the input dropped every event with
no error logged, because it only published when the message content was
non-empty. Events are now published when either the content or the fields are
populated.
The bug was first seen in as SDH affecting a customer.
The
aws-s3input picks a read path based on each object's Content-Type. Objects served asapplication/jsonandapplication/x-ndjsongo through a JSON reader that ignores the configured parsers, so the missingmessage_keynever mattered. Any othercontent-typeroutes the object through the generic file-reader path, which does run thendjsonparser.Stage 1: the parser doesn't drop anything. With no
message_key, the parser returns empty content plus the parsed JSON, and writes those parsed keys into the event's fields:decode() returns empty content when no message_key
the parsed JSON is written into the event fields
So at this point the data is fully intact. It's in
message.Fields, onlymessage.Contenthas been cleared.Stage 2: the event is dropped here. In the S3 file-reader loop, there is a guard that only checks whether
message.Contentis non-empty. Since the parser emptied Content, the whole block is skipped, eventCallback is never called, and the fields that hold the data are discarded with no log line:readFile only emits when len(message.Content) > 0
Checklist
stresstest.shscript to run them under stress conditions and race detector to verify their stability../changelog/fragmentsusing the changelog tool.Disruptive User Impact
No. They actually fix a bug!
How to test this PR locally
This reproduces the customer's case: an integration policy with an
ndjsonparser and no
message_key, reading S3 objects whoseContent-Typeis notapplication/json/application/x-ndjson(e.g.text/plain).Before the fix no events are ingested and nothing is logged while after the fix the events are ingested with the JSON
decoded into their fields.
Related issues
Use cases
Screenshots
Logs
This is an automatic backport of pull request #52077 done by [Mergify](https://mergify.com).