logstash-input-s3 3.1.8 → 3.1.9

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: 4a526bec73e4d07a3547e1470e6733e45087d3b3a9904af4489df0e5f8735c4c
4
- data.tar.gz: 80ff8f5c24cce9e91a8c848c2d31554188e6e685a2919d03122bb7eb95c5e024
3
+ metadata.gz: 60a19b3b0dff622aedd2d5dbbc373af2e7d778d0dadc50cbbccfb374ad81bca5
4
+ data.tar.gz: dcf91569049bb072699ec4134429bef539ccdd593a4096c99a944c2ea1b903b9
5
5
  SHA512:
6
- metadata.gz: 5d14998fbcbf09289e6c0fde186d2c56154dad02196b3e222ee5b85c959122b6e4d8dae4861676016b801b8ba2f9bbdf8341b7d4cad86d43d60bfacf9d50c548
7
- data.tar.gz: 16753788a73d9df21feb9bbb9ee82f8791c4a477563f0ffd44055a15e2463d654bd629815f20c30c0a5d680db79a240d6344713b584d6f11f2e7a87a73b489d0
6
+ metadata.gz: 8d4f33328b99e69f45d69740b434d30c8eea1e3ffe9d07faf021c350447520b3a5d227c99fdfbe7f52ddbd8812ae1c4d44605a08e44f3c1dbf20cca9ff756143
7
+ data.tar.gz: 6eaa8fa809d8b8ecb9390cf148b964edadca7aee861f94d0f4cb62c694f9d1a6174a19025c4286dcb1f694d3395bbd3013a432486009749c49d5d2961f284734
@@ -1,3 +1,8 @@
1
+ ## 3.1.9
2
+ - Change default sincedb path to live in `{path.data}/plugins/inputs/s3` instead of $HOME.
3
+ Prior Logstash installations (using $HOME default) are automatically migrated.
4
+ - Don't download the file if the length is 0 #2
5
+
1
6
  ## 3.1.8
2
7
  - Update gemspec summary
3
8
 
@@ -196,8 +196,9 @@ The AWS Session token for temporary credential
196
196
 
197
197
  Where to write the since database (keeps track of the date
198
198
  the last handled file was added to S3). The default will write
199
- sincedb files to some path matching "$HOME/.sincedb*"
200
- Should be a path with filename not just a directory.
199
+ sincedb files to in the directory '{path.data}/plugins/inputs/s3/'
200
+
201
+ If specified, this setting must be a filename path and not just a directory.
201
202
 
202
203
  [id="plugins-{type}s-{plugin}-temporary_directory"]
203
204
  ===== `temporary_directory`
@@ -211,4 +212,4 @@ default to the current OS temporary directory in linux /tmp/logstash
211
212
 
212
213
 
213
214
  [id="plugins-{type}s-{plugin}-common-options"]
214
- include::{include_path}/{type}.asciidoc[]
215
+ include::{include_path}/{type}.asciidoc[]
@@ -27,9 +27,11 @@ class LogStash::Inputs::S3 < LogStash::Inputs::Base
27
27
  # If specified, the prefix of filenames in the bucket must match (not a regexp)
28
28
  config :prefix, :validate => :string, :default => nil
29
29
 
30
- # Where to write the since database (keeps track of the date
31
- # the last handled file was added to S3). The default will write
32
- # sincedb files to some path matching "$HOME/.sincedb*"
30
+ # The path to use for writing state. The state stored by this plugin is
31
+ # a memory of files already processed by this plugin.
32
+ #
33
+ # If not specified, the default is in `{path.data}/plugins/inputs/s3/...`
34
+ #
33
35
  # Should be a path with filename not just a directory.
34
36
  config :sincedb_path, :validate => :string, :default => nil
35
37
 
@@ -102,7 +104,7 @@ class LogStash::Inputs::S3 < LogStash::Inputs::Base
102
104
  @logger.debug("S3 input: Found key", :key => log.key)
103
105
 
104
106
  unless ignore_filename?(log.key)
105
- if sincedb.newer?(log.last_modified)
107
+ if sincedb.newer?(log.last_modified) && log.content_length > 0
106
108
  objects[log.key] = log.last_modified
107
109
  @logger.debug("S3 input: Adding to objects[]", :key => log.key)
108
110
  @logger.debug("objects[] length is: ", :length => objects.length)
@@ -286,7 +288,29 @@ class LogStash::Inputs::S3 < LogStash::Inputs::Base
286
288
 
287
289
  private
288
290
  def sincedb_file
289
- File.join(ENV["HOME"], ".sincedb_" + Digest::MD5.hexdigest("#{@bucket}+#{@prefix}"))
291
+ digest = Digest::MD5.hexdigest("#{@bucket}+#{@prefix}")
292
+ dir = File.join(LogStash::SETTINGS.get_value("path.data"), "plugins", "inputs", "s3")
293
+ FileUtils::mkdir_p(dir)
294
+ path = File.join(dir, "sincedb_#{digest}")
295
+
296
+ # Migrate old default sincedb path to new one.
297
+ if ENV["HOME"]
298
+ # This is the old file path including the old digest mechanism.
299
+ # It remains as a way to automatically upgrade users with the old default ($HOME)
300
+ # to the new default (path.data)
301
+ old = File.join(ENV["HOME"], ".sincedb_" + Digest::MD5.hexdigest("#{@bucket}+#{@prefix}"))
302
+ if File.exist?(old)
303
+ logger.info("Migrating old sincedb in $HOME to {path.data}")
304
+ FileUtils.mv(old, path)
305
+ end
306
+ end
307
+
308
+ path
309
+ end
310
+
311
+
312
+ private
313
+ def old_sincedb_file
290
314
  end
291
315
 
292
316
  private
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-input-s3'
4
- s.version = '3.1.8'
4
+ s.version = '3.1.9'
5
5
  s.licenses = ['Apache License (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"
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.metadata = { "logstash_plugin" => "true", "logstash_group" => "input" }
21
21
 
22
22
  # Gem dependencies
23
- s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
23
+ s.add_runtime_dependency "logstash-core-plugin-api", ">= 2.1.12", "<= 2.99"
24
24
  s.add_runtime_dependency 'logstash-mixin-aws'
25
25
  s.add_runtime_dependency 'stud', '~> 0.0.18'
26
26
  # s.add_runtime_dependency 'aws-sdk-resources', '>= 2.0.33'
@@ -81,11 +81,11 @@ describe LogStash::Inputs::S3 do
81
81
  describe "#list_new_files" do
82
82
  before { allow_any_instance_of(Aws::S3::Bucket).to receive(:objects) { objects_list } }
83
83
 
84
- let!(:present_object) { double(:key => 'this-should-be-present', :last_modified => Time.now) }
84
+ let!(:present_object) { double(:key => 'this-should-be-present', :last_modified => Time.now, :content_length => 10) }
85
85
  let(:objects_list) {
86
86
  [
87
- double(:key => 'exclude-this-file-1', :last_modified => Time.now - 2 * day),
88
- double(:key => 'exclude/logstash', :last_modified => Time.now - 2 * day),
87
+ double(:key => 'exclude-this-file-1', :last_modified => Time.now - 2 * day, :content_length => 100),
88
+ double(:key => 'exclude/logstash', :last_modified => Time.now - 2 * day, :content_length => 50),
89
89
  present_object
90
90
  ]
91
91
  }
@@ -105,7 +105,7 @@ describe LogStash::Inputs::S3 do
105
105
  context "If the bucket is the same as the backup bucket" do
106
106
  it 'should ignore files from the bucket if they match the backup prefix' do
107
107
  objects_list = [
108
- double(:key => 'mybackup-log-1', :last_modified => Time.now),
108
+ double(:key => 'mybackup-log-1', :last_modified => Time.now, :content_length => 5),
109
109
  present_object
110
110
  ]
111
111
 
@@ -131,7 +131,7 @@ describe LogStash::Inputs::S3 do
131
131
  prefix = 'mysource/'
132
132
 
133
133
  objects_list = [
134
- double(:key => prefix, :last_modified => Time.now),
134
+ double(:key => prefix, :last_modified => Time.now, :content_length => 5),
135
135
  present_object
136
136
  ]
137
137
 
@@ -144,9 +144,9 @@ describe LogStash::Inputs::S3 do
144
144
 
145
145
  it 'should sort return object sorted by last_modification date with older first' do
146
146
  objects = [
147
- double(:key => 'YESTERDAY', :last_modified => Time.now - day),
148
- double(:key => 'TODAY', :last_modified => Time.now),
149
- double(:key => 'TWO_DAYS_AGO', :last_modified => Time.now - 2 * day)
147
+ double(:key => 'YESTERDAY', :last_modified => Time.now - day, :content_length => 5),
148
+ double(:key => 'TODAY', :last_modified => Time.now, :content_length => 5),
149
+ double(:key => 'TWO_DAYS_AGO', :last_modified => Time.now - 2 * day, :content_length => 5)
150
150
  ]
151
151
 
152
152
  allow_any_instance_of(Aws::S3::Bucket).to receive(:objects) { objects }
@@ -225,7 +225,7 @@ describe LogStash::Inputs::S3 do
225
225
 
226
226
  context 'when working with logs' do
227
227
  let(:objects) { [log] }
228
- let(:log) { double(:key => 'uncompressed.log', :last_modified => Time.now - 2 * day) }
228
+ let(:log) { double(:key => 'uncompressed.log', :last_modified => Time.now - 2 * day, :content_length => 5) }
229
229
  let(:data) { File.read(log_file) }
230
230
 
231
231
  before do
@@ -270,7 +270,7 @@ describe LogStash::Inputs::S3 do
270
270
  end
271
271
 
272
272
  context "multiple compressed streams" do
273
- let(:log) { double(:key => 'log.gz', :last_modified => Time.now - 2 * day) }
273
+ let(:log) { double(:key => 'log.gz', :last_modified => Time.now - 2 * day, :content_length => 5) }
274
274
  let(:log_file) { File.join(File.dirname(__FILE__), '..', 'fixtures', 'multiple_compressed_streams.gz') }
275
275
 
276
276
  include_examples "generated events" do
@@ -279,7 +279,7 @@ describe LogStash::Inputs::S3 do
279
279
  end
280
280
 
281
281
  context 'compressed' do
282
- let(:log) { double(:key => 'log.gz', :last_modified => Time.now - 2 * day) }
282
+ let(:log) { double(:key => 'log.gz', :last_modified => Time.now - 2 * day, :content_length => 5) }
283
283
  let(:log_file) { File.join(File.dirname(__FILE__), '..', 'fixtures', 'compressed.log.gz') }
284
284
 
285
285
  include_examples "generated events"
metadata CHANGED
@@ -1,21 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-s3
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.8
4
+ version: 3.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-07 00:00:00.000000000 Z
11
+ date: 2017-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: '1.60'
18
+ version: 2.1.12
19
19
  - - "<="
20
20
  - !ruby/object:Gem::Version
21
21
  version: '2.99'
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '1.60'
29
+ version: 2.1.12
30
30
  - - "<="
31
31
  - !ruby/object:Gem::Version
32
32
  version: '2.99'
@@ -152,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
152
  version: '0'
153
153
  requirements: []
154
154
  rubyforge_project:
155
- rubygems_version: 2.6.11
155
+ rubygems_version: 2.6.13
156
156
  signing_key:
157
157
  specification_version: 4
158
158
  summary: Streams events from files in a S3 bucket