fluent-plugin-kinesis 1.3.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -23
  3. data/CHANGELOG.md +13 -0
  4. data/Gemfile +9 -9
  5. data/LICENSE.txt +201 -40
  6. data/Makefile +24 -31
  7. data/README.md +179 -308
  8. data/Rakefile +9 -13
  9. data/benchmark/task.rake +96 -58
  10. data/fluent-plugin-kinesis.gemspec +15 -19
  11. data/gemfiles/Gemfile.fluentd-0.12 +10 -10
  12. data/lib/fluent/plugin/kinesis.rb +166 -0
  13. data/lib/fluent/plugin/kinesis_helper/aggregator.rb +99 -0
  14. data/lib/fluent/plugin/kinesis_helper/api.rb +152 -121
  15. data/lib/fluent/plugin/kinesis_helper/client.rb +125 -12
  16. data/lib/fluent/plugin/out_kinesis_firehose.rb +40 -27
  17. data/lib/fluent/plugin/out_kinesis_streams.rb +51 -30
  18. data/lib/fluent/plugin/out_kinesis_streams_aggregated.rb +76 -0
  19. data/lib/fluent_plugin_kinesis/version.rb +10 -10
  20. metadata +18 -70
  21. data/README-v0.4.md +0 -348
  22. data/benchmark/dummy.conf +0 -0
  23. data/gemfiles/Gemfile.aws-sdk-2.4 +0 -20
  24. data/gemfiles/Gemfile.fluentd-0.10.58 +0 -20
  25. data/gemfiles/Gemfile.fluentd-0.14.11 +0 -20
  26. data/gemfiles/Gemfile.ruby-2.0 +0 -21
  27. data/gemfiles/Gemfile.ruby-2.1 +0 -21
  28. data/lib/fluent/plugin/kinesis_helper.rb +0 -36
  29. data/lib/fluent/plugin/kinesis_helper/class_methods.rb +0 -123
  30. data/lib/fluent/plugin/kinesis_helper/credentials.rb +0 -51
  31. data/lib/fluent/plugin/kinesis_helper/error.rb +0 -43
  32. data/lib/fluent/plugin/kinesis_helper/format.rb +0 -85
  33. data/lib/fluent/plugin/kinesis_helper/initialize.rb +0 -59
  34. data/lib/fluent/plugin/kinesis_helper/kpl.rb +0 -82
  35. data/lib/fluent/plugin/out_kinesis.rb +0 -323
  36. data/lib/fluent/plugin/out_kinesis_producer.rb +0 -48
  37. data/lib/fluent/plugin/patched_detach_process_impl.rb +0 -103
  38. data/lib/kinesis_producer.rb +0 -24
  39. data/lib/kinesis_producer/binary.rb +0 -10
  40. data/lib/kinesis_producer/daemon.rb +0 -270
  41. data/lib/kinesis_producer/library.rb +0 -122
  42. data/lib/kinesis_producer/protobuf/config.pb.rb +0 -66
  43. data/lib/kinesis_producer/protobuf/messages.pb.rb +0 -151
  44. data/lib/kinesis_producer/tasks/binary.rake +0 -73
@@ -1,44 +1,57 @@
1
1
  #
2
- # Copyright 2014-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ # Copyright 2014-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  #
4
- # Licensed under the Amazon Software License (the "License").
5
- # You may not use this file except in compliance with the License.
6
- # A copy of the License is located at
4
+ # Licensed under the Apache License, Version 2.0 (the "License"). You
5
+ # may not use this file except in compliance with the License. A copy of
6
+ # the License is located at
7
7
  #
8
- # http://aws.amazon.com/asl/
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
9
  #
10
- # or in the "license" file accompanying this file. This file is distributed
11
- # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12
- # express or implied. See the License for the specific language governing
13
- # permissions and limitations under the License.
10
+ # or in the "license" file accompanying this file. This file is
11
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
12
+ # ANY KIND, either express or implied. See the License for the specific
13
+ # language governing permissions and limitations under the License.
14
14
 
15
- require 'fluent/plugin/kinesis_helper'
15
+ require 'fluent/plugin/kinesis'
16
16
 
17
17
  module Fluent
18
- class KinesisFirehoseOutput < BufferedOutput
19
- include KinesisHelper
18
+ class KinesisFirehoseOutput < KinesisOutput
20
19
  Fluent::Plugin.register_output('kinesis_firehose', self)
21
- config_param_for_firehose
22
20
 
23
- def write(chunk)
24
- records = convert_to_records(chunk)
25
- split_to_batches(records).each do |batch|
26
- batch_request_with_retry(batch)
21
+ RequestType = :firehose
22
+ BatchRequestLimitCount = 500
23
+ BatchRequestLimitSize = 4 * 1024 * 1024
24
+ include KinesisHelper::API::BatchRequest
25
+
26
+ config_param :delivery_stream_name, :string
27
+ config_param :append_new_line, :bool, default: true
28
+
29
+ def configure(conf)
30
+ super
31
+ if @append_new_line
32
+ org_data_formatter = @data_formatter
33
+ @data_formatter = ->(tag, time, record) {
34
+ org_data_formatter.call(tag, time, record) + "\n"
35
+ }
27
36
  end
28
- log.debug("Written #{records.size} records")
29
37
  end
30
38
 
31
- private
32
-
33
- def convert_format(tag, time, record)
34
- { data: data_format(tag, time, record) }
39
+ def format(tag, time, record)
40
+ format_for_api do
41
+ [@data_formatter.call(tag, time, record)]
42
+ end
35
43
  end
36
44
 
37
- def batch_request(batch)
38
- client.put_record_batch(
39
- delivery_stream_name: @delivery_stream_name,
40
- records: batch
41
- )
45
+ def write(chunk)
46
+ write_records_batch(chunk) do |batch|
47
+ records = batch.map{|(data)|
48
+ { data: data }
49
+ }
50
+ client.put_record_batch(
51
+ delivery_stream_name: @delivery_stream_name,
52
+ records: records,
53
+ )
54
+ end
42
55
  end
43
56
  end
44
57
  end
@@ -1,48 +1,69 @@
1
1
  #
2
- # Copyright 2014-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ # Copyright 2014-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  #
4
- # Licensed under the Amazon Software License (the "License").
5
- # You may not use this file except in compliance with the License.
6
- # A copy of the License is located at
4
+ # Licensed under the Apache License, Version 2.0 (the "License"). You
5
+ # may not use this file except in compliance with the License. A copy of
6
+ # the License is located at
7
7
  #
8
- # http://aws.amazon.com/asl/
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
9
  #
10
- # or in the "license" file accompanying this file. This file is distributed
11
- # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12
- # express or implied. See the License for the specific language governing
13
- # permissions and limitations under the License.
10
+ # or in the "license" file accompanying this file. This file is
11
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
12
+ # ANY KIND, either express or implied. See the License for the specific
13
+ # language governing permissions and limitations under the License.
14
14
 
15
- require 'fluent/plugin/kinesis_helper'
15
+ require 'fluent/plugin/kinesis'
16
16
 
17
17
  module Fluent
18
- class KinesisStreamsOutput < BufferedOutput
19
- include KinesisHelper
18
+ class KinesisStreamsOutput < KinesisOutput
20
19
  Fluent::Plugin.register_output('kinesis_streams', self)
21
- config_param_for_streams
20
+
21
+ RequestType = :streams
22
+ BatchRequestLimitCount = 500
23
+ BatchRequestLimitSize = 5 * 1024 * 1024
24
+ include KinesisHelper::API::BatchRequest
25
+
26
+ config_param :stream_name, :string
27
+ config_param :partition_key, :string, default: nil
28
+
29
+ def configure(conf)
30
+ super
31
+ @key_formatter = key_formatter_create
32
+ end
33
+
34
+ def format(tag, time, record)
35
+ format_for_api do
36
+ data = @data_formatter.call(tag, time, record)
37
+ key = @key_formatter.call(record)
38
+ [data, key]
39
+ end
40
+ end
22
41
 
23
42
  def write(chunk)
24
- records = convert_to_records(chunk)
25
- split_to_batches(records).each do |batch|
26
- next unless batch.size > 0
27
- batch_request_with_retry(batch)
43
+ write_records_batch(chunk) do |batch|
44
+ records = batch.map{|(data, partition_key)|
45
+ { data: data, partition_key: partition_key }
46
+ }
47
+ client.put_records(
48
+ stream_name: @stream_name,
49
+ records: records,
50
+ )
28
51
  end
29
- log.debug("Written #{records.size} records")
30
52
  end
31
53
 
32
54
  private
33
55
 
34
- def convert_format(tag, time, record)
35
- {
36
- data: data_format(tag, time, record),
37
- partition_key: key(record),
38
- }
39
- end
40
-
41
- def batch_request(batch)
42
- client.put_records(
43
- stream_name: @stream_name,
44
- records: batch,
45
- )
56
+ def key_formatter_create
57
+ if @partition_key.nil?
58
+ ->(record) { SecureRandom.hex(16) }
59
+ else
60
+ ->(record) {
61
+ if !record.key?(@partition_key)
62
+ raise KeyNotFoundError.new(@partition_key, record)
63
+ end
64
+ record[@partition_key]
65
+ }
66
+ end
46
67
  end
47
68
  end
48
69
  end
@@ -0,0 +1,76 @@
1
+ #
2
+ # Copyright 2014-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License"). You
5
+ # may not use this file except in compliance with the License. A copy of
6
+ # the License is located at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # or in the "license" file accompanying this file. This file is
11
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
12
+ # ANY KIND, either express or implied. See the License for the specific
13
+ # language governing permissions and limitations under the License.
14
+
15
+ require 'fluent/plugin/kinesis'
16
+ require 'fluent/plugin/kinesis_helper/aggregator'
17
+
18
+ module Fluent
19
+ class KinesisStreamsAggregatedOutput < KinesisOutput
20
+ Fluent::Plugin.register_output('kinesis_streams_aggregated', self)
21
+ include KinesisHelper::Aggregator::Mixin
22
+
23
+ RequestType = :streams_aggregated
24
+ BatchRequestLimitCount = 100_000
25
+ BatchRequestLimitSize = 1024 * 1024
26
+ include KinesisHelper::API::BatchRequest
27
+
28
+ config_param :stream_name, :string
29
+ config_param :fixed_partition_key, :string, default: nil
30
+
31
+ def configure(conf)
32
+ super
33
+ @partition_key_generator = create_partition_key_generator
34
+ @batch_request_max_size -= offset
35
+ @max_record_size -= offset
36
+ end
37
+
38
+ def format(tag, time, record)
39
+ format_for_api do
40
+ [@data_formatter.call(tag, time, record)]
41
+ end
42
+ end
43
+
44
+ def write(chunk)
45
+ write_records_batch(chunk) do |batch|
46
+ key = @partition_key_generator.call
47
+ records = batch.map{|(data)|data}
48
+ client.put_records(
49
+ stream_name: @stream_name,
50
+ records: [{
51
+ partition_key: key,
52
+ data: aggregator.aggregate(records, key),
53
+ }],
54
+ )
55
+ end
56
+ end
57
+
58
+ def offset
59
+ @offset ||= AggregateOffset + @partition_key_generator.call.size*2
60
+ end
61
+
62
+ private
63
+
64
+ def size_of_values(record)
65
+ super(record) + RecordOffset
66
+ end
67
+
68
+ def create_partition_key_generator
69
+ if @fixed_partition_key.nil?
70
+ ->() { SecureRandom.hex(16) }
71
+ else
72
+ ->() { @fixed_partition_key }
73
+ end
74
+ end
75
+ end
76
+ end
@@ -1,17 +1,17 @@
1
1
  #
2
- # Copyright 2014-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ # Copyright 2014-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  #
4
- # Licensed under the Amazon Software License (the "License").
5
- # You may not use this file except in compliance with the License.
6
- # A copy of the License is located at
4
+ # Licensed under the Apache License, Version 2.0 (the "License"). You
5
+ # may not use this file except in compliance with the License. A copy of
6
+ # the License is located at
7
7
  #
8
- # http://aws.amazon.com/asl/
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
9
  #
10
- # or in the "license" file accompanying this file. This file is distributed
11
- # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12
- # express or implied. See the License for the specific language governing
13
- # permissions and limitations under the License.
10
+ # or in the "license" file accompanying this file. This file is
11
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
12
+ # ANY KIND, either express or implied. See the License for the specific
13
+ # language governing permissions and limitations under the License.
14
14
 
15
15
  module FluentPluginKinesis
16
- VERSION = '1.3.0'
16
+ VERSION = '2.0.0'
17
17
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-kinesis
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amazon Web Services
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-22 00:00:00.000000000 Z
11
+ date: 2017-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.10.58
19
+ version: 0.12.35
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '2'
@@ -26,40 +26,26 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 0.10.58
29
+ version: 0.12.35
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '2'
33
33
  - !ruby/object:Gem::Dependency
34
- name: protobuf
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- version: 3.5.5
40
- type: :runtime
41
- prerelease: false
42
- version_requirements: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: 3.5.5
47
- - !ruby/object:Gem::Dependency
48
- name: aws-sdk
34
+ name: aws-sdk-kinesis
49
35
  requirement: !ruby/object:Gem::Requirement
50
36
  requirements:
51
37
  - - "~>"
52
38
  - !ruby/object:Gem::Version
53
- version: '2'
39
+ version: '1'
54
40
  type: :runtime
55
41
  prerelease: false
56
42
  version_requirements: !ruby/object:Gem::Requirement
57
43
  requirements:
58
44
  - - "~>"
59
45
  - !ruby/object:Gem::Version
60
- version: '2'
46
+ version: '1'
61
47
  - !ruby/object:Gem::Dependency
62
- name: concurrent-ruby
48
+ name: aws-sdk-firehose
63
49
  requirement: !ruby/object:Gem::Requirement
64
50
  requirements:
65
51
  - - "~>"
@@ -73,19 +59,19 @@ dependencies:
73
59
  - !ruby/object:Gem::Version
74
60
  version: '1'
75
61
  - !ruby/object:Gem::Dependency
76
- name: os
62
+ name: google-protobuf
77
63
  requirement: !ruby/object:Gem::Requirement
78
64
  requirements:
79
- - - ">="
65
+ - - "~>"
80
66
  - !ruby/object:Gem::Version
81
- version: 0.9.6
67
+ version: '3'
82
68
  type: :runtime
83
69
  prerelease: false
84
70
  version_requirements: !ruby/object:Gem::Requirement
85
71
  requirements:
86
- - - ">="
72
+ - - "~>"
87
73
  - !ruby/object:Gem::Version
88
- version: 0.9.6
74
+ version: '3'
89
75
  - !ruby/object:Gem::Dependency
90
76
  name: bundler
91
77
  requirement: !ruby/object:Gem::Requirement
@@ -198,20 +184,6 @@ dependencies:
198
184
  - - ">="
199
185
  - !ruby/object:Gem::Version
200
186
  version: 0.0.2
201
- - !ruby/object:Gem::Dependency
202
- name: rubyzip
203
- requirement: !ruby/object:Gem::Requirement
204
- requirements:
205
- - - ">="
206
- - !ruby/object:Gem::Version
207
- version: 1.0.0
208
- type: :development
209
- prerelease: false
210
- version_requirements: !ruby/object:Gem::Requirement
211
- requirements:
212
- - - ">="
213
- - !ruby/object:Gem::Version
214
- version: 1.0.0
215
187
  - !ruby/object:Gem::Dependency
216
188
  name: mocha
217
189
  requirement: !ruby/object:Gem::Requirement
@@ -268,46 +240,22 @@ files:
268
240
  - LICENSE.txt
269
241
  - Makefile
270
242
  - NOTICE.txt
271
- - README-v0.4.md
272
243
  - README.md
273
244
  - Rakefile
274
- - amazon-kinesis-producer-native-binaries/linux/kinesis_producer
275
- - amazon-kinesis-producer-native-binaries/osx/kinesis_producer
276
- - amazon-kinesis-producer-native-binaries/windows/kinesis_producer.exe
277
- - benchmark/dummy.conf
278
245
  - benchmark/task.rake
279
246
  - fluent-plugin-kinesis.gemspec
280
- - gemfiles/Gemfile.aws-sdk-2.4
281
- - gemfiles/Gemfile.fluentd-0.10.58
282
247
  - gemfiles/Gemfile.fluentd-0.12
283
- - gemfiles/Gemfile.fluentd-0.14.11
284
- - gemfiles/Gemfile.ruby-2.0
285
- - gemfiles/Gemfile.ruby-2.1
286
- - lib/fluent/plugin/kinesis_helper.rb
248
+ - lib/fluent/plugin/kinesis.rb
249
+ - lib/fluent/plugin/kinesis_helper/aggregator.rb
287
250
  - lib/fluent/plugin/kinesis_helper/api.rb
288
- - lib/fluent/plugin/kinesis_helper/class_methods.rb
289
251
  - lib/fluent/plugin/kinesis_helper/client.rb
290
- - lib/fluent/plugin/kinesis_helper/credentials.rb
291
- - lib/fluent/plugin/kinesis_helper/error.rb
292
- - lib/fluent/plugin/kinesis_helper/format.rb
293
- - lib/fluent/plugin/kinesis_helper/initialize.rb
294
- - lib/fluent/plugin/kinesis_helper/kpl.rb
295
- - lib/fluent/plugin/out_kinesis.rb
296
252
  - lib/fluent/plugin/out_kinesis_firehose.rb
297
- - lib/fluent/plugin/out_kinesis_producer.rb
298
253
  - lib/fluent/plugin/out_kinesis_streams.rb
299
- - lib/fluent/plugin/patched_detach_process_impl.rb
254
+ - lib/fluent/plugin/out_kinesis_streams_aggregated.rb
300
255
  - lib/fluent_plugin_kinesis/version.rb
301
- - lib/kinesis_producer.rb
302
- - lib/kinesis_producer/binary.rb
303
- - lib/kinesis_producer/daemon.rb
304
- - lib/kinesis_producer/library.rb
305
- - lib/kinesis_producer/protobuf/config.pb.rb
306
- - lib/kinesis_producer/protobuf/messages.pb.rb
307
- - lib/kinesis_producer/tasks/binary.rake
308
256
  homepage: https://github.com/awslabs/aws-fluent-plugin-kinesis
309
257
  licenses:
310
- - Amazon Software License
258
+ - Apache-2.0
311
259
  metadata: {}
312
260
  post_install_message:
313
261
  rdoc_options: []
@@ -317,7 +265,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
317
265
  requirements:
318
266
  - - ">="
319
267
  - !ruby/object:Gem::Version
320
- version: 2.0.0
268
+ version: '2.1'
321
269
  required_rubygems_version: !ruby/object:Gem::Requirement
322
270
  requirements:
323
271
  - - ">="