fluent-plugin-s3 0.6.8 → 0.6.9
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/.travis.yml +7 -1
- data/ChangeLog +7 -0
- data/Gemfile +2 -0
- data/Gemfile.v0.12 +6 -0
- data/README.md +11 -21
- data/VERSION +1 -1
- data/fluent-plugin-s3.gemspec +1 -0
- data/lib/fluent/plugin/out_s3.rb +9 -21
- data/test/test_out_s3.rb +11 -25
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d3125cb720171313d0ac3b19ee194e3996454d4
|
4
|
+
data.tar.gz: ca82560974fb26d500e418888b6ca03cdc020f2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 981012e05d6804b223b3e683e3da31754f034c818a4bdcc3820be7643c48a21ecd08a76e9df945adf35b77ed4e70e4b1da33bd4155765ee26cabefbadda6fb36
|
7
|
+
data.tar.gz: 751fbb6b67929ea0bb0934e345a83f0afb3f8cea60cffc64f4f6947f623122643c50e6b5bb1e9c1266a01fa708b3150e74777fd71bdd4bc809cfbcac59f2a23b
|
data/.travis.yml
CHANGED
@@ -5,12 +5,13 @@ rvm:
|
|
5
5
|
- 2.0
|
6
6
|
- 2.1
|
7
7
|
- 2.2.3
|
8
|
-
- 2.3.
|
8
|
+
- 2.3.1
|
9
9
|
- ruby-head
|
10
10
|
- rbx
|
11
11
|
|
12
12
|
gemfile:
|
13
13
|
- Gemfile
|
14
|
+
- Gemfile.v0.12
|
14
15
|
|
15
16
|
branches:
|
16
17
|
only:
|
@@ -25,3 +26,8 @@ matrix:
|
|
25
26
|
allow_failures:
|
26
27
|
- rvm: ruby-head
|
27
28
|
- rvm: rbx
|
29
|
+
exclude:
|
30
|
+
- rvm: 1.9.3
|
31
|
+
gemfile: Gemfile
|
32
|
+
- rvm: 2.0
|
33
|
+
gemfile: Gemfile
|
data/ChangeLog
CHANGED
data/Gemfile
CHANGED
data/Gemfile.v0.12
ADDED
data/README.md
CHANGED
@@ -126,8 +126,7 @@ You get:
|
|
126
126
|
"log/events/ts=20130112-00/events_0.gz"
|
127
127
|
|
128
128
|
The
|
129
|
-
[fluent-mixin-config-placeholders](https://github.com/tagomoris/fluent-mixin-
|
130
|
-
onfig-placeholders) mixin is also incorporated, so additional variables such
|
129
|
+
[fluent-mixin-config-placeholders](https://github.com/tagomoris/fluent-mixin-config-placeholders) mixin is also incorporated, so additional variables such
|
131
130
|
as %{hostname}, %{uuid}, etc. can be used in the s3_object_key_format. This
|
132
131
|
could prove useful in preventing filename conflicts when writing from multiple
|
133
132
|
servers.
|
@@ -158,7 +157,7 @@ See `Use your compression algorithm` section for adding another format.
|
|
158
157
|
**format**
|
159
158
|
|
160
159
|
Change one line format in the S3 object. Supported formats are "out_file",
|
161
|
-
"json", "ltsv" and "single_value".
|
160
|
+
"json", "ltsv" and "single_value". See also [official Formatter article](http://docs.fluentd.org/articles/formatter-plugin-overview).
|
162
161
|
|
163
162
|
* out_file (default).
|
164
163
|
|
@@ -260,8 +259,7 @@ using IAM roles. Valid values are:
|
|
260
259
|
* private (default)
|
261
260
|
* public-read
|
262
261
|
* public-read-write (not recommended - see [Canned
|
263
|
-
ACL](http://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#
|
264
|
-
ed-acl))
|
262
|
+
ACL](http://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl))
|
265
263
|
* authenticated-read
|
266
264
|
* bucket-owner-read
|
267
265
|
* bucket-owner-full-control
|
@@ -337,12 +335,9 @@ Typically, you use AssumeRole for cross-account access or federation.
|
|
337
335
|
See also:
|
338
336
|
|
339
337
|
* [Using IAM Roles - AWS Identity and Access
|
340
|
-
Management](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use.
|
341
|
-
|
342
|
-
* [Aws::
|
343
|
-
t.html)
|
344
|
-
* [Aws::AssumeRoleCredentials](http://docs.aws.amazon.com/sdkforruby/api/Aws
|
345
|
-
/AssumeRoleCredentials.html)
|
338
|
+
Management](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use.html)
|
339
|
+
* [Aws::STS::Client](http://docs.aws.amazon.com/sdkforruby/api/Aws/STS/Client.html)
|
340
|
+
* [Aws::AssumeRoleCredentials](http://docs.aws.amazon.com/sdkforruby/api/Aws/AssumeRoleCredentials.html)
|
346
341
|
|
347
342
|
**role_arn (required)**
|
348
343
|
|
@@ -383,14 +378,11 @@ EC2 instance.
|
|
383
378
|
|
384
379
|
See also:
|
385
380
|
|
386
|
-
* [Aws::InstanceProfileCredentials](http://docs.aws.amazon.com/sdkforruby/
|
387
|
-
i/Aws/InstanceProfileCredentials.html)
|
381
|
+
* [Aws::InstanceProfileCredentials](http://docs.aws.amazon.com/sdkforruby/api/Aws/InstanceProfileCredentials.html)
|
388
382
|
* [Temporary Security Credentials - AWS Identity and Access
|
389
|
-
Management](http://docs.aws.amazon.com/IAM/latest/UserGuide/
|
390
|
-
_temp.html)
|
383
|
+
Management](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp.html)
|
391
384
|
* [Instance Metadata and User Data - Amazon Elastic Compute
|
392
|
-
Cloud](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-
|
393
|
-
adata.html)
|
385
|
+
Cloud](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html)
|
394
386
|
|
395
387
|
**retries**
|
396
388
|
|
@@ -428,8 +420,7 @@ local developing.
|
|
428
420
|
|
429
421
|
See also:
|
430
422
|
|
431
|
-
* [Aws::SharedCredentials](http://docs.aws.amazon.com/sdkforruby/api/Aws/
|
432
|
-
redCredentials.html)
|
423
|
+
* [Aws::SharedCredentials](http://docs.aws.amazon.com/sdkforruby/api/Aws/SharedCredentials.html)
|
433
424
|
|
434
425
|
**path**
|
435
426
|
|
@@ -456,8 +447,7 @@ Note that the bucket must already exist and **auto_create_bucket** has no
|
|
456
447
|
effect in this case.
|
457
448
|
|
458
449
|
Refer to the [AWS
|
459
|
-
documentation](http://docs.aws.amazon.com/IAM/latest/UserGuide/
|
460
|
-
ies.html) for example policies.
|
450
|
+
documentation](http://docs.aws.amazon.com/IAM/latest/UserGuide/ExampleIAMPolicies.html) for example policies.
|
461
451
|
|
462
452
|
Using [IAM
|
463
453
|
roles](http://docs.aws.amazon.com/IAM/latest/UserGuide/WorkingWithRoles.html)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.9
|
data/fluent-plugin-s3.gemspec
CHANGED
@@ -22,6 +22,7 @@ Gem::Specification.new do |gem|
|
|
22
22
|
gem.add_dependency "yajl-ruby", "~> 1.0"
|
23
23
|
gem.add_dependency "fluent-mixin-config-placeholders", ">= 0.3.0"
|
24
24
|
gem.add_development_dependency "rake", ">= 0.9.2"
|
25
|
+
gem.add_development_dependency "rr", "= 1.1.2"
|
25
26
|
gem.add_development_dependency "test-unit", ">= 3.0.8"
|
26
27
|
gem.add_development_dependency "test-unit-rr", ">= 1.0.3"
|
27
28
|
gem.add_development_dependency "timecop"
|
data/lib/fluent/plugin/out_s3.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
module Fluent
|
2
2
|
require 'fluent/mixin/config_placeholders'
|
3
|
-
require 'securerandom'
|
4
3
|
|
5
4
|
class S3Output < Fluent::TimeSlicedOutput
|
6
5
|
Fluent::Plugin.register_output('s3', self)
|
@@ -70,7 +69,7 @@ module Fluent
|
|
70
69
|
config_param :profile_name, :string, :default => nil
|
71
70
|
end
|
72
71
|
desc "The number of attempts to load instance profile credentials from the EC2 metadata service using IAM role"
|
73
|
-
config_param :aws_iam_retries, :integer, :default =>
|
72
|
+
config_param :aws_iam_retries, :integer, :default => nil
|
74
73
|
desc "S3 bucket name"
|
75
74
|
config_param :s3_bucket, :string
|
76
75
|
desc "S3 region name"
|
@@ -165,7 +164,6 @@ module Fluent
|
|
165
164
|
end
|
166
165
|
|
167
166
|
def start
|
168
|
-
super
|
169
167
|
options = setup_credentials
|
170
168
|
options[:region] = @s3_region if @s3_region
|
171
169
|
options[:endpoint] = @s3_endpoint if @s3_endpoint
|
@@ -181,8 +179,7 @@ module Fluent
|
|
181
179
|
check_apikeys if @check_apikey_on_start
|
182
180
|
ensure_bucket
|
183
181
|
|
184
|
-
|
185
|
-
@hex_random_n = (@hex_random_length + 1) / 2
|
182
|
+
super
|
186
183
|
end
|
187
184
|
|
188
185
|
def format(tag, time, record)
|
@@ -257,25 +254,16 @@ module Fluent
|
|
257
254
|
|
258
255
|
private
|
259
256
|
|
260
|
-
#
|
261
|
-
def
|
262
|
-
|
263
|
-
|
264
|
-
tsuffix = unique_id[0...(unique_id.size/2)].unpack('C*').map {|x| x.to_s(16) }.join('') # size: 16
|
265
|
-
else
|
266
|
-
nil
|
267
|
-
end
|
257
|
+
# v0.14 has a useful Fluent::UniqueId.hex(unique_id) method, though
|
258
|
+
def unique_hex(chunk)
|
259
|
+
unique_id = chunk.unique_id
|
260
|
+
unique_id.unpack('C*').map {|x| x.to_s(16) }.join('')
|
268
261
|
end
|
269
262
|
|
270
263
|
def hex_random(chunk)
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
tsuffix.reverse! # tsuffix is like (time_sec, time_usec, rand) => reversing gives more randomness
|
275
|
-
tsuffix[0...@hex_random_length]
|
276
|
-
else
|
277
|
-
SecureRandom.hex(@hex_random_n)[0...@hex_random_length]
|
278
|
-
end
|
264
|
+
unique_hex = unique_hex(chunk)
|
265
|
+
unique_hex.reverse! # unique_hex is like (time_sec, time_usec, rand) => reversing gives more randomness
|
266
|
+
unique_hex[0...@hex_random_length]
|
279
267
|
end
|
280
268
|
|
281
269
|
def ensure_bucket
|
data/test/test_out_s3.rb
CHANGED
@@ -26,7 +26,7 @@ class S3OutputTest < Test::Unit::TestCase
|
|
26
26
|
]
|
27
27
|
|
28
28
|
def create_driver(conf = CONFIG)
|
29
|
-
Fluent::Test::
|
29
|
+
Fluent::Test::TimeSlicedOutputTestDriver.new(Fluent::S3Output) do
|
30
30
|
def write(chunk)
|
31
31
|
chunk.read
|
32
32
|
end
|
@@ -247,7 +247,7 @@ class S3OutputTest < Test::Unit::TestCase
|
|
247
247
|
|
248
248
|
assert_equal %[2011-01-02T13:14:15Z\ttest\t{"a":1}\n] +
|
249
249
|
%[2011-01-02T13:14:15Z\ttest\t{"a":2}\n],
|
250
|
-
data
|
250
|
+
data.first
|
251
251
|
end
|
252
252
|
|
253
253
|
CONFIG_TIME_SLICE = %[
|
@@ -330,38 +330,24 @@ class S3OutputTest < Test::Unit::TestCase
|
|
330
330
|
Dir.glob('tmp/*').each {|file| FileUtils.rm_f(file) }
|
331
331
|
end
|
332
332
|
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
write_with_custom_s3_object_key_format_containing_hex_random_placeholder(config, hex[0...5])
|
339
|
-
end
|
340
|
-
|
341
|
-
def test_write_with_custom_s3_object_key_format_containing_hex_random_placeholder_file_buffer
|
342
|
-
tsuffix = "5226c3c4fb3d49b1"
|
343
|
-
any_instance_of(Fluent::FileBufferChunk) do |klass|
|
344
|
-
unique_id = "R&\xC3\xC4\xFB=I\xB1R&\xC3\xC4\xFB=I\xB1" # corresponding unique_id with tsuffxi
|
345
|
-
stub(klass).unique_id { unique_id }
|
346
|
-
end
|
347
|
-
hex = tsuffix.reverse
|
333
|
+
# ToDo: need to test hex_random does not change on retry, but it is difficult with
|
334
|
+
# the current fluentd test helper because it does not provide a way to run with the same chunks
|
335
|
+
def test_write_with_custom_s3_object_key_format_containing_hex_random_placeholder
|
336
|
+
unique_hex = "5226c3c4fb3d49b15226c3c4fb3d49b1"
|
337
|
+
hex_random = unique_hex.reverse[0...5]
|
348
338
|
|
349
|
-
config = CONFIG_TIME_SLICE.gsub(/%{hostname}/,"%{hex_random}") << "\nhex_random_length
|
339
|
+
config = CONFIG_TIME_SLICE.gsub(/%{hostname}/,"%{hex_random}") << "\nhex_random_length #{hex_random.length}"
|
350
340
|
config = config.gsub(/buffer_type memory/, "buffer_type file\nbuffer_path test/tmp/buf")
|
351
|
-
write_with_custom_s3_object_key_format_containing_hex_random_placeholder(config, hex)
|
352
|
-
end
|
353
341
|
|
354
|
-
# ToDo: need to test hex_random does not change on retry, but it is difficult with
|
355
|
-
# the current fluentd test helper because it does not provide a way to run with the same chunks
|
356
|
-
def write_with_custom_s3_object_key_format_containing_hex_random_placeholder(config, hex)
|
357
342
|
# Partial mock the S3Bucket, not to make an actual connection to Amazon S3
|
358
343
|
setup_mocks(true)
|
359
344
|
|
360
|
-
s3path = "log/events/ts=20110102-13/events_0-#{
|
345
|
+
s3path = "log/events/ts=20110102-13/events_0-#{hex_random}.gz"
|
361
346
|
s3_local_file_path = "/tmp/s3-test.txt"
|
362
347
|
setup_s3_object_mocks(s3_local_file_path: s3_local_file_path, s3path: s3path)
|
363
348
|
|
364
349
|
d = create_time_sliced_driver(config)
|
350
|
+
stub(d.instance).unique_hex { unique_hex }
|
365
351
|
|
366
352
|
time = Time.parse("2011-01-02 13:14:15 UTC").to_i
|
367
353
|
d.emit({"a"=>1}, time)
|
@@ -553,7 +539,7 @@ class S3OutputTest < Test::Unit::TestCase
|
|
553
539
|
d.run
|
554
540
|
|
555
541
|
logs = d.instance.log.logs
|
556
|
-
assert_true logs.any? {|log| log.include?('
|
542
|
+
assert_true logs.any? {|log| log.include?('out_s3: delayed events were put') }
|
557
543
|
|
558
544
|
Timecop.return
|
559
545
|
FileUtils.rm_f(s3_local_file_path)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-s3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sadayuki Furuhashi
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-07-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fluentd
|
@@ -87,6 +87,20 @@ dependencies:
|
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: 0.9.2
|
90
|
+
- !ruby/object:Gem::Dependency
|
91
|
+
name: rr
|
92
|
+
requirement: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.1.2
|
97
|
+
type: :development
|
98
|
+
prerelease: false
|
99
|
+
version_requirements: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 1.1.2
|
90
104
|
- !ruby/object:Gem::Dependency
|
91
105
|
name: test-unit
|
92
106
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,6 +154,7 @@ files:
|
|
140
154
|
- AUTHORS
|
141
155
|
- ChangeLog
|
142
156
|
- Gemfile
|
157
|
+
- Gemfile.v0.12
|
143
158
|
- README.md
|
144
159
|
- Rakefile
|
145
160
|
- VERSION
|
@@ -170,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
185
|
version: '0'
|
171
186
|
requirements: []
|
172
187
|
rubyforge_project:
|
173
|
-
rubygems_version: 2.
|
188
|
+
rubygems_version: 2.5.1
|
174
189
|
signing_key:
|
175
190
|
specification_version: 4
|
176
191
|
summary: Amazon S3 output plugin for Fluentd event collector
|