fluent-plugin-elasticsearch 1.16.0 → 1.16.1

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
  SHA256:
3
- metadata.gz: 15e80a669ab0e24b83a279e1cbcc3240b76560b445319b7af7b2f719523b86e1
4
- data.tar.gz: df01b4f813ffeba65619b778d418384b1cf3df3323929cf2921cf1273a336738
3
+ metadata.gz: 222baba6d90b4d1146642683a3e6144b6339d2c4dc6a6a456c238fc984ae6023
4
+ data.tar.gz: 929e1d360821206f8a17e76e2a4948d65c855c77ab68fcca372a2c9be2471170
5
5
  SHA512:
6
- metadata.gz: 2e44489b1f603ae61d9566c4cd0d6c16a7cec6ee5c701053f884ee284945fa2f48407674108223ec6c4c7127daabcaf17b6eb534b06d8c26339dd3aaba2fa908
7
- data.tar.gz: cee4380e5d0aecfd9305bdbc68eaf3c2dbc9fef6b0e8f88f05ad4870a33d3b330983118a6ebe492ac4645805ec23c7acc270b91d37d6a222ed03ebc5ae28c6a5
6
+ metadata.gz: 0aac8b9d854aa8042f8fd0a79faec608e202ae77fc53e8ad123f28b9b38021fd6de5cc011427cf1311bc19d701c4c529746647fa007579303fb13018e99f0d51
7
+ data.tar.gz: f5622800b63e568c2b8e15fe4e6d05523bede040d9d86edc5f88db557d4eff4c66223fc3beeac3b687af4e9680e25972ca21e8b572012b5a2f7a3b1726a7b453
data/History.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ### [Unreleased]
4
4
 
5
+ ### 1.16.1
6
+ - allow configure of retry_tag so messages can be routed through a different pipeline (#419)
7
+ - fix #417. emit_error_event using an exception (#418)
8
+
5
9
  ### 1.16.0
6
10
  - evaluate bulk request failures and reroute failed messages (#405)
7
11
 
data/README.md CHANGED
@@ -45,6 +45,7 @@ Note: For Amazon Elasticsearch Service please consider using [fluent-plugin-aws-
45
45
  + [remove_keys](#remove_keys)
46
46
  + [remove_keys_on_update](#remove_keys_on_update)
47
47
  + [remove_keys_on_update_key](#remove_keys_on_update_key)
48
+ + [retry_tag](#retry_tag)
48
49
  + [write_operation](#write_operation)
49
50
  + [time_parse_error_tag](#time_parse_error_tag)
50
51
  + [reconnect_on_error](#reconnect_on_error)
@@ -435,6 +436,21 @@ present in the record then the keys in record are used, if the `remove_keys_on_u
435
436
  remove_keys_on_update_key keys_to_skip
436
437
  ```
437
438
 
439
+ ### retry_tag
440
+
441
+ This setting allows custom routing of messages in response to bulk request failures. The default behavior is to emit
442
+ failed records using the same tag that was provided. When set to a value other then `nil`, failed messages are emitted
443
+ with the specified tag:
444
+
445
+ ```
446
+ retry_tag 'retry_es'
447
+ ```
448
+ **NOTE:** `retry_tag` is optional. If you would rather use labels to reroute retries, add a label (e.g '@label @SOMELABEL') to your fluent
449
+ elasticsearch plugin configuration. Retry records are, by default, submitted for retry to the ROOT label, which means
450
+ records will flow through your fluentd pipeline from the beginning. This may nor may not be a problem if the pipeline
451
+ is idempotent - that is - you can process a record again with no changes. Use tagging or labeling to ensure your retry
452
+ records are not processed again by your fluentd processing pipeline.
453
+
438
454
  ### write_operation
439
455
 
440
456
  The write_operation can be any of:
@@ -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 = '1.16.0'
6
+ s.version = '1.16.1'
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}
@@ -61,7 +61,7 @@ class Fluent::ElasticsearchErrorHandler
61
61
  stats[:duplicates] += 1
62
62
  when 400 == status
63
63
  stats[:bad_argument] += 1
64
- @plugin.router.emit_error_event(tag, time, rawrecord, '400 - Rejected by Elasticsearch')
64
+ @plugin.router.emit_error_event(tag, time, rawrecord, ElasticsearchError.new('400 - Rejected by Elasticsearch'))
65
65
  else
66
66
  if item[write_operation].has_key?('error') && item[write_operation]['error'].has_key?('type')
67
67
  type = item[write_operation]['error']['type']
@@ -71,7 +71,7 @@ class Fluent::ElasticsearchErrorHandler
71
71
  # When we don't have a type field, something changed in the API
72
72
  # expected return values (ES 2.x)
73
73
  stats[:errors_bad_resp] += 1
74
- @plugin.router.emit_error_event(tag, time, rawrecord, "#{status} - No error type provided in the response")
74
+ @plugin.router.emit_error_event(tag, time, rawrecord, ElasticsearchError.new("#{status} - No error type provided in the response"))
75
75
  next
76
76
  end
77
77
  stats[type] += 1
@@ -56,6 +56,7 @@ class Fluent::ElasticsearchOutput < Fluent::ObjectBufferedOutput
56
56
  config_param :request_timeout, :time, :default => 5
57
57
  config_param :reload_connections, :bool, :default => true
58
58
  config_param :reload_on_failure, :bool, :default => false
59
+ config_param :retry_tag, :string, :default=>nil
59
60
  config_param :resurrect_after, :time, :default => 60
60
61
  config_param :time_key, :string, :default => nil
61
62
  config_param :time_key_exclude_timestamp, :bool, :default => false
@@ -428,7 +429,8 @@ class Fluent::ElasticsearchOutput < Fluent::ObjectBufferedOutput
428
429
  error.handle_error(response, tag, chunk, bulk_message_count)
429
430
  end
430
431
  rescue RetryStreamError => e
431
- router.emit_stream(tag, e.retry_stream)
432
+ emit_tag = @retry_tag ? @retry_tag : tag
433
+ router.emit_stream(emit_tag, e.retry_stream)
432
434
  rescue *client.transport.host_unreachable_exceptions => e
433
435
  if retries < 2
434
436
  retries += 1
@@ -11,7 +11,7 @@ class TestElasticsearchErrorHandler < Test::Unit::TestCase
11
11
  def initialize(log)
12
12
  @log = log
13
13
  @write_operation = 'index'
14
- @error_events = Fluent::MultiEventStream.new
14
+ @error_events = []
15
15
  end
16
16
 
17
17
  def router
@@ -19,7 +19,7 @@ class TestElasticsearchErrorHandler < Test::Unit::TestCase
19
19
  end
20
20
 
21
21
  def emit_error_event(tag, time, record, e)
22
- @error_events.add(time, record)
22
+ @error_events << {:tag => tag, :time=>time, :record=>record, :error=>e}
23
23
  end
24
24
 
25
25
  def process_message(tag, meta, header, time, record, bulk_message)
@@ -75,7 +75,8 @@ class TestElasticsearchErrorHandler < Test::Unit::TestCase
75
75
  }))
76
76
  chunk = MockChunk.new(records)
77
77
  @handler.handle_error(response, 'atag', chunk, records.length)
78
- assert_equal(1, @plugin.error_events.instance_variable_get(:@time_array).size)
78
+ assert_equal(1, @plugin.error_events.size)
79
+ assert_true(@plugin.error_events[0][:error].respond_to?(:backtrace))
79
80
  end
80
81
 
81
82
  def test_retry_error
@@ -181,10 +182,13 @@ class TestElasticsearchErrorHandler < Test::Unit::TestCase
181
182
  assert_equal 2, records[0]['_id']
182
183
  assert_equal 6, records[1]['_id']
183
184
  assert_equal 8, records[2]['_id']
184
- errors = @plugin.error_events.collect {|time, record| record}
185
- assert_equal 2, errors.length
186
- assert_equal 5, errors[0]['_id']
187
- assert_equal 7, errors[1]['_id']
185
+ error_ids = @plugin.error_events.collect {|h| h[:record]['_id']}
186
+ assert_equal 2, error_ids.length
187
+ assert_equal 5, error_ids[0]
188
+ assert_equal 7, error_ids[1]
189
+ @plugin.error_events.collect {|h| h[:error]}.each do |e|
190
+ assert_true e.respond_to?(:backtrace)
191
+ end
188
192
  end
189
193
  assert_true failed
190
194
 
@@ -1348,6 +1348,39 @@ class ElasticsearchOutput < Test::Unit::TestCase
1348
1348
  assert_equal(connection_resets, 1)
1349
1349
  end
1350
1350
 
1351
+ def test_bulk_error_retags_when_configured
1352
+ driver.configure("retry_tag retry\n")
1353
+ stub_elastic_ping
1354
+ stub_request(:post, 'http://localhost:9200/_bulk')
1355
+ .to_return(lambda do |req|
1356
+ { :status => 200,
1357
+ :headers => { 'Content-Type' => 'json' },
1358
+ :body => %({
1359
+ "took" : 1,
1360
+ "errors" : true,
1361
+ "items" : [
1362
+ {
1363
+ "create" : {
1364
+ "_index" : "foo",
1365
+ "_type" : "bar",
1366
+ "_id" : "abc",
1367
+ "status" : 500,
1368
+ "error" : {
1369
+ "type" : "some unrecognized type",
1370
+ "reason":"some error to cause version mismatch"
1371
+ }
1372
+ }
1373
+ }
1374
+ ]
1375
+ })
1376
+ }
1377
+ end)
1378
+ driver.emit(sample_record, 1)
1379
+
1380
+ driver.expect_emit('retry', 1, sample_record)
1381
+ driver.run
1382
+ end
1383
+
1351
1384
  def test_bulk_error
1352
1385
  stub_elastic_ping
1353
1386
  stub_request(:post, 'http://localhost:9200/_bulk')
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: 1.16.0
4
+ version: 1.16.1
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-05-02 00:00:00.000000000 Z
12
+ date: 2018-05-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fluentd