fluent-plugin-s3 0.7.2 → 0.8.0.rc1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 55e080d8a3659c9031a55c444803d30f9fc748de
4
- data.tar.gz: 09d5d7227c24f4f997e88d7a5d8ea41fb24aaf1a
3
+ metadata.gz: 396e2f615eeaf603b9240f364dea07db8a7e92ef
4
+ data.tar.gz: 64b0a5e72ac0ee484e676d15417c8c44536001c9
5
5
  SHA512:
6
- metadata.gz: 49e4ba0663061d8443a9603a0d465b491a23f4e286d1e620d8f1cb8a5bbde204c0a274d60c088181e22b181a702881ca39664764b88fc02ad75d73615a604ebc
7
- data.tar.gz: 13da940d95c312cf99f7fc632493a2d1c5b36e397528212a45de930520c61250e7f798a2d6f498d9d7e6825f5b660e7cedfabb6462b33d53782eafd66d600ec5
6
+ metadata.gz: 3bc5c5e87a48959943863e011ea8d12532b348602cb94f76c6c050af4e07bafd7d6f175e7a1c5f111187a8c7d63e994a98983f50a3af168550c7dc3f6644e137
7
+ data.tar.gz: 4763fb32496ccb0cea8565aea1b2b553fefa015cfaf952f31f7eb7d15a5361ba46a2545c8fbe4296c2d63e6de1290263c07d9cce265935de5bca5236e0939136
data/Gemfile CHANGED
@@ -1,5 +1,7 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  gem 'json', '= 1.8.3'
4
+ gem 'uuidtools'
5
+ gem 'fluentd', '= 0.14.8'
4
6
 
5
7
  gemspec
data/README.md CHANGED
@@ -85,8 +85,9 @@ The format of S3 object keys. You can use several built-in variables:
85
85
  * %{time_slice}
86
86
  * %{index}
87
87
  * %{file_extension}
88
- * %{uuid_flush}
89
88
  * %{hex_random}
89
+ * %{uuid_flush}
90
+ * %{hostname}
90
91
 
91
92
  to decide keys dynamically.
92
93
 
@@ -98,7 +99,8 @@ the sequential number starts from 0, increments when multiple files are
98
99
  uploaded to S3 in the same time slice.
99
100
  * %{file_extention} is always "gz" for
100
101
  now.
101
- * %{uuid_flush} a uuid that is replaced everytime the buffer will be flushed
102
+ * %{uuid_flush} a uuid that is replaced everytime the buffer will be flushed. If you want to use this placeholder, install `uuidtools` gem first.
103
+ * %{hostname} is replaced with `Socket.gethostname` result. This is same as "#{Socket.gethostname}".
102
104
  * %{hex_random} a random hex string that is replaced for each buffer chunk, not
103
105
  assured to be unique. This is used to follow a way of peformance tuning, `Add
104
106
  a Hex Hash Prefix to Key Name`, written in [Request Rate and Performance
@@ -130,14 +132,6 @@ You get:
130
132
  "log/events/ts=20130111-23/events_1.gz"
131
133
  "log/events/ts=20130112-00/events_0.gz"
132
134
 
133
- The
134
- [fluent-mixin-config-placeholders](https://github.com/tagomoris/fluent-mixin-config-placeholders) mixin is also incorporated, so additional variables such
135
- as %{hostname}, %{uuid}, etc. can be used in the s3_object_key_format. This
136
- could prove useful in preventing filename conflicts when writing from multiple
137
- servers.
138
-
139
- s3_object_key_format %{path}/events/ts=%{time_slice}/events_%{index}-%{hostname}.%{file_extension}
140
-
141
135
  **force_path_style**
142
136
 
143
137
  :force_path_style (Boolean) — default: false — When set to true, the
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.2
1
+ 0.8.0.rc1
@@ -19,8 +19,6 @@ Gem::Specification.new do |gem|
19
19
 
20
20
  gem.add_dependency "fluentd", [">= 0.10.58", "< 2"]
21
21
  gem.add_dependency "aws-sdk", [">= 2.3.22", "< 3"]
22
- gem.add_dependency "yajl-ruby", "~> 1.0"
23
- gem.add_dependency "fluent-mixin-config-placeholders", ">= 0.3.0"
24
22
  gem.add_development_dependency "rake", ">= 0.9.2"
25
23
  gem.add_development_dependency "rr", "= 1.1.2"
26
24
  gem.add_development_dependency "test-unit", ">= 3.0.8"
@@ -1,8 +1,6 @@
1
1
  require 'fluent/output'
2
2
 
3
3
  module Fluent
4
- require 'fluent/mixin/config_placeholders'
5
-
6
4
  class S3Output < Fluent::TimeSlicedOutput
7
5
  Fluent::Plugin.register_output('s3', self)
8
6
 
@@ -14,6 +12,7 @@ module Fluent
14
12
  require 'tempfile'
15
13
 
16
14
  @compressor = nil
15
+ @uuid_flush_enabled = false
17
16
  end
18
17
 
19
18
  # For fluentd v0.12.16 or earlier
@@ -119,13 +118,8 @@ module Fluent
119
118
 
120
119
  attr_reader :bucket
121
120
 
122
- include Fluent::Mixin::ConfigPlaceholders
123
121
  MAX_HEX_RANDOM_LENGTH = 16
124
122
 
125
- def placeholders
126
- [:percent]
127
- end
128
-
129
123
  def configure(conf)
130
124
  super
131
125
 
@@ -162,6 +156,8 @@ module Fluent
162
156
  $log.warn "reduced_redundancy parameter is deprecated. Use storage_class parameter instead"
163
157
  @storage_class = "REDUCED_REDUNDANCY"
164
158
  end
159
+
160
+ @s3_object_key_format = process_s3_object_key_format
165
161
  @values_for_s3_object_chunk = {}
166
162
  end
167
163
 
@@ -203,8 +199,8 @@ module Fluent
203
199
  "time_slice" => chunk.key,
204
200
  "file_extension" => @compressor.ext,
205
201
  "index" => i,
206
- "uuid_flush" => uuid_random,
207
202
  }.merge!(@values_for_s3_object_chunk[chunk.unique_id])
203
+ values_for_s3_object_key['uuid_flush'.freeze] = uuid_random if @uuid_flush_enabled
208
204
 
209
205
  s3path = @s3_object_key_format.gsub(%r(%{[^}]+})) { |expr|
210
206
  values_for_s3_object_key[expr[2...expr.size-1]]
@@ -268,6 +264,10 @@ module Fluent
268
264
  unique_hex[0...@hex_random_length]
269
265
  end
270
266
 
267
+ def uuid_random
268
+ ::UUIDTools::UUID.random_create.to_s
269
+ end
270
+
271
271
  def ensure_bucket
272
272
  if !@bucket.exists?
273
273
  if @auto_create_bucket
@@ -279,6 +279,34 @@ module Fluent
279
279
  end
280
280
  end
281
281
 
282
+ def process_s3_object_key_format
283
+ %W(%{uuid} %{uuid:random} %{uuid:hostname} %{uuid:timestamp}).each { |ph|
284
+ if @s3_object_key_format.include?(ph)
285
+ raise ConfigError, %!#{ph} placeholder in s3_object_key_format is removed!
286
+ end
287
+ }
288
+
289
+ if @s3_object_key_format.include?('%{uuid_flush}')
290
+ # test uuidtools works or not
291
+ begin
292
+ require 'uuidtools'
293
+ rescue LoadError
294
+ raise ConfigError, "uuidtools gem not found. Install uuidtools gem first"
295
+ end
296
+ begin
297
+ uuid_random
298
+ rescue => e
299
+ raise ConfigError, "Generating uuid doesn't work. Can't use %{uuid_flush} on this environment. #{e}"
300
+ end
301
+ @uuid_flush_enabled = true
302
+ end
303
+
304
+ @s3_object_key_format.gsub('%{hostname}') { |expr|
305
+ log.warn "%{hostname} will be removed in the future. Use \"\#{Socket.gethostname}\" instead"
306
+ Socket.gethostname
307
+ }
308
+ end
309
+
282
310
  def check_apikeys
283
311
  @bucket.objects(:prefix => @path).first
284
312
  rescue Aws::S3::Errors::NoSuchBucket
data/test/test_out_s3.rb CHANGED
@@ -251,7 +251,6 @@ class S3OutputTest < Test::Unit::TestCase
251
251
  end
252
252
 
253
253
  CONFIG_TIME_SLICE = %[
254
- hostname testing.node.local
255
254
  aws_key_id test_key_id
256
255
  aws_sec_key test_sec_key
257
256
  s3_bucket test_bucket
@@ -299,11 +298,18 @@ class S3OutputTest < Test::Unit::TestCase
299
298
  end
300
299
 
301
300
  def test_write_with_custom_s3_object_key_format_containing_uuid_flush_placeholder
301
+
302
+ begin
303
+ require 'uuidtools'
304
+ rescue LoadError
305
+ pend("uuidtools not found. skip this test")
306
+ end
307
+
302
308
  # Partial mock the S3Bucket, not to make an actual connection to Amazon S3
303
309
  setup_mocks(true)
304
310
 
305
311
  uuid = "5755e23f-9b54-42d8-8818-2ea38c6f279e"
306
- stub(UUIDTools::UUID).random_create{ uuid }
312
+ stub(::UUIDTools::UUID).random_create{ uuid }
307
313
 
308
314
  s3_local_file_path = "/tmp/s3-test.txt"
309
315
  s3path = "log/events/ts=20110102-13/events_0-#{uuid}.gz"
@@ -380,7 +386,7 @@ class S3OutputTest < Test::Unit::TestCase
380
386
  end
381
387
 
382
388
  def setup_s3_object_mocks(params = {})
383
- s3path = params[:s3path] || "log/events/ts=20110102-13/events_0-testing.node.local.gz"
389
+ s3path = params[:s3path] || "log/events/ts=20110102-13/events_0-#{Socket.gethostname}.gz"
384
390
  s3_local_file_path = params[:s3_local_file_path] || "/tmp/s3-test.txt"
385
391
 
386
392
  # Assert content of event logs which are being sent to S3
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.7.2
4
+ version: 0.8.0.rc1
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-10-20 00:00:00.000000000 Z
12
+ date: 2016-11-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fluentd
@@ -51,34 +51,6 @@ dependencies:
51
51
  - - "<"
52
52
  - !ruby/object:Gem::Version
53
53
  version: '3'
54
- - !ruby/object:Gem::Dependency
55
- name: yajl-ruby
56
- requirement: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - "~>"
59
- - !ruby/object:Gem::Version
60
- version: '1.0'
61
- type: :runtime
62
- prerelease: false
63
- version_requirements: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - "~>"
66
- - !ruby/object:Gem::Version
67
- version: '1.0'
68
- - !ruby/object:Gem::Dependency
69
- name: fluent-mixin-config-placeholders
70
- requirement: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- version: 0.3.0
75
- type: :runtime
76
- prerelease: false
77
- version_requirements: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - ">="
80
- - !ruby/object:Gem::Version
81
- version: 0.3.0
82
54
  - !ruby/object:Gem::Dependency
83
55
  name: rake
84
56
  requirement: !ruby/object:Gem::Requirement
@@ -191,9 +163,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
191
163
  version: '0'
192
164
  required_rubygems_version: !ruby/object:Gem::Requirement
193
165
  requirements:
194
- - - ">="
166
+ - - ">"
195
167
  - !ruby/object:Gem::Version
196
- version: '0'
168
+ version: 1.3.1
197
169
  requirements: []
198
170
  rubyforge_project:
199
171
  rubygems_version: 2.5.1