fluent-plugin-kinesis 0.3.6 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +11 -1
- data/lib/fluent/plugin/out_kinesis.rb +16 -7
- data/lib/fluent/plugin/version.rb +1 -1
- data/test/plugin/test_out_kinesis.rb +83 -2
- metadata +24 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6dc44b8f1a4d7220c6d4c20dd4e33baa5ed70a78
|
4
|
+
data.tar.gz: 2d012e6a2733199c34308a4469743b4bf8c957bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5cdbc4d830d1c71b4df65feaf3ec246434768863d4e533e4bd4bf6c10509f67ed055e3112de3476157372e28016f53fa140e50ad5cd323e65cc2d274ccb4d6d
|
7
|
+
data.tar.gz: 969d010695643a4e94abc934fd877fb7bc96991d77ea596d23c749a4a89aa4b7263e1606dfb37cb32fa4ea664b6839f1b1c5e3482fead17d32304f8b97cfb94d
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 0.4.0
|
4
|
+
- Feature - Add option to ensure Kinesis Stream connection. [#35](https://github.com/awslabs/aws-fluent-plugin-kinesis/pull/35)
|
5
|
+
- Feature - Add option to support zlib compression. [#39](https://github.com/awslabs/aws-fluent-plugin-kinesis/pull/39)
|
6
|
+
|
7
|
+
Note: We introduced [Semantic Versioning](http://semver.org/) here.
|
8
|
+
|
3
9
|
## 0.3.6
|
4
10
|
|
5
11
|
- **Cross account access support**: Added support for cross account access for Amazon Kinesis stream. With this update, you can put reocrds to streams those are owned by other AWS account. This feature is achieved by [AssumeRole](http://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html).
|
data/README.md
CHANGED
@@ -119,6 +119,10 @@ It should be in form like "us-east-1", "us-west-2".
|
|
119
119
|
Refer to [Regions and Endpoints in AWS General Reference](http://docs.aws.amazon.com/general/latest/gr/rande.html#ak_region)
|
120
120
|
for supported regions.
|
121
121
|
|
122
|
+
### ensure_stream_connection
|
123
|
+
|
124
|
+
When enabled, the plugin checks and ensures a connection to the stream you are using by [DescribeStream](http://docs.aws.amazon.com/kinesis/latest/APIReference/API_DescribeStream.html) and throws exception if it fails. Enabled by default.
|
125
|
+
|
122
126
|
### http_proxy
|
123
127
|
|
124
128
|
Proxy server, if any.
|
@@ -196,13 +200,19 @@ Integer, default is 3. When **order_events** is false, the plugin will put multi
|
|
196
200
|
records to Amazon Kinesis in batches using PutRecords. A set of records in a batch
|
197
201
|
may fail for reasons documented in the Kinesis Service API Reference for PutRecords.
|
198
202
|
Failed records will be retried **retries_on_putrecords** times. If a record
|
199
|
-
fails all retries an error log will be emitted.
|
203
|
+
fails all retries an error log will be emitted.
|
200
204
|
|
201
205
|
### use_yajl
|
202
206
|
|
203
207
|
Boolean, default is false.
|
204
208
|
In case you find error `Encoding::UndefinedConversionError` with multibyte texts, you can avoid that error with this option.
|
205
209
|
|
210
|
+
### zlib_compression
|
211
|
+
|
212
|
+
Boolean, default is false.
|
213
|
+
Zlib compresses the message data blob.
|
214
|
+
Each zlib compressed message must remain within megabyte in size.
|
215
|
+
|
206
216
|
### debug
|
207
217
|
|
208
218
|
Boolean. Enable if you need to debug Amazon Kinesis API call. Default is false.
|
@@ -17,6 +17,7 @@ require 'yajl'
|
|
17
17
|
require 'logger'
|
18
18
|
require 'securerandom'
|
19
19
|
require 'fluent/plugin/version'
|
20
|
+
require 'zlib'
|
20
21
|
|
21
22
|
module FluentPluginKinesis
|
22
23
|
class OutputFilter < Fluent::BufferedOutput
|
@@ -41,6 +42,7 @@ module FluentPluginKinesis
|
|
41
42
|
# The 'region' parameter is optional because
|
42
43
|
# it may be set as an environment variable.
|
43
44
|
config_param :region, :string, default: nil
|
45
|
+
config_param :ensure_stream_connection, :bool, default: true
|
44
46
|
|
45
47
|
config_param :profile, :string, :default => nil
|
46
48
|
config_param :credentials_path, :string, :default => nil
|
@@ -56,6 +58,7 @@ module FluentPluginKinesis
|
|
56
58
|
config_param :order_events, :bool, default: false
|
57
59
|
config_param :retries_on_putrecords, :integer, default: 3
|
58
60
|
config_param :use_yajl, :bool, default: false
|
61
|
+
config_param :zlib_compression, :bool, default: false
|
59
62
|
|
60
63
|
config_param :debug, :bool, default: false
|
61
64
|
|
@@ -102,7 +105,9 @@ module FluentPluginKinesis
|
|
102
105
|
detach_multi_process do
|
103
106
|
super
|
104
107
|
load_client
|
105
|
-
|
108
|
+
if @ensure_stream_connection
|
109
|
+
check_connection_to_stream
|
110
|
+
end
|
106
111
|
end
|
107
112
|
end
|
108
113
|
|
@@ -120,15 +125,15 @@ module FluentPluginKinesis
|
|
120
125
|
end
|
121
126
|
|
122
127
|
def write(chunk)
|
123
|
-
data_list = chunk.to_enum(:msgpack_each).
|
124
|
-
|
128
|
+
data_list = chunk.to_enum(:msgpack_each).map{|record|
|
129
|
+
build_data_to_put(record)
|
130
|
+
}.find_all{|record|
|
131
|
+
unless record_exceeds_max_size?(record[:data])
|
125
132
|
true
|
126
133
|
else
|
127
|
-
log.error sprintf('Record exceeds the %.3f KB(s) per-record size limit and will not be delivered: %s', PUT_RECORD_MAX_DATA_SIZE / 1024.0, record[
|
134
|
+
log.error sprintf('Record exceeds the %.3f KB(s) per-record size limit and will not be delivered: %s', PUT_RECORD_MAX_DATA_SIZE / 1024.0, record[:data])
|
128
135
|
false
|
129
136
|
end
|
130
|
-
}.map{|record|
|
131
|
-
build_data_to_put(record)
|
132
137
|
}
|
133
138
|
|
134
139
|
if @order_events
|
@@ -220,7 +225,11 @@ module FluentPluginKinesis
|
|
220
225
|
end
|
221
226
|
|
222
227
|
def build_data_to_put(data)
|
223
|
-
|
228
|
+
if @zlib_compression
|
229
|
+
Hash[data.map{|k, v| [k.to_sym, k=="data" ? Zlib::Deflate.deflate(v) : v] }]
|
230
|
+
else
|
231
|
+
Hash[data.map{|k, v| [k.to_sym, v] }]
|
232
|
+
end
|
224
233
|
end
|
225
234
|
|
226
235
|
def put_record_for_order_events(data_list)
|
@@ -30,6 +30,14 @@ class KinesisOutputTest < Test::Unit::TestCase
|
|
30
30
|
use_yajl true
|
31
31
|
]
|
32
32
|
|
33
|
+
CONFIG_WITH_COMPRESSION = CONFIG + %[
|
34
|
+
zlib_compression true
|
35
|
+
]
|
36
|
+
|
37
|
+
CONFIG_YAJL_WITH_COMPRESSION = CONFIG_YAJL + %[
|
38
|
+
zlib_compression true
|
39
|
+
]
|
40
|
+
|
33
41
|
def create_driver(conf = CONFIG, tag='test')
|
34
42
|
Fluent::Test::BufferedOutputTestDriver
|
35
43
|
.new(FluentPluginKinesis::OutputFilter, tag).configure(conf)
|
@@ -143,6 +151,7 @@ class KinesisOutputTest < Test::Unit::TestCase
|
|
143
151
|
conf = %[
|
144
152
|
stream_name test_stream
|
145
153
|
region us-east-1
|
154
|
+
ensure_stream_connection false
|
146
155
|
http_proxy http://proxy:3333/
|
147
156
|
partition_key test_partition_key
|
148
157
|
partition_key_expr record
|
@@ -154,6 +163,7 @@ class KinesisOutputTest < Test::Unit::TestCase
|
|
154
163
|
d = create_driver(conf)
|
155
164
|
assert_equal 'test_stream', d.instance.stream_name
|
156
165
|
assert_equal 'us-east-1', d.instance.region
|
166
|
+
assert_equal false, d.instance.ensure_stream_connection
|
157
167
|
assert_equal 'http://proxy:3333/', d.instance.http_proxy
|
158
168
|
assert_equal 'test_partition_key', d.instance.partition_key
|
159
169
|
assert_equal 'Proc',
|
@@ -237,7 +247,7 @@ class KinesisOutputTest < Test::Unit::TestCase
|
|
237
247
|
|
238
248
|
|
239
249
|
data("json"=>CONFIG, "yajl"=>CONFIG_YAJL)
|
240
|
-
def
|
250
|
+
def test_format_without_compression(config)
|
241
251
|
|
242
252
|
d = create_driver(config)
|
243
253
|
|
@@ -276,6 +286,46 @@ class KinesisOutputTest < Test::Unit::TestCase
|
|
276
286
|
d.run
|
277
287
|
end
|
278
288
|
|
289
|
+
data("json"=>CONFIG_WITH_COMPRESSION, "yajl"=>CONFIG_YAJL_WITH_COMPRESSION)
|
290
|
+
def test_format_with_compression(config)
|
291
|
+
|
292
|
+
d = create_driver(config)
|
293
|
+
|
294
|
+
data1 = {"test_partition_key"=>"key1","a"=>1,"time"=>"2011-01-02T13:14:15Z","tag"=>"test"}
|
295
|
+
data2 = {"test_partition_key"=>"key2","a"=>2,"time"=>"2011-01-02T13:14:15Z","tag"=>"test"}
|
296
|
+
|
297
|
+
time = Time.parse("2011-01-02 13:14:15 UTC").to_i
|
298
|
+
d.emit(data1, time)
|
299
|
+
d.emit(data2, time)
|
300
|
+
|
301
|
+
d.expect_format({
|
302
|
+
'data' => data1.to_json,
|
303
|
+
'partition_key' => 'key1' }.to_msgpack
|
304
|
+
)
|
305
|
+
d.expect_format({
|
306
|
+
'data' => data2.to_json,
|
307
|
+
'partition_key' => 'key2' }.to_msgpack
|
308
|
+
)
|
309
|
+
|
310
|
+
client = create_mock_client
|
311
|
+
client.describe_stream(stream_name: 'test_stream')
|
312
|
+
client.put_records(
|
313
|
+
stream_name: 'test_stream',
|
314
|
+
records: [
|
315
|
+
{
|
316
|
+
data: Zlib::Deflate.deflate(data1.to_json),
|
317
|
+
partition_key: 'key1'
|
318
|
+
},
|
319
|
+
{
|
320
|
+
data: Zlib::Deflate.deflate(data2.to_json),
|
321
|
+
partition_key: 'key2'
|
322
|
+
}
|
323
|
+
]
|
324
|
+
) { {} }
|
325
|
+
|
326
|
+
d.run
|
327
|
+
end
|
328
|
+
|
279
329
|
def test_order_events
|
280
330
|
|
281
331
|
d = create_driver(CONFIG + "\norder_events true")
|
@@ -349,7 +399,7 @@ class KinesisOutputTest < Test::Unit::TestCase
|
|
349
399
|
)
|
350
400
|
end
|
351
401
|
|
352
|
-
def
|
402
|
+
def test_multibyte_with_yajl_without_compression
|
353
403
|
|
354
404
|
d = create_driver(CONFIG_YAJL)
|
355
405
|
|
@@ -380,6 +430,37 @@ class KinesisOutputTest < Test::Unit::TestCase
|
|
380
430
|
d.run
|
381
431
|
end
|
382
432
|
|
433
|
+
def test_multibyte_with_yajl_with_compression
|
434
|
+
|
435
|
+
d = create_driver(CONFIG_YAJL_WITH_COMPRESSION)
|
436
|
+
|
437
|
+
data1 = {"test_partition_key"=>"key1","a"=>"\xE3\x82\xA4\xE3\x83\xB3\xE3\x82\xB9\xE3\x83\x88\xE3\x83\xBC\xE3\x83\xAB","time"=>"2011-01-02T13:14:15Z","tag"=>"test"}
|
438
|
+
json = Yajl.dump(data1)
|
439
|
+
data1["a"].force_encoding("ASCII-8BIT")
|
440
|
+
|
441
|
+
time = Time.parse("2011-01-02 13:14:15 UTC").to_i
|
442
|
+
d.emit(data1, time)
|
443
|
+
|
444
|
+
d.expect_format({
|
445
|
+
'data' => json,
|
446
|
+
'partition_key' => 'key1' }.to_msgpack
|
447
|
+
)
|
448
|
+
|
449
|
+
client = create_mock_client
|
450
|
+
client.describe_stream(stream_name: 'test_stream')
|
451
|
+
client.put_records(
|
452
|
+
stream_name: 'test_stream',
|
453
|
+
records: [
|
454
|
+
{
|
455
|
+
data: Zlib::Deflate.deflate(json),
|
456
|
+
partition_key: 'key1'
|
457
|
+
}
|
458
|
+
]
|
459
|
+
) { {} }
|
460
|
+
|
461
|
+
d.run
|
462
|
+
end
|
463
|
+
|
383
464
|
def test_get_key
|
384
465
|
d = create_driver
|
385
466
|
assert_equal(
|
metadata
CHANGED
@@ -1,123 +1,123 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-kinesis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.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: 2015-
|
11
|
+
date: 2015-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.3'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '10.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: test-unit-rr
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '1.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: fluentd
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 0.10.53
|
62
|
-
- - <
|
62
|
+
- - "<"
|
63
63
|
- !ruby/object:Gem::Version
|
64
64
|
version: '0.13'
|
65
65
|
type: :runtime
|
66
66
|
prerelease: false
|
67
67
|
version_requirements: !ruby/object:Gem::Requirement
|
68
68
|
requirements:
|
69
|
-
- -
|
69
|
+
- - ">="
|
70
70
|
- !ruby/object:Gem::Version
|
71
71
|
version: 0.10.53
|
72
|
-
- - <
|
72
|
+
- - "<"
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '0.13'
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: aws-sdk-core
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
|
-
- -
|
79
|
+
- - ">="
|
80
80
|
- !ruby/object:Gem::Version
|
81
81
|
version: 2.0.12
|
82
|
-
- - <
|
82
|
+
- - "<"
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '3.0'
|
85
85
|
type: :runtime
|
86
86
|
prerelease: false
|
87
87
|
version_requirements: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
|
-
- -
|
89
|
+
- - ">="
|
90
90
|
- !ruby/object:Gem::Version
|
91
91
|
version: 2.0.12
|
92
|
-
- - <
|
92
|
+
- - "<"
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '3.0'
|
95
95
|
- !ruby/object:Gem::Dependency
|
96
96
|
name: multi_json
|
97
97
|
requirement: !ruby/object:Gem::Requirement
|
98
98
|
requirements:
|
99
|
-
- - ~>
|
99
|
+
- - "~>"
|
100
100
|
- !ruby/object:Gem::Version
|
101
101
|
version: '1.0'
|
102
102
|
type: :runtime
|
103
103
|
prerelease: false
|
104
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
105
|
requirements:
|
106
|
-
- - ~>
|
106
|
+
- - "~>"
|
107
107
|
- !ruby/object:Gem::Version
|
108
108
|
version: '1.0'
|
109
109
|
- !ruby/object:Gem::Dependency
|
110
110
|
name: msgpack
|
111
111
|
requirement: !ruby/object:Gem::Requirement
|
112
112
|
requirements:
|
113
|
-
- -
|
113
|
+
- - ">="
|
114
114
|
- !ruby/object:Gem::Version
|
115
115
|
version: 0.5.8
|
116
116
|
type: :runtime
|
117
117
|
prerelease: false
|
118
118
|
version_requirements: !ruby/object:Gem::Requirement
|
119
119
|
requirements:
|
120
|
-
- -
|
120
|
+
- - ">="
|
121
121
|
- !ruby/object:Gem::Version
|
122
122
|
version: 0.5.8
|
123
123
|
description:
|
@@ -126,8 +126,8 @@ executables: []
|
|
126
126
|
extensions: []
|
127
127
|
extra_rdoc_files: []
|
128
128
|
files:
|
129
|
-
- .gitignore
|
130
|
-
- .travis.yml
|
129
|
+
- ".gitignore"
|
130
|
+
- ".travis.yml"
|
131
131
|
- CHANGELOG.md
|
132
132
|
- CONTRIBUTORS.txt
|
133
133
|
- Gemfile
|
@@ -150,12 +150,12 @@ require_paths:
|
|
150
150
|
- lib
|
151
151
|
required_ruby_version: !ruby/object:Gem::Requirement
|
152
152
|
requirements:
|
153
|
-
- -
|
153
|
+
- - ">="
|
154
154
|
- !ruby/object:Gem::Version
|
155
155
|
version: 1.9.3
|
156
156
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
157
|
requirements:
|
158
|
-
- -
|
158
|
+
- - ">="
|
159
159
|
- !ruby/object:Gem::Version
|
160
160
|
version: '0'
|
161
161
|
requirements: []
|