fluent-plugin-kinesis-firehose 0.1.1 → 0.1.2.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/lib/fluent/plugin/out_kinesis_firehose.rb +57 -13
- data/lib/fluent_plugin_kinesis_firehose/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5a52689533a4ac87d41ce025a97f9caca093dbc
|
4
|
+
data.tar.gz: 9d2bfd0b85ed883067979a1de7b014290f265f56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 142208dbeccfad34374d724762f01a53ef3743e9204038b9fdb8932831db63adde4e9c8e3e03c44e90d23287f2ae1776ae8a4f472f66c88982da4279d0d28400
|
7
|
+
data.tar.gz: 53da4b07a323773d3ae87eebbe62992ec664430205864ff247524d9d9fcdb3f4cc27ba8a3036c4193e819943df19e84176447d21c8d2cf4e80b61bb1f07dc7dc
|
data/README.md
CHANGED
@@ -5,6 +5,11 @@ Fluentd output plugin for Amazon Kinesis Firehose.
|
|
5
5
|
[![Gem Version](https://badge.fury.io/rb/fluent-plugin-kinesis-firehose.svg)](http://badge.fury.io/rb/fluent-plugin-kinesis-firehose)
|
6
6
|
[![Build Status](https://travis-ci.org/winebarrel/fluent-plugin-kinesis-firehose.svg)](https://travis-ci.org/winebarrel/fluent-plugin-kinesis-firehose)
|
7
7
|
|
8
|
+
## ChangeLog
|
9
|
+
|
10
|
+
* `>= 0.1.2`
|
11
|
+
* Add `retries_on_putrecordbatch` option ([PR#2](https://github.com/winebarrel/fluent-plugin-kinesis-firehose/pull/3))
|
12
|
+
|
8
13
|
## Installation
|
9
14
|
|
10
15
|
Add this line to your application's Gemfile:
|
@@ -35,6 +40,7 @@ Or install it yourself as:
|
|
35
40
|
#aws_sec_key ...
|
36
41
|
region us-east-1
|
37
42
|
#endpoint ...
|
43
|
+
#retries_on_putrecordbatch 3
|
38
44
|
|
39
45
|
#data_key data (default: nil)
|
40
46
|
|
@@ -14,16 +14,17 @@ class Fluent::KinesisFirehoseOutput < Fluent::BufferedOutput
|
|
14
14
|
define_method('log') { $log }
|
15
15
|
end
|
16
16
|
|
17
|
-
config_param :profile,
|
18
|
-
config_param :credentials_path,
|
19
|
-
config_param :aws_key_id,
|
20
|
-
config_param :aws_sec_key,
|
21
|
-
config_param :region,
|
22
|
-
config_param :endpoint,
|
23
|
-
config_param :http_proxy,
|
24
|
-
config_param :delivery_stream_name,
|
25
|
-
config_param :data_key,
|
26
|
-
config_param :append_new_line,
|
17
|
+
config_param :profile, :string, :default => nil
|
18
|
+
config_param :credentials_path, :string, :default => nil
|
19
|
+
config_param :aws_key_id, :string, :default => nil, :secret => true
|
20
|
+
config_param :aws_sec_key, :string, :default => nil, :secret => true
|
21
|
+
config_param :region, :string, :default => nil
|
22
|
+
config_param :endpoint, :string, :default => nil
|
23
|
+
config_param :http_proxy, :string, :default => nil
|
24
|
+
config_param :delivery_stream_name, :string
|
25
|
+
config_param :data_key, :string, :default => nil
|
26
|
+
config_param :append_new_line, :bool, :default => true
|
27
|
+
config_param :retries_on_putrecordbatch, :integer, :default => 3
|
27
28
|
|
28
29
|
def initialize
|
29
30
|
super
|
@@ -33,6 +34,7 @@ class Fluent::KinesisFirehoseOutput < Fluent::BufferedOutput
|
|
33
34
|
|
34
35
|
def configure(conf)
|
35
36
|
super
|
37
|
+
@sleep_duration = Array.new(@retries_on_putrecordbatch) {|n| ((2 ** n) * scaling_factor) }
|
36
38
|
end
|
37
39
|
|
38
40
|
def format(tag, time, record)
|
@@ -54,6 +56,9 @@ class Fluent::KinesisFirehoseOutput < Fluent::BufferedOutput
|
|
54
56
|
}.each_slice(PUT_RECORDS_MAX_COUNT) {|data_list|
|
55
57
|
put_records(data_list)
|
56
58
|
}
|
59
|
+
rescue => e
|
60
|
+
log.error e.message
|
61
|
+
log.error_backtrace e.backtrace
|
57
62
|
end
|
58
63
|
|
59
64
|
private
|
@@ -86,19 +91,54 @@ class Fluent::KinesisFirehoseOutput < Fluent::BufferedOutput
|
|
86
91
|
false
|
87
92
|
end
|
88
93
|
}.each {|chunk|
|
89
|
-
|
94
|
+
put_record_batch_with_retry(chunk)
|
90
95
|
}
|
91
96
|
end
|
92
97
|
|
93
|
-
def
|
98
|
+
def put_record_batch_with_retry(data_list, retry_count=0)
|
94
99
|
records = data_list.map do |data|
|
95
100
|
{:data => data}
|
96
101
|
end
|
97
102
|
|
98
|
-
client.put_record_batch(
|
103
|
+
response = client.put_record_batch(
|
99
104
|
:delivery_stream_name => @delivery_stream_name,
|
100
105
|
:records => records
|
101
106
|
)
|
107
|
+
|
108
|
+
if response[:failed_put_count] && response[:failed_put_count] > 0
|
109
|
+
failed_records = collect_failed_records(data_list, response)
|
110
|
+
|
111
|
+
if retry_count < @retries_on_putrecordbatch
|
112
|
+
sleep @sleep_duration[retry_count]
|
113
|
+
retry_count += 1
|
114
|
+
log.warn 'Retrying to put records. Retry count: %d' % retry_count
|
115
|
+
put_record_batch_with_retry(failed_records.map{|record| record[:data] }, retry_count)
|
116
|
+
else
|
117
|
+
failed_records.each {|record|
|
118
|
+
log.error 'Could not put record, Error: %s/%s, Record: %s' % [
|
119
|
+
record[:error_code],
|
120
|
+
record[:error_message],
|
121
|
+
record[:data]
|
122
|
+
]
|
123
|
+
}
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def collect_failed_records(data_list, response)
|
129
|
+
failed_records = []
|
130
|
+
|
131
|
+
response[:request_responses].each_with_index do |record, index|
|
132
|
+
if record[:error_code]
|
133
|
+
failed_records.push(
|
134
|
+
data: data_list[index],
|
135
|
+
error_code: record[:error_code],
|
136
|
+
error_message: record[:error_message]
|
137
|
+
)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
failed_records
|
102
142
|
end
|
103
143
|
|
104
144
|
def client
|
@@ -127,4 +167,8 @@ class Fluent::KinesisFirehoseOutput < Fluent::BufferedOutput
|
|
127
167
|
|
128
168
|
@client = Aws::Firehose::Client.new(options)
|
129
169
|
end
|
170
|
+
|
171
|
+
def scaling_factor
|
172
|
+
0.5 + rand * 0.1
|
173
|
+
end
|
130
174
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-kinesis-firehose
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2.beta
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Genki Sugawara
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -142,12 +142,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
142
142
|
version: '0'
|
143
143
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
144
|
requirements:
|
145
|
-
- - '
|
145
|
+
- - '>'
|
146
146
|
- !ruby/object:Gem::Version
|
147
|
-
version:
|
147
|
+
version: 1.3.1
|
148
148
|
requirements: []
|
149
149
|
rubyforge_project:
|
150
|
-
rubygems_version: 2.
|
150
|
+
rubygems_version: 2.4.8
|
151
151
|
signing_key:
|
152
152
|
specification_version: 4
|
153
153
|
summary: Fluentd output plugin for Amazon Kinesis Firehose.
|