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

Final flush #223

Merged
merged 4 commits into from
Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 3.8.3
- Fix missing `metadata` and `type` of the last event [#223](https://github.com/logstash-plugins/logstash-input-s3/pull/223)

## 3.8.2
- Refactor: read sincedb time once per bucket listing [#233](https://github.com/logstash-plugins/logstash-input-s3/pull/233)

Expand Down
32 changes: 18 additions & 14 deletions lib/logstash/inputs/s3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -235,30 +235,34 @@ def process_local_log(queue, filename, object)
@logger.debug('Event is metadata, updating the current cloudfront metadata', :event => event)
update_metadata(metadata, event)
else
decorate(event)

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)
event.set(@cloudfront_version_key, metadata[:cloudfront_version]) unless metadata[:cloudfront_version].nil?
event.set(@cloudfront_fields_key, metadata[:cloudfront_fields]) unless metadata[:cloudfront_fields].nil?

queue << event
push_decoded_event(queue, metadata, object, event)
end
end
end
# #ensure any stateful codecs (such as multi-line ) are flushed to the queue
@codec.flush do |event|
queue << event
push_decoded_event(queue, metadata, object, event)
end

return true
end # def process_local_log

def push_decoded_event(queue, metadata, object, event)
decorate(event)

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)
event.set(@cloudfront_version_key, metadata[:cloudfront_version]) unless metadata[:cloudfront_version].nil?
event.set(@cloudfront_fields_key, metadata[:cloudfront_fields]) unless metadata[:cloudfront_fields].nil?

queue << event
end

def event_is_metadata?(event)
return false unless event.get("message").class == String
line = event.get("message")
Expand Down
2 changes: 1 addition & 1 deletion logstash-input-s3.gemspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Gem::Specification.new do |s|

s.name = 'logstash-input-s3'
s.version = '3.8.2'
s.version = '3.8.3'
s.licenses = ['Apache-2.0']
s.summary = "Streams events from files in a S3 bucket"
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
Expand Down
1 change: 1 addition & 0 deletions spec/inputs/s3_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@
events = fetch_events(config)
expect(events.size).to eq(events_to_process)
expect(events[0].get("[@metadata][s3][key]")).to eql log.key
expect(events[1].get("[@metadata][s3][key]")).to eql log.key
end

it "deletes the temporary file" do
Expand Down