fluent-plugin-elasticsearch 2.10.0 → 2.10.1

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: f778421b8290ea1db16ad57f1c0be9a35e656d201e5b52c502ae9301c60a67c3
4
- data.tar.gz: 7e72d88f792ac7a959faa393e91fcc08917ada672860730352219b5d26b167b4
3
+ metadata.gz: 8e64450e9c4dca90c39c52e6c9bd2a6b3bc3958644f608fde7444c2024f68b62
4
+ data.tar.gz: 05a52be8643cacf7e5301d50a6d545c7105acd84ffca1ba417551929d4c0fed4
5
5
  SHA512:
6
- metadata.gz: 8222728bf41a377029aa620f94f7d773529d4dbae47081158022c49b8ebb08aed224d93208db1d4933663ea5226decd1e99096c9890a0f59a58d22e8aca9d5ae
7
- data.tar.gz: fe857ad374b96cfc4eeedb02642fc1bebfb4da43f0cba397789db9f74a6df6704ffb1c57b65524b00866e4b540c97130c387f6252bbf35fa1215d95c7f3c1f1a
6
+ metadata.gz: 3e6c52a7f807205e3f851039710b207f0afccdafd3fe9337a471e65752bc9aa8a5737790b33d0dc2e1a09569cad282cdc97450e3cffb23bef16907b9680cf521
7
+ data.tar.gz: af806e72ce8af92c9486432feca7d2a5fc1f5c241d98de54af6301321864fb29a88c2a81be1c487bb81292947d9d970df10d95b6b683434910b0c52b82bbb589
data/History.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ### [Unreleased]
4
4
 
5
+ ### 2.10.1
6
+ - Uplift Merge pull request #419 from jcantrill/retry_prefix (#421)
7
+ - Uplift Merge pull request #418 from jcantrill/emit_exception (#420)
8
+
5
9
  ### 2.10.0
6
10
  - Uplift Merge pull request #405 from jcantrill/sanitize_bulk (#414)
7
11
 
data/README.md CHANGED
@@ -47,6 +47,7 @@ Current maintainers: @cosmo0920
47
47
  + [remove_keys](#remove_keys)
48
48
  + [remove_keys_on_update](#remove_keys_on_update)
49
49
  + [remove_keys_on_update_key](#remove_keys_on_update_key)
50
+ + [retry_tag](#retry_tag)
50
51
  + [write_operation](#write_operation)
51
52
  + [time_parse_error_tag](#time_parse_error_tag)
52
53
  + [reconnect_on_error](#reconnect_on_error)
@@ -526,6 +527,21 @@ present in the record then the keys in record are used, if the `remove_keys_on_u
526
527
  remove_keys_on_update_key keys_to_skip
527
528
  ```
528
529
 
530
+ ### retry_tag
531
+
532
+ This setting allows custom routing of messages in response to bulk request failures. The default behavior is to emit
533
+ failed records using the same tag that was provided. When set to a value other then `nil`, failed messages are emitted
534
+ with the specified tag:
535
+
536
+ ```
537
+ retry_tag 'retry_es'
538
+ ```
539
+ **NOTE:** `retry_tag` is optional. If you would rather use labels to reroute retries, add a label (e.g '@label @SOMELABEL') to your fluent
540
+ elasticsearch plugin configuration. Retry records are, by default, submitted for retry to the ROOT label, which means
541
+ records will flow through your fluentd pipeline from the beginning. This may nor may not be a problem if the pipeline
542
+ is idempotent - that is - you can process a record again with no changes. Use tagging or labeling to ensure your retry
543
+ records are not processed again by your fluentd processing pipeline.
544
+
529
545
  ### write_operation
530
546
 
531
547
  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 = '2.10.0'
6
+ s.version = '2.10.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::Plugin::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::Plugin::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
@@ -67,6 +67,7 @@ EOC
67
67
  config_param :request_timeout, :time, :default => 5
68
68
  config_param :reload_connections, :bool, :default => true
69
69
  config_param :reload_on_failure, :bool, :default => false
70
+ config_param :retry_tag, :string, :default=>nil
70
71
  config_param :resurrect_after, :time, :default => 60
71
72
  config_param :time_key, :string, :default => nil
72
73
  config_param :time_key_exclude_timestamp, :bool, :default => false
@@ -510,7 +511,8 @@ EOC
510
511
  error.handle_error(response, tag, chunk, bulk_message_count, extracted_values)
511
512
  end
512
513
  rescue RetryStreamError => e
513
- router.emit_stream(tag, e.retry_stream)
514
+ emit_tag = @retry_tag ? @retry_tag : tag
515
+ router.emit_stream(emit_tag, e.retry_stream)
514
516
  rescue *client.transport.host_unreachable_exceptions => e
515
517
  if retries < 2
516
518
  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, extracted_values)
@@ -72,7 +72,8 @@ class TestElasticsearchErrorHandler < Test::Unit::TestCase
72
72
  chunk = MockChunk.new(records)
73
73
  dummy_extracted_values = []
74
74
  @handler.handle_error(response, 'atag', chunk, records.length, dummy_extracted_values)
75
- assert_equal(1, @plugin.error_events.instance_variable_get(:@time_array).size)
75
+ assert_equal(1, @plugin.error_events.size)
76
+ assert_true(@plugin.error_events[0][:error].respond_to?(:backtrace))
76
77
  end
77
78
 
78
79
  def test_retry_error
@@ -179,10 +180,13 @@ class TestElasticsearchErrorHandler < Test::Unit::TestCase
179
180
  assert_equal 2, records[0]['_id']
180
181
  assert_equal 6, records[1]['_id']
181
182
  assert_equal 8, records[2]['_id']
182
- errors = @plugin.error_events.collect {|time, record| record}
183
- assert_equal 2, errors.length
184
- assert_equal 5, errors[0]['_id']
185
- assert_equal 7, errors[1]['_id']
183
+ error_ids = @plugin.error_events.collect {|h| h[:record]['_id']}
184
+ assert_equal 2, error_ids.length
185
+ assert_equal 5, error_ids[0]
186
+ assert_equal 7, error_ids[1]
187
+ @plugin.error_events.collect {|h| h[:error]}.each do |e|
188
+ assert_true e.respond_to?(:backtrace)
189
+ end
186
190
  end
187
191
  assert_true failed
188
192
 
@@ -1718,6 +1718,40 @@ class ElasticsearchOutput < Test::Unit::TestCase
1718
1718
  assert_equal(connection_resets, 1)
1719
1719
  end
1720
1720
 
1721
+ def test_bulk_error_retags_when_configured
1722
+ driver.configure("retry_tag retry\n")
1723
+ stub_elastic_ping
1724
+ stub_request(:post, 'http://localhost:9200/_bulk')
1725
+ .to_return(lambda do |req|
1726
+ { :status => 200,
1727
+ :headers => { 'Content-Type' => 'json' },
1728
+ :body => %({
1729
+ "took" : 1,
1730
+ "errors" : true,
1731
+ "items" : [
1732
+ {
1733
+ "create" : {
1734
+ "_index" : "foo",
1735
+ "_type" : "bar",
1736
+ "_id" : "abc",
1737
+ "status" : 500,
1738
+ "error" : {
1739
+ "type" : "some unrecognized type",
1740
+ "reason":"some error to cause version mismatch"
1741
+ }
1742
+ }
1743
+ }
1744
+ ]
1745
+ })
1746
+ }
1747
+ end)
1748
+
1749
+ driver.run(default_tag: 'test') do
1750
+ driver.feed(1, sample_record)
1751
+ end
1752
+
1753
+ assert_equal [['retry', 1, sample_record]], driver.events
1754
+ end
1721
1755
 
1722
1756
  def test_bulk_error
1723
1757
  stub_elastic_ping
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.10.0
4
+ version: 2.10.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-03 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