logstash-input-s3 3.3.6 → 3.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/docs/index.asciidoc +10 -0
- data/lib/logstash/inputs/s3.rb +15 -3
- data/logstash-input-s3.gemspec +1 -1
- data/spec/inputs/s3_spec.rb +31 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6b2e69a2cc95f3fc7bdcc0a5b828e08a3795d88f5468795fafc4a518b7e4128
|
4
|
+
data.tar.gz: 5a1d0103482e624fe8131eed9c28e636c71bb38b70980e463e1548bcb7efaff1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cb50c30b2acdd5f8da2602346b0fc9b3ef82f4dd5d1649e7cff8e7d746c28ef0e997cb8db8c1821639e3e8b8001ef19e2c8a0557d5b8a6f37ea9b5a27e451f8
|
7
|
+
data.tar.gz: 41be7059efac9cd05b2379a5035cc11104bd7c9716939ac9a2c63aa94ee7bbf79832c7219492ce5576987d36bae038c530af64c11e021c89dee47aa53ea4bf51
|
data/CHANGELOG.md
CHANGED
@@ -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
|
|
data/docs/index.asciidoc
CHANGED
@@ -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
|
|
data/lib/logstash/inputs/s3.rb
CHANGED
@@ -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,
|
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
|
-
|
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,
|
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)
|
data/logstash-input-s3.gemspec
CHANGED
@@ -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.
|
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"
|
data/spec/inputs/s3_spec.rb
CHANGED
@@ -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]") } ==
|
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.
|
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-
|
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
|