Skip to content

Commit b8fd12d

Browse files
shamilrobbavey
authored andcommitted
add support for setting mutipart upload threshold (logstash-plugins#202)
* add support for setting mutipar upload threshold * Add upload_multipart_threshold to docs * Apply sorting in docs * CHANGELOG and version bump
1 parent c8169d7 commit b8fd12d

File tree

5 files changed

+35
-2
lines changed

5 files changed

+35
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 4.1.8
2+
- Add support for setting mutipart upload threshold [#202](https://github.com/logstash-plugins/logstash-output-s3/pull/202)
3+
14
## 4.1.7
25
- Fixed issue where on restart, 0 byte files could erroneously be uploaded to s3 [#195](https://github.com/logstash-plugins/logstash-output-s3/issues/195)
36

docs/index.asciidoc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ This plugin supports the following configuration options plus the <<plugins-{typ
101101
| <<plugins-{type}s-{plugin}-storage_class>> |<<string,string>>, one of `["STANDARD", "REDUCED_REDUNDANCY", "STANDARD_IA"]`|No
102102
| <<plugins-{type}s-{plugin}-temporary_directory>> |<<string,string>>|No
103103
| <<plugins-{type}s-{plugin}-time_file>> |<<number,number>>|No
104+
| <<plugins-{type}s-{plugin}-upload_multipart_threshold>> |<<number,number>>|No
104105
| <<plugins-{type}s-{plugin}-upload_queue_size>> |<<number,number>>|No
105106
| <<plugins-{type}s-{plugin}-upload_workers_count>> |<<number,number>>|No
106107
| <<plugins-{type}s-{plugin}-validate_credentials_on_root_bucket>> |<<boolean,boolean>>|No
@@ -352,6 +353,14 @@ If you define file_size you have a number of files in consideration of the secti
352353
0 stay all time on listerner, beware if you specific 0 and size_file 0, because you will not put the file on bucket,
353354
for now the only thing this plugin can do is to put the file when logstash restart.
354355

356+
[id="plugins-{type}s-{plugin}-upload_multipart_threshold"]
357+
===== `upload_multipart_threshold`
358+
359+
* Value type is <<number,number>>
360+
* Default value is `15728640`
361+
362+
Files larger than this number are uploaded using the S3 multipart APIs
363+
355364
[id="plugins-{type}s-{plugin}-upload_queue_size"]
356365
===== `upload_queue_size`
357366

lib/logstash/outputs/s3.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ class LogStash::Outputs::S3 < LogStash::Outputs::Base
160160
# Number of items we can keep in the local queue before uploading them
161161
config :upload_queue_size, :validate => :number, :default => 2 * (Concurrent.processor_count * 0.25).ceil
162162

163+
# Files larger than this number are uploaded using the S3 multipart APIs. Default threshold is 15MB.
164+
config :upload_multipart_threshold, :validate => :number, :default => 15 * 1024 * 1024
165+
163166
# The version of the S3 signature hash to use. Normally uses the internal client default, can be explicitly
164167
# specified here
165168
config :signature_version, :validate => ['v2', 'v4']
@@ -296,7 +299,8 @@ def upload_options
296299
:server_side_encryption => @server_side_encryption ? @server_side_encryption_algorithm : nil,
297300
:ssekms_key_id => @server_side_encryption_algorithm == "aws:kms" ? @ssekms_key_id : nil,
298301
:storage_class => @storage_class,
299-
:content_encoding => @encoding == "gzip" ? "gzip" : nil
302+
:content_encoding => @encoding == "gzip" ? "gzip" : nil,
303+
:multipart_threshold => @upload_multipart_threshold
300304
}
301305
end
302306

logstash-output-s3.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Gem::Specification.new do |s|
22
s.name = 'logstash-output-s3'
3-
s.version = '4.1.7'
3+
s.version = '4.1.8'
44
s.licenses = ['Apache-2.0']
55
s.summary = "Sends Logstash events to the Amazon Simple Storage Service"
66
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"

spec/outputs/s3_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,23 @@
6060
end
6161
end
6262

63+
describe "Multipart upload threshold" do
64+
context "when configured" do
65+
it "should use the configured threshold" do
66+
threshold = 1 * 1024 * 1024
67+
s3 = described_class.new(options.merge({ "upload_multipart_threshold" => threshold }))
68+
expect(s3.upload_options).to include(:multipart_threshold => threshold)
69+
end
70+
end
71+
72+
context "when not configured" do
73+
it "should use 15MB as the default" do
74+
s3 = described_class.new(options)
75+
expect(s3.upload_options).to include(:multipart_threshold => 15 * 1024 * 1024)
76+
end
77+
end
78+
end
79+
6380
describe "Service Side Encryption" do
6481

6582
context "when configured" do

0 commit comments

Comments
 (0)