fluent-plugin-elasticsearch 3.3.2 → 3.3.3

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: 65a43866400112b8742307709fb258518efdee379cdbb56b324ed365d8a4e1d7
4
- data.tar.gz: 716149f2c5aa5380bbfc95e916d730572546bfae2520ed0b792dc6b6a828d78c
3
+ metadata.gz: 2d075f2b8fe2deb8579ce232104c2e497eb6aee6703b28f0288728b2f2622c23
4
+ data.tar.gz: 580c94f146d2039d242cc0e02487bc771e12e0f9ac885d634ea4fc169c6e577b
5
5
  SHA512:
6
- metadata.gz: 6d98dc4fef7b9fe208d549fc93f8a4809bfb56f156bee069bf0f599891d13b29adad5d119e9e7a2274f31aede5a13879dbf16223f98a3642d598f9f71eb2665f
7
- data.tar.gz: ab08e35c256740009631cf5d8fa13c9f8ab9edc98f172e106d111177b4a069db13ba27a60f201c71411727bdb9cac63de716d0b6d9e4ae2184a3eac8ae12131f
6
+ metadata.gz: d98b07c8fe8e0c13d290e50957c9f2f6f6d988173bc3dbe3a6f36bedf546531f85639d3fce637295eefb14d5c3726a77e3b91fd418b451080caae03399177df8
7
+ data.tar.gz: 3cc3ab52cb741c020568fd55e82d496805b5a66b2d54ea6a9cf09917413099934f17bc6d69fce8b9ef431f7b0dde6662d27d9649d6ecd4330dce55fae932364d
data/History.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ### [Unreleased]
4
4
 
5
+ ### 3.3.3
6
+ - Add unit test for exception message (#563)
7
+ - Add ignore_exceptions config (#562)
8
+
5
9
  ### 3.3.2
6
10
  - Fix support for host, hosts placeholders (#560)
7
11
  - typo fixes in README.md (#559)
data/README.md CHANGED
@@ -82,6 +82,8 @@ Current maintainers: @cosmo0920
82
82
  + [Multi workers](#multi-workers)
83
83
  + [log_es_400_reason](#log_es_400_reason)
84
84
  + [suppress_doc_wrap](#suppress_doc_wrap)
85
+ + [ignore_exceptions](#ignore_exceptions)
86
+ + [exception_backup](#exception_backup)
85
87
  * [Troubleshooting](#troubleshooting)
86
88
  + [Cannot send events to elasticsearch](#cannot-send-events-to-elasticsearch)
87
89
  + [Cannot see detailed failure log](#cannot-see-detailed-failure-log)
@@ -1032,6 +1034,24 @@ By default, record body is wrapped by 'doc'. This behavior can not handle update
1032
1034
 
1033
1035
  Default value is `false`.
1034
1036
 
1037
+ ## ignore_exceptions
1038
+
1039
+ A list of exception that will be ignored - when the exception occurs the chunk will be discarded and the buffer retry mechanism won't be called. It is possible also to specify classes at higher level in the hierarchy. For example
1040
+
1041
+ ```
1042
+ ignore_exceptions ["Elasticsearch::Transport::Transport::ServerError"]
1043
+ ```
1044
+
1045
+ will match all subclasses of `ServerError` - `Elasticsearch::Transport::Transport::Errors::BadRequest`, `Elasticsearch::Transport::Transport::Errors::ServiceUnavailable`, etc.
1046
+
1047
+ Default value is empty list (no exception is ignored).
1048
+
1049
+ ## exception_backup
1050
+
1051
+ Indicates whether to backup chunk when ignore exception occurs.
1052
+
1053
+ Default value is `true`.
1054
+
1035
1055
  ## Troubleshooting
1036
1056
 
1037
1057
  ### Cannot send events to Elasticsearch
@@ -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 = '3.3.2'
6
+ s.version = '3.3.3'
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}
@@ -133,6 +133,8 @@ EOC
133
133
  config_param :log_es_400_reason, :bool, :default => false
134
134
  config_param :custom_headers, :hash, :default => {}
135
135
  config_param :suppress_doc_wrap, :bool, :default => false
136
+ config_param :ignore_exceptions, :array, :default => [], value_type: :string, :desc => "Ignorable exception list"
137
+ config_param :exception_backup, :bool, :default => true, :desc => "Chunk backup flag when ignore exception occured"
136
138
 
137
139
  config_section :buffer do
138
140
  config_set_default :@type, DEFAULT_BUFFER_TYPE
@@ -275,6 +277,16 @@ EOC
275
277
 
276
278
  @routing_key_name = configure_routing_key_name
277
279
  @current_config = nil
280
+
281
+ @ignore_exception_classes = @ignore_exceptions.map do |exception|
282
+ unless Object.const_defined?(exception)
283
+ log.warn "Cannot find class #{exception}. Will ignore it."
284
+
285
+ nil
286
+ else
287
+ Object.const_get(exception)
288
+ end
289
+ end.compact
278
290
  end
279
291
 
280
292
  def backend_options
@@ -678,10 +690,17 @@ EOC
678
690
  emit_tag = @retry_tag ? @retry_tag : tag
679
691
  router.emit_stream(emit_tag, e.retry_stream)
680
692
  rescue => e
693
+ ignore = @ignore_exception_classes.any? { |clazz| e.class <= clazz }
694
+
695
+ log.warn "Exception ignored in tag #{tag}: #{e.class.name} #{e.message}" if ignore
696
+
681
697
  @_es = nil if @reconnect_on_error
682
698
  @_es_info = nil if @reconnect_on_error
699
+
700
+ raise UnrecoverableRequestFailure if ignore && @exception_backup
701
+
683
702
  # FIXME: identify unrecoverable errors and raise UnrecoverableRequestFailure instead
684
- raise RecoverableRequestFailure, "could not push logs to Elasticsearch cluster (#{connection_options_description(info.host)}): #{e.message}"
703
+ raise RecoverableRequestFailure, "could not push logs to Elasticsearch cluster (#{connection_options_description(info.host)}): #{e.message}" unless ignore
685
704
  end
686
705
  end
687
706
 
@@ -1546,6 +1546,26 @@ class ElasticsearchOutput < Test::Unit::TestCase
1546
1546
  assert_requested(first_request)
1547
1547
  assert_requested(second_request)
1548
1548
  end
1549
+
1550
+ def test_writes_to_extracted_host_with_placeholder_replaced_in_exception_message
1551
+ driver.configure(Fluent::Config::Element.new(
1552
+ 'ROOT', '', {
1553
+ '@type' => 'elasticsearch',
1554
+ 'host' => 'myhost-${pipeline_id}',
1555
+ }, [
1556
+ Fluent::Config::Element.new('buffer', 'tag,pipeline_id', {}, [])
1557
+ ]
1558
+ ))
1559
+ time = Time.parse Date.today.iso8601
1560
+ pipeline_id = "1"
1561
+ request = stub_elastic_unavailable("http://myhost-1:9200/_bulk")
1562
+ exception = assert_raise(Fluent::Plugin::ElasticsearchOutput::RecoverableRequestFailure) {
1563
+ driver.run(default_tag: 'test') do
1564
+ driver.feed(time.to_i, sample_record.merge({"pipeline_id" => pipeline_id}))
1565
+ end
1566
+ }
1567
+ assert_equal("could not push logs to Elasticsearch cluster ({:host=>\"myhost-1\", :port=>9200, :scheme=>\"http\"}): [503] ", exception.message)
1568
+ end
1549
1569
  end
1550
1570
 
1551
1571
  def test_writes_to_logstash_index_with_specified_prefix_uppercase
@@ -2569,4 +2589,32 @@ class ElasticsearchOutput < Test::Unit::TestCase
2569
2589
  )
2570
2590
  end
2571
2591
 
2592
+ def test_ignore_exception
2593
+ driver.configure('ignore_exceptions ["Elasticsearch::Transport::Transport::Errors::ServiceUnavailable"]')
2594
+ stub_elastic_unavailable
2595
+
2596
+ driver.run(default_tag: 'test') do
2597
+ driver.feed(sample_record)
2598
+ end
2599
+ end
2600
+
2601
+ def test_ignore_exception_with_superclass
2602
+ driver.configure('ignore_exceptions ["Elasticsearch::Transport::Transport::ServerError"]')
2603
+ stub_elastic_unavailable
2604
+
2605
+ driver.run(default_tag: 'test') do
2606
+ driver.feed(sample_record)
2607
+ end
2608
+ end
2609
+
2610
+ def test_ignore_excetion_handles_appropriate_ones
2611
+ driver.configure('ignore_exceptions ["Faraday::ConnectionFailed"]')
2612
+ stub_elastic_unavailable
2613
+
2614
+ assert_raise(Fluent::Plugin::ElasticsearchOutput::RecoverableRequestFailure) {
2615
+ driver.run(default_tag: 'test', shutdown: false) do
2616
+ driver.feed(sample_record)
2617
+ end
2618
+ }
2619
+ end
2572
2620
  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: 3.3.2
4
+ version: 3.3.3
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: 2019-03-18 00:00:00.000000000 Z
12
+ date: 2019-03-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fluentd