logstash-filter-elasticsearch 3.13.0 → 3.14.0

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: 3d55417f0b601e60aa33702b94eec237fc3ed47dc37e06bfa83b1f8b3f2c0884
4
- data.tar.gz: 335f6c76502901f6b0021d8fd89be14b716c2c0f493e22c4d59bd865bcce91db
3
+ metadata.gz: aa249a04a85198ffab82e97a53f15c8c1ce3792b0d7f737962979aaccf0b8a78
4
+ data.tar.gz: 1501f7b558ead54e7701b0048b5f1f9847d250e96ebdf4cd2875000f733ad8c0
5
5
  SHA512:
6
- metadata.gz: cd657fd129d3972aff051cf111e15f18b40861631e3d47249887023e3779d6c9cbd09b515dcb7beb5d6783b73f5fef69d3e57425115f100b6cf7576984da832b
7
- data.tar.gz: 410cdfcd7857b6522f91549b8e57244624385f1dde1ddc393bbadb4a8c7468ea5e4df91697b9b5cb1221a1c99a0c4ea054a6a21a0babb52617bb0b54b71bd4bb
6
+ metadata.gz: c31a11c7588de85b8bbdb922c8938946a651230080202b2442dcea5fc3ef686e499aa74b3f10df9df172713b4b007e0e3ba539b7dff838fccb33da116c3aacbf
7
+ data.tar.gz: 3bcd227e3ba31712287bb27367959b8a5e032a7e9fa5a907f1ae7018e4422db6b3275bbcb3f88d83d6d623d5f015c2ae80a66a148e2bcb3a84181a801e486640
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 3.14.0
2
+ - Added support for configurable retries with new `retry_on_failure` and `retry_on_status` options [#160](https://github.com/logstash-plugins/logstash-filter-elasticsearch/pull/160)
3
+
1
4
  ## 3.13.0
2
5
  - Added support for this plugin identifying itself to Elasticsearch with an SSL/TLS client certificate using a new `keystore` option [#162](https://github.com/logstash-plugins/logstash-filter-elasticsearch/pull/162)
3
6
 
data/docs/index.asciidoc CHANGED
@@ -142,6 +142,8 @@ This plugin supports the following configuration options plus the <<plugins-{typ
142
142
  | <<plugins-{type}s-{plugin}-query>> |<<string,string>>|No
143
143
  | <<plugins-{type}s-{plugin}-query_template>> |<<string,string>>|No
144
144
  | <<plugins-{type}s-{plugin}-result_size>> |<<number,number>>|No
145
+ | <<plugins-{type}s-{plugin}-retry_on_failure>> |<<number,number>>|No
146
+ | <<plugins-{type}s-{plugin}-result_on_status_>> |<<number,number list>>|No
145
147
  | <<plugins-{type}s-{plugin}-sort>> |<<string,string>>|No
146
148
  | <<plugins-{type}s-{plugin}-ssl>> |<<boolean,boolean>>|No
147
149
  | <<plugins-{type}s-{plugin}-keystore>> |a valid filesystem path|No
@@ -330,11 +332,30 @@ the {ref}/query-dsl.html[Elasticsearch query documentation].
330
332
  [id="plugins-{type}s-{plugin}-result_size"]
331
333
  ===== `result_size`
332
334
 
333
- * Value type is <<number,number>>
334
- * Default value is `1`
335
+ * Value type is <<number,number>>
336
+ * Default value is `1`
335
337
 
336
338
  How many results to return
337
339
 
340
+ [id="plugins-{type}s-{plugin}-retry_on_failure"]
341
+ ===== `retry_on_failure`
342
+
343
+ * Value type is <<number,number>>
344
+ * Default value is `0` (retries disabled)
345
+
346
+ How many times to retry an individual failed request.
347
+
348
+ When enabled, retry requests that result in connection errors or an HTTP status code included in <<plugins-{type}s-{plugin}-retry_on_status>>
349
+
350
+ [id="plugins-{type}s-{plugin}-retry_on_status"]
351
+ ===== `retry_on_status`
352
+
353
+ * Value type is <<number,number list>>
354
+ * Default value is an empty list `[]`
355
+
356
+ Which HTTP Status codes to consider for retries (in addition to connection errors) when using <<plugins-{type}s-{plugin}-retry_on_failure>>,
357
+
358
+
338
359
  [id="plugins-{type}s-{plugin}-sort"]
339
360
  ===== `sort`
340
361
 
@@ -34,15 +34,23 @@ module LogStash
34
34
  # set ca_file even if ssl isn't on, since the host can be an https url
35
35
  ssl_options.update(ssl: true, ca_file: options[:ca_file]) if options[:ca_file]
36
36
  ssl_options.update(ssl: true, trust_strategy: options[:ssl_trust_strategy]) if options[:ssl_trust_strategy]
37
-
38
37
  if keystore
39
38
  ssl_options[:keystore] = keystore
40
39
  logger.debug("Keystore for client certificate", :keystore => keystore)
41
40
  ssl_options[:keystore_password] = keystore_password.value if keystore_password
42
41
  end
43
42
 
43
+ client_options = {
44
+ hosts: hosts,
45
+ transport_class: ::Elasticsearch::Transport::Transport::HTTP::Manticore,
46
+ transport_options: transport_options,
47
+ ssl: ssl_options,
48
+ retry_on_failure: options[:retry_on_failure],
49
+ retry_on_status: options[:retry_on_status]
50
+ }
51
+
44
52
  logger.info("New ElasticSearch filter client", :hosts => hosts)
45
- @client = ::Elasticsearch::Client.new(hosts: hosts, transport_options: transport_options, transport_class: ::Elasticsearch::Transport::Transport::HTTP::Manticore, :ssl => ssl_options)
53
+ @client = ::Elasticsearch::Client.new(client_options)
46
54
  end
47
55
 
48
56
  def search(params)
@@ -82,6 +82,12 @@ class LogStash::Filters::Elasticsearch < LogStash::Filters::Base
82
82
  # Tags the event on failure to look up geo information. This can be used in later analysis.
83
83
  config :tag_on_failure, :validate => :array, :default => ["_elasticsearch_lookup_failure"]
84
84
 
85
+ # How many times to retry on failure?
86
+ config :retry_on_failure, :validate => :number, :default => 0
87
+
88
+ # What status codes to retry on?
89
+ config :retry_on_status, :validate => :number, :list => true, :default => [500, 502, 503, 504]
90
+
85
91
  # config :ca_trusted_fingerprint, :validate => :sha_256_hex
86
92
  include LogStash::PluginMixins::CATrustedFingerprintSupport
87
93
 
@@ -215,6 +221,8 @@ class LogStash::Filters::Elasticsearch < LogStash::Filters::Base
215
221
  :proxy => @proxy,
216
222
  :ssl => @ssl,
217
223
  :ca_file => @ca_file,
224
+ :retry_on_failure => @retry_on_failure,
225
+ :retry_on_status => @retry_on_status,
218
226
  :keystore => @keystore,
219
227
  :keystore_password => @keystore_password,
220
228
  :ssl_trust_strategy => trust_strategy_for_ca_trusted_fingerprint
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-filter-elasticsearch'
4
- s.version = '3.13.0'
4
+ s.version = '3.14.0'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "Copies fields from previous log events in Elasticsearch to current events "
7
7
  s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
@@ -29,4 +29,3 @@ Gem::Specification.new do |s|
29
29
 
30
30
  s.add_development_dependency 'logstash-devutils'
31
31
  end
32
-
@@ -301,6 +301,15 @@ describe LogStash::Filters::Elasticsearch do
301
301
  end
302
302
  end
303
303
 
304
+ context 'with client-level retries' do
305
+ let(:config) do
306
+ super().merge(
307
+ "retry_on_failure" => 3,
308
+ "retry_on_status" => [500]
309
+ )
310
+ end
311
+ end
312
+
304
313
  context "if query is on nested field" do
305
314
  let(:config) do
306
315
  {
@@ -559,6 +568,28 @@ describe LogStash::Filters::Elasticsearch do
559
568
  end
560
569
  end
561
570
  end
571
+
572
+ describe "retry_on_failure" do
573
+ let(:config) { super().merge("retry_on_failure" => 3) }
574
+
575
+ it 'propagates to the client' do
576
+ plugin.register
577
+
578
+ client = plugin.send(:get_client).client
579
+ expect( extract_transport(client).options[:retry_on_failure] ).to eq(3)
580
+ end
581
+ end
582
+
583
+ describe "retry_on_status" do
584
+ let(:config) { super().merge("retry_on_status" => [500, 502, 503, 504]) }
585
+
586
+ it 'propagates to the client' do
587
+ plugin.register
588
+
589
+ client = plugin.send(:get_client).client
590
+ expect( extract_transport(client).options[:retry_on_status] ).to eq([500, 502, 503, 504])
591
+ end
592
+ end
562
593
  end
563
594
 
564
595
  describe "ca_trusted_fingerprint" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-elasticsearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.13.0
4
+ version: 3.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-26 00:00:00.000000000 Z
11
+ date: 2023-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement