logstash-input-s3-sns-sqs 1.4.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa00cb9383c9782647f404283f10281febb31622
4
- data.tar.gz: a8fe32f0d3668c893ff5ef5cd253e02dee8f4fd5
3
+ metadata.gz: b252a2e8b2c9ef1fa911f4f3032508ddfda53411
4
+ data.tar.gz: 10b201c1f0e1a2a5858682efa109c99da3d0d3bf
5
5
  SHA512:
6
- metadata.gz: a602a1a99073817666f83f0f0194e953c3ee6a75efd5e4e2faf4a44a1d19323133ea0c96e6fab7d306ec75f2f6384c936f2f1a134b6639e4ffe645c76af727f4
7
- data.tar.gz: 8652e9ecc5c3b9342dabb842c8258adcf52f28d5184dae8f3e1bd27ffed0bac0333a79f2055be4a55bbb2e0849db8ac5426d6936fafe1c96ac25a1701038d58f
6
+ metadata.gz: 75f71948df7e26e7ac607219532cdb1a8df156ada93dab895560fbcf215b06308e1e900cc6c21450d395a9ec5d48a841e6c3104fd244e380074e2337088d6d5a
7
+ data.tar.gz: ad9ef3e7094750e8976cd6b02ebfb9cbedbf4ac15ee6585b91c76d9de237436bf8e3a684cbed336db029e0c0c1a748b6989a12af73e4bce2487e0194699b0159
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.4.1
2
+ - Fix: Last event in file not decorated
3
+ - Adjust metadata namings
4
+ - Event decoration in private method now.
1
5
  ## 1.4.0
2
6
  - Filehandling rewritten THX to logstash-input-s3 for inspiration
3
7
  - Improve performance of gzip decoding by 10x by using Java's Zlib
@@ -98,6 +98,9 @@ class LogStash::Inputs::S3SNSSQS < LogStash::Inputs::Threadable
98
98
 
99
99
  default :codec, "plain"
100
100
 
101
+ # The message string to use in the event.
102
+ config :message, :validate => :string, :default => "Hello World!"
103
+
101
104
  # Name of the SQS Queue to pull messages from. Note that this is just the name of the queue, not the URL or ARN.
102
105
  config :queue, :validate => :string, :required => true
103
106
  config :s3_key_prefix, :validate => :string, :default => ''
@@ -203,7 +206,7 @@ class LogStash::Inputs::S3SNSSQS < LogStash::Inputs::Threadable
203
206
  object = s3bucket.object(key)
204
207
  filename = File.join(temporary_directory, File.basename(key))
205
208
  if download_remote_file(object, filename)
206
- if process_local_log( filename, key, instance_codec, queue)
209
+ if process_local_log( filename, key, instance_codec, queue, bucket)
207
210
  delete_file_from_bucket(object)
208
211
  FileUtils.remove_entry_secure(filename, true)
209
212
  end
@@ -237,10 +240,9 @@ class LogStash::Inputs::S3SNSSQS < LogStash::Inputs::Threadable
237
240
  # @param [Queue] Where to push the event
238
241
  # @param [String] Which file to read from
239
242
  # @return [Boolean] True if the file was completely read, false otherwise.
240
- def process_local_log(filename, key, instance_codec, queue)
243
+ def process_local_log(filename, key, instance_codec, queue, bucket)
241
244
  @logger.debug('Processing file', :filename => filename)
242
245
  metadata = {}
243
- i=1
244
246
  # Currently codecs operates on bytes instead of stream.
245
247
  # So all IO stuff: decompression, reading need to be done in the actual
246
248
  # input and send as bytes to the codecs.
@@ -262,37 +264,42 @@ class LogStash::Inputs::S3SNSSQS < LogStash::Inputs::Threadable
262
264
  # The line need to go through the codecs to replace
263
265
  # unknown bytes in the log stream before doing a regexp match or
264
266
  # you will get a `Error: invalid byte sequence in UTF-8'
265
- #event = LogStash::Event.new("message" => @message)
266
- if event_is_metadata?(event)
267
- @logger.debug('Event is metadata, updating the current cloudfront metadata', :event => event)
268
- update_metadata(metadata, event)
269
- else
270
-
271
- decorate(event)
272
-
273
- event.set("cloudfront_version", metadata[:cloudfront_version]) unless metadata[:cloudfront_version].nil?
274
- event.set("cloudfront_fields", metadata[:cloudfront_fields]) unless metadata[:cloudfront_fields].nil?
275
-
276
- event.set("[@metadata][s3]", { "key" => key })
277
-
278
- if match=/#{s3_key_prefix}\/?(?<type_folder>.*?)\/.*/.match(key)
279
- event.set('[@metadata][s3_object_folder]', match['type_folder'])
280
- end
281
- #@logger.info("queue event #{i}")
282
- #i += 1
283
- queue << event
284
- end
267
+ local_decorate(event, key, metadata, bucket)
268
+ queue << event
285
269
  end
286
270
  end
271
+ @logger.debug("end if file #{filename}")
287
272
  #@logger.info("event pre flush", :event => event)
288
273
  # #ensure any stateful codecs (such as multi-line ) are flushed to the queue
289
274
  instance_codec.flush do |event|
275
+ local_decorate(event, key, metadata, bucket)
276
+ @logger.debug("We´e to flush an incomplete event...", :event => event)
290
277
  queue << event
291
278
  end
292
279
 
293
280
  return true
294
281
  end # def process_local_log
295
282
 
283
+ private
284
+ def local_decorate(event, key, metadata, bucket)
285
+ if event_is_metadata?(event)
286
+ @logger.debug('Event is metadata, updating the current cloudfront metadata', :event => event)
287
+ update_metadata(metadata, event)
288
+ else
289
+
290
+ decorate(event)
291
+
292
+ event.set("cloudfront_version", metadata[:cloudfront_version]) unless metadata[:cloudfront_version].nil?
293
+ event.set("cloudfront_fields", metadata[:cloudfront_fields]) unless metadata[:cloudfront_fields].nil?
294
+
295
+ event.set("[@metadata][s3]", { "object_key" => key })
296
+ event.set("[@metadata][s3]", { "bucket_name" => bucket })
297
+ if match=/#{s3_key_prefix}\/?(?<type_folder>.*?)\/.*/.match(key)
298
+ event.set('[@metadata][s3]', {"s3_object_folder" => match['type_folder']})
299
+ end
300
+ end
301
+ end
302
+
296
303
  private
297
304
  def read_file(filename, &block)
298
305
  if gzip?(filename)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-input-s3-sns-sqs'
3
- s.version = '1.4.0'
3
+ s.version = '1.4.1'
4
4
  s.licenses = ['Apache License (2.0)']
5
5
  s.summary = "Get logs from AWS s3 buckets as issued by an object-created event via sns -> sqs."
6
6
  s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-s3-sns-sqs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Herweg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-16 00:00:00.000000000 Z
11
+ date: 2018-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement