logstash-input-s3 3.3.6 → 3.3.7

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
  SHA256:
3
- metadata.gz: 33d02e0410e180a35672fc42215f5758ab34592b0acbac20caeedc3b2c555f8c
4
- data.tar.gz: 5010dba8d504458b455a4941db2de4accd039b8ff47eeeb31da4059d0580847f
3
+ metadata.gz: b6b2e69a2cc95f3fc7bdcc0a5b828e08a3795d88f5468795fafc4a518b7e4128
4
+ data.tar.gz: 5a1d0103482e624fe8131eed9c28e636c71bb38b70980e463e1548bcb7efaff1
5
5
  SHA512:
6
- metadata.gz: 57ad952479ee8ac3a8582898f630e1db633101a595693566dd7697f4f70b7fc74568f1ab6da95e9498bae49f73dc6a4d76e96b28d677eab492965fc70e948f99
7
- data.tar.gz: 34d23aebf95e88011d9bb6c2d4e6a14a2e7fc8110003672c9c703613bcbba095f5311043906022fcec443424b865c87b48d49682a13d5667d7fd5184deadb949
6
+ metadata.gz: 7cb50c30b2acdd5f8da2602346b0fc9b3ef82f4dd5d1649e7cff8e7d746c28ef0e997cb8db8c1821639e3e8b8001ef19e2c8a0557d5b8a6f37ea9b5a27e451f8
7
+ data.tar.gz: 41be7059efac9cd05b2379a5035cc11104bd7c9716939ac9a2c63aa94ee7bbf79832c7219492ce5576987d36bae038c530af64c11e021c89dee47aa53ea4bf51
@@ -1,3 +1,6 @@
1
+ ## 3.3.7
2
+ - Added ability to optionally include S3 object properties inside @metadata [#155](https://github.com/logstash-plugins/logstash-input-s3/pull/155)
3
+
1
4
  ## 3.3.6
2
5
  - Fixed error in documentation by removing illegal commas [#154](https://github.com/logstash-plugins/logstash-input-s3/pull/154)
3
6
 
@@ -44,6 +44,7 @@ This plugin supports the following configuration options plus the <<plugins-{typ
44
44
  | <<plugins-{type}s-{plugin}-delete>> |<<boolean,boolean>>|No
45
45
  | <<plugins-{type}s-{plugin}-endpoint>> |<<string,string>>|No
46
46
  | <<plugins-{type}s-{plugin}-exclude_pattern>> |<<string,string>>|No
47
+ | <<plugins-{type}s-{plugin}-include_object_properties>> |<<boolean,boolean>>|No
47
48
  | <<plugins-{type}s-{plugin}-interval>> |<<number,number>>|No
48
49
  | <<plugins-{type}s-{plugin}-prefix>> |<<string,string>>|No
49
50
  | <<plugins-{type}s-{plugin}-proxy_uri>> |<<string,string>>|No
@@ -176,6 +177,15 @@ the connection to s3. See full list in https://docs.aws.amazon.com/sdkforruby/ap
176
177
  }
177
178
  }
178
179
 
180
+ [id="plugins-{type}s-{plugin}-include_object_properties"]
181
+ ===== `include_object_properties`
182
+
183
+ * Value type is <<boolean,boolean>>
184
+ * Default value is `false`
185
+
186
+ Whether or not to include the S3 object's properties (last_modified, content_type, metadata) into each Event at
187
+ `[@metadata][s3]`. Regardless of this setting, `[@metdata][s3][key]` will always be present.
188
+
179
189
  [id="plugins-{type}s-{plugin}-interval"]
180
190
  ===== `interval`
181
191
 
@@ -70,6 +70,11 @@ class LogStash::Inputs::S3 < LogStash::Inputs::Base
70
70
  # default to the current OS temporary directory in linux /tmp/logstash
71
71
  config :temporary_directory, :validate => :string, :default => File.join(Dir.tmpdir, "logstash")
72
72
 
73
+ # Whether or not to include the S3 object's properties (last_modified, content_type, metadata)
74
+ # into each Event at [@metadata][s3]. Regardless of this setting, [@metdata][s3][key] will always
75
+ # be present.
76
+ config :include_object_properties, :validate => :boolean, :default => false
77
+
73
78
  public
74
79
  def register
75
80
  require "fileutils"
@@ -177,8 +182,9 @@ class LogStash::Inputs::S3 < LogStash::Inputs::Base
177
182
  #
178
183
  # @param [Queue] Where to push the event
179
184
  # @param [String] Which file to read from
185
+ # @param [S3Object] Source s3 object
180
186
  # @return [Boolean] True if the file was completely read, false otherwise.
181
- def process_local_log(queue, filename, key)
187
+ def process_local_log(queue, filename, object)
182
188
  @logger.debug('Processing file', :filename => filename)
183
189
  metadata = {}
184
190
  # Currently codecs operates on bytes instead of stream.
@@ -209,7 +215,13 @@ class LogStash::Inputs::S3 < LogStash::Inputs::Base
209
215
  event.set("cloudfront_version", metadata[:cloudfront_version]) unless metadata[:cloudfront_version].nil?
210
216
  event.set("cloudfront_fields", metadata[:cloudfront_fields]) unless metadata[:cloudfront_fields].nil?
211
217
 
212
- event.set("[@metadata][s3]", { "key" => key })
218
+ if @include_object_properties
219
+ event.set("[@metadata][s3]", object.data.to_h)
220
+ else
221
+ event.set("[@metadata][s3]", {})
222
+ end
223
+
224
+ event.set("[@metadata][s3][key]", object.key)
213
225
 
214
226
  queue << event
215
227
  end
@@ -365,7 +377,7 @@ class LogStash::Inputs::S3 < LogStash::Inputs::Base
365
377
 
366
378
  filename = File.join(temporary_directory, File.basename(key))
367
379
  if download_remote_file(object, filename)
368
- if process_local_log(queue, filename, key)
380
+ if process_local_log(queue, filename, object)
369
381
  lastmod = object.last_modified
370
382
  backup_to_bucket(object)
371
383
  backup_to_dir(filename)
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-input-s3'
4
- s.version = '3.3.6'
4
+ s.version = '3.3.7'
5
5
  s.licenses = ['Apache-2.0']
6
6
  s.summary = "Streams events from files in a S3 bucket"
7
7
  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"
@@ -277,7 +277,7 @@ describe LogStash::Inputs::S3 do
277
277
  it 'should process events' do
278
278
  events = fetch_events(config)
279
279
  expect(events.size).to eq(events_to_process)
280
- insist { events[0].get("[@metadata][s3]") } == {"key" => log.key }
280
+ insist { events[0].get("[@metadata][s3][key]") } == log.key
281
281
  end
282
282
 
283
283
  it "deletes the temporary file" do
@@ -344,7 +344,7 @@ describe LogStash::Inputs::S3 do
344
344
 
345
345
  context 'when working with logs' do
346
346
  let(:objects) { [log] }
347
- let(:log) { double(:key => 'uncompressed.log', :last_modified => Time.now - 2 * day, :content_length => 5) }
347
+ let(:log) { double(:key => 'uncompressed.log', :last_modified => Time.now - 2 * day, :content_length => 5, :data => { "etag" => 'c2c966251da0bc3229d12c2642ba50a4' }) }
348
348
  let(:data) { File.read(log_file) }
349
349
 
350
350
  before do
@@ -451,5 +451,34 @@ describe LogStash::Inputs::S3 do
451
451
 
452
452
  include_examples "generated events"
453
453
  end
454
+
455
+ context 'when include_object_properties is set to true' do
456
+ let(:config) { super.merge({ "include_object_properties" => true }) }
457
+ let(:log_file) { File.join(File.dirname(__FILE__), '..', 'fixtures', 'uncompressed.log') }
458
+
459
+ it 'should extract object properties onto [@metadata][s3]' do
460
+ events = fetch_events(config)
461
+ events.each do |event|
462
+ expect(event.get('[@metadata][s3]')).to include(log.data)
463
+ end
464
+ end
465
+
466
+ include_examples "generated events"
467
+ end
468
+
469
+ context 'when include_object_properties is set to false' do
470
+ let(:config) { super.merge({ "include_object_properties" => false }) }
471
+ let(:log_file) { File.join(File.dirname(__FILE__), '..', 'fixtures', 'uncompressed.log') }
472
+
473
+ it 'should NOT extract object properties onto [@metadata][s3]' do
474
+ events = fetch_events(config)
475
+ events.each do |event|
476
+ expect(event.get('[@metadata][s3]')).to_not include(log.data)
477
+ end
478
+ end
479
+
480
+ include_examples "generated events"
481
+ end
482
+
454
483
  end
455
484
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-s3
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.6
4
+ version: 3.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-19 00:00:00.000000000 Z
11
+ date: 2018-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement