Skip to content

Add decorate(event) in case of stateful codecs like multiline #173

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

Closed
wants to merge 1 commit into from

Conversation

duaraghav8
Copy link

@duaraghav8 duaraghav8 commented May 29, 2019

The decorate() method wasn't being called in case of stateful codecs before en-queuing the event. This resulted in type, tags and add_field options being ineffective when a user uses them with this plugin.
This PR fixes it

See issue #153

Thanks for contributing to Logstash! If you haven't already signed our CLA, here's a handy link: https://www.elastic.co/contributor-agreement/

The `decorate()` method wasn't being called in case of stateful codecs before en-queuing the event. This resulted in `type`, `tags` and `add_field` options being ineffective when a user uses them with this plugin.
This PR fixes it
@duaraghav8 duaraghav8 changed the title Fix #153 Add decorate(event) in case of stateful codecs like multiline May 29, 2019
@zuifanzhuce
Copy link

I'm using s3 and multiline, adding "decorate(event)" into s3.rb doesn't fix my issue. However, after adding all those below, the issue is gone.

@codec.flush do |event|
decorate(event)

  event.set("cloudfront_version", metadata[:cloudfront_version]) unless metadata[:cloudfront_version].nil?
  event.set("cloudfront_fields", metadata[:cloudfront_fields]) unless metadata[:cloudfront_fields].nil?

  if @include_object_properties
    event.set("[@metadata][s3]", object.data.to_h)
  else
    event.set("[@metadata][s3]", {})
  end

  event.set("[@metadata][s3][key]", object.key)
      
  queue << event
end

@roeezab
Copy link

roeezab commented Dec 24, 2019

I'm using s3 and multiline, adding "decorate(event)" into s3.rb doesn't fix my issue. However, after adding all those below, the issue is gone.

@codec.flush do |event|
decorate(event)

  event.set("cloudfront_version", metadata[:cloudfront_version]) unless metadata[:cloudfront_version].nil?
  event.set("cloudfront_fields", metadata[:cloudfront_fields]) unless metadata[:cloudfront_fields].nil?

  if @include_object_properties
    event.set("[@metadata][s3]", object.data.to_h)
  else
    event.set("[@metadata][s3]", {})
  end

  event.set("[@metadata][s3][key]", object.key)
      
  queue << event
end

It worked for me as well. Thanks @duaraghav8 and @zuifanzhuce!

@kaisecheng
Copy link
Contributor

The issue is fixed in 3.8.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants