fluent-plugin-elasticsearch 2.9.1 → 2.9.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 68bc9bdc4c7c5e52553aafacc5b7018e1cc7f5b01e4f5bcacb112443787b4ced
4
- data.tar.gz: 9bd3383b8b79e480f86753827c88fc127767357e02729dec6e7d1b8a676fd0de
3
+ metadata.gz: c6294313d2bbda7a0933074c22b9d94db7d0a6ae7e7518210a0b56fa6a5ae2a2
4
+ data.tar.gz: a94f6a5ce9d4e79c3280d512cb8acd9174aac263179f09f18088f50f6a1f9a62
5
5
  SHA512:
6
- metadata.gz: 44987ff76928eb5e78607820ef84ad4a9ea5dc8d8c8043afff8506919ac87cc4cf6643c9a3ff875d412c3a82012bcbef32dda27fcfe61d4a87bb33e8de63d9dc
7
- data.tar.gz: 20169754c661e2de4a938d208c34e10adbde571790082a28c2c7f76996c5c0a5db5b74edcf1642a352f2a0196334706e575bb2b9ec46e8dd55c5ff1d695a5460
6
+ metadata.gz: d0184d1b690d6c9118bcb419e6904411b61dd8cac289f59e78ba554fbe3c953ac7b697b5271a491fbcf5b391d5691a7c3982288ed10bf6b9e1eca54a705450cb
7
+ data.tar.gz: e0efbbd71009eaa75e8372677fbd169a54f1d143b2ce12df112c075af8b523a18650472ea6c4692267ca39cb48f30204d81dbd556bc18187d2c31a7c515ee4a8
data/History.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ### [Unreleased]
4
4
 
5
+ ### 2.9.2
6
+ - Uplift Merge pull request #410 from richm/v0.12-consistent-errors-and-tests (#411)
7
+ - Add correct link for include_timestamp (#408)
8
+
5
9
  ### 2.9.1
6
10
  - Uplift Merge pull request #406 from richm/v0.12-successes-duplicates-no-retry (#407)
7
11
 
data/README.md CHANGED
@@ -28,7 +28,7 @@ Current maintainers: @cosmo0920
28
28
  + [time_precision](#time_precision)
29
29
  + [time_key](#time_key)
30
30
  + [time_key_exclude_timestamp](#time_key_exclude_timestamp)
31
- + [include_timestamp](#time_key_exclude_timestamp)
31
+ + [include_timestamp](#include_timestamp)
32
32
  + [utc_index](#utc_index)
33
33
  + [target_index_key](#target_index_key)
34
34
  + [target_type_key](#target_type_key)
@@ -3,7 +3,7 @@ $:.push File.expand_path('../lib', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'fluent-plugin-elasticsearch'
6
- s.version = '2.9.1'
6
+ s.version = '2.9.2'
7
7
  s.authors = ['diogo', 'pitr']
8
8
  s.email = ['pitr.vern@gmail.com', 'me@diogoterror.com']
9
9
  s.description = %q{Elasticsearch output plugin for Fluent event collector}
@@ -53,29 +53,24 @@ class Fluent::Plugin::ElasticsearchErrorHandler
53
53
  stats[type] += 1
54
54
  end
55
55
  end
56
- if stats[:errors_bad_resp] > 0
57
- @plugin.log.on_debug { @plugin.log.debug("Unable to parse response from elasticsearch, likely an API version mismatch: #{response}") }
58
- raise ElasticsearchVersionMismatch, "Unable to parse error response from Elasticsearch, likely an API version mismatch. Add '@log_level debug' to your config to see the full response"
59
- end
60
56
  @plugin.log.on_debug do
61
57
  msg = ["Indexed (op = #{@plugin.write_operation})"]
62
58
  stats.each_pair { |key, value| msg << "#{value} #{key}" }
63
59
  @plugin.log.debug msg.join(', ')
64
60
  end
65
- if stats[:successes] + stats[:duplicates] == bulk_message_count
66
- @plugin.log.debug("retry succeeded - all #{bulk_message_count} records were successfully sent")
67
- return
68
- end
69
- stats.each_key do |key|
70
- case key
71
- when 'out_of_memory_error'
72
- raise ElasticsearchOutOfMemory, 'Elasticsearch has exhausted its heap, retrying'
73
- when 'es_rejected_execution_exception'
74
- raise BulkIndexQueueFull, 'Bulk index queue is full, retrying'
75
- else
76
- @plugin.log.on_debug { @plugin.log.debug("Elasticsearch errors returned, retrying: #{response}") }
77
- raise ElasticsearchError, "Elasticsearch returned errors, retrying. Add '@log_level debug' to your config to see the full response"
78
- end
61
+ case
62
+ when stats[:errors_bad_resp] > 0
63
+ @plugin.log.on_debug { @plugin.log.debug("Unable to parse response from elasticsearch, likely an API version mismatch: #{response}") }
64
+ raise ElasticsearchVersionMismatch, "Unable to parse error response from Elasticsearch, likely an API version mismatch. Add '@log_level debug' to your config to see the full response"
65
+ when stats[:successes] + stats[:duplicates] == bulk_message_count
66
+ @plugin.log.info("retry succeeded - successes=#{stats[:successes]} duplicates=#{stats[:duplicates]}")
67
+ when stats['es_rejected_execution_exception'] > 0
68
+ raise BulkIndexQueueFull, 'Bulk index queue is full, retrying'
69
+ when stats['out_of_memory_error'] > 0
70
+ raise ElasticsearchOutOfMemory, 'Elasticsearch has exhausted its heap, retrying'
71
+ else
72
+ @plugin.log.on_debug { @plugin.log.debug("Elasticsearch errors returned, retrying: #{response}") }
73
+ raise ElasticsearchError, "Elasticsearch returned errors, retrying. Add '@log_level debug' to your config to see the full response"
79
74
  end
80
75
  end
81
76
  end
@@ -6,20 +6,21 @@ class TestElasticsearchErrorHandler < Test::Unit::TestCase
6
6
 
7
7
  class TestPlugin
8
8
  attr_reader :log
9
+ attr_reader :write_operation
9
10
  def initialize(log)
10
11
  @log = log
11
- end
12
-
13
- def write_operation
14
- 'index'
12
+ @write_operation = 'index'
15
13
  end
16
14
  end
17
15
 
18
16
  def setup
19
17
  Fluent::Test.setup
20
- @log = Fluent::Engine.log
21
- plugin = TestPlugin.new(@log)
22
- @handler = Fluent::Plugin::ElasticsearchErrorHandler.new(plugin)
18
+ @log_device = Fluent::Test::DummyLogDevice.new
19
+ dl_opts = {:log_level => ServerEngine::DaemonLogger::INFO}
20
+ logger = ServerEngine::DaemonLogger.new(@log_device, dl_opts)
21
+ @log = Fluent::Log.new(logger)
22
+ @plugin = TestPlugin.new(@log)
23
+ @handler = Fluent::Plugin::ElasticsearchErrorHandler.new(@plugin)
23
24
  end
24
25
 
25
26
  def parse_response(value)
@@ -39,7 +40,7 @@ class TestElasticsearchErrorHandler < Test::Unit::TestCase
39
40
  "status" : 500,
40
41
  "error" : {
41
42
  "type" : "some unrecognized type",
42
- "reason":"some error to cause version mismatch"
43
+ "reason":"unrecognized error"
43
44
  }
44
45
  }
45
46
  },
@@ -51,7 +52,7 @@ class TestElasticsearchErrorHandler < Test::Unit::TestCase
51
52
  "status" : 500,
52
53
  "error" : {
53
54
  "type" : "some unrecognized type",
54
- "reason":"some error to cause version mismatch"
55
+ "reason":"unrecognized error"
55
56
  }
56
57
  }
57
58
  },
@@ -79,7 +80,7 @@ class TestElasticsearchErrorHandler < Test::Unit::TestCase
79
80
  "status" : 400,
80
81
  "error" : {
81
82
  "type" : "some unrecognized type",
82
- "reason":"some error to cause version mismatch"
83
+ "reason":"unrecognized error"
83
84
  }
84
85
  }
85
86
  }
@@ -119,4 +120,171 @@ class TestElasticsearchErrorHandler < Test::Unit::TestCase
119
120
 
120
121
  end
121
122
 
123
+ def test_retry_with_successes_and_duplicates
124
+ response = parse_response(%(
125
+ {
126
+ "took" : 0,
127
+ "errors" : true,
128
+ "items" : [
129
+ {
130
+ "create" : {
131
+ "_index" : "foo",
132
+ "_type" : "bar",
133
+ "_id" : "abc",
134
+ "status" : 409,
135
+ "error" : {
136
+ "reason":"duplicate ID"
137
+ }
138
+ }
139
+ },
140
+ {
141
+ "create" : {
142
+ "_index" : "foo",
143
+ "_type" : "bar",
144
+ "_id" : "abc",
145
+ "status" : 201
146
+ }
147
+ }
148
+ ]
149
+ }
150
+ ))
151
+
152
+ @plugin.instance_variable_set(:@write_operation, 'create')
153
+ @handler.instance_variable_set(:@bulk_message_count, 2)
154
+ @handler.handle_error(response)
155
+ assert_match /retry succeeded - successes=1 duplicates=1/, @log.out.logs[0]
156
+ end
157
+
158
+ def test_bulk_rejection_errors
159
+ response = parse_response(%({
160
+ "took" : 0,
161
+ "errors" : true,
162
+ "items" : [
163
+ {
164
+ "create" : {
165
+ "_index" : "foo",
166
+ "_type" : "bar",
167
+ "_id" : "abc",
168
+ "status" : 500,
169
+ "error" : {
170
+ "type" : "some unrecognized type",
171
+ "reason":"unrecognized error"
172
+ }
173
+ }
174
+ },
175
+ {
176
+ "create" : {
177
+ "_index" : "foo",
178
+ "_type" : "bar",
179
+ "_id" : "abc",
180
+ "status" : 500,
181
+ "error" : {
182
+ "type" : "some unrecognized type",
183
+ "reason":"unrecognized error"
184
+ }
185
+ }
186
+ },
187
+ {
188
+ "create" : {
189
+ "_index" : "foo",
190
+ "_type" : "bar",
191
+ "_id" : "abc",
192
+ "status" : 201
193
+ }
194
+ },
195
+ {
196
+ "create" : {
197
+ "_index" : "foo",
198
+ "_type" : "bar",
199
+ "_id" : "abc",
200
+ "status" : 409
201
+ }
202
+ },
203
+ {
204
+ "create" : {
205
+ "_index" : "foo",
206
+ "_type" : "bar",
207
+ "_id" : "abc",
208
+ "status" : 429,
209
+ "error" : {
210
+ "type" : "es_rejected_execution_exception",
211
+ "reason":"Elasticsearch could not process bulk index request"
212
+ }
213
+ }
214
+ }
215
+ ]
216
+ }))
217
+
218
+ assert_raise Fluent::Plugin::ElasticsearchErrorHandler::BulkIndexQueueFull do
219
+ @handler.handle_error(response)
220
+ end
221
+
222
+ end
223
+
224
+ def test_out_of_memory_errors
225
+ response = parse_response(%({
226
+ "took" : 0,
227
+ "errors" : true,
228
+ "items" : [
229
+ {
230
+ "create" : {
231
+ "_index" : "foo",
232
+ "_type" : "bar",
233
+ "_id" : "abc",
234
+ "status" : 500,
235
+ "error" : {
236
+ "type" : "some unrecognized type",
237
+ "reason":"unrecognized error"
238
+ }
239
+ }
240
+ },
241
+ {
242
+ "create" : {
243
+ "_index" : "foo",
244
+ "_type" : "bar",
245
+ "_id" : "abc",
246
+ "status" : 500,
247
+ "error" : {
248
+ "type" : "some unrecognized type",
249
+ "reason":"unrecognized error"
250
+ }
251
+ }
252
+ },
253
+ {
254
+ "create" : {
255
+ "_index" : "foo",
256
+ "_type" : "bar",
257
+ "_id" : "abc",
258
+ "status" : 201
259
+ }
260
+ },
261
+ {
262
+ "create" : {
263
+ "_index" : "foo",
264
+ "_type" : "bar",
265
+ "_id" : "abc",
266
+ "status" : 409
267
+ }
268
+ },
269
+ {
270
+ "create" : {
271
+ "_index" : "foo",
272
+ "_type" : "bar",
273
+ "_id" : "abc",
274
+ "status" : 400,
275
+ "error" : {
276
+ "type" : "out_of_memory_error",
277
+ "reason":"Elasticsearch exhausted its heap"
278
+ }
279
+ }
280
+ }
281
+ ]
282
+ }))
283
+
284
+ assert_raise Fluent::Plugin::ElasticsearchErrorHandler::ElasticsearchOutOfMemory do
285
+ @handler.handle_error(response)
286
+ end
287
+
288
+ end
289
+
122
290
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-elasticsearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.1
4
+ version: 2.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - diogo
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-04-23 00:00:00.000000000 Z
12
+ date: 2018-04-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fluentd