logstash-input-elasticsearch 4.7.1 → 4.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/docs/index.asciidoc +31 -0
- data/lib/logstash/inputs/elasticsearch.rb +50 -15
- data/logstash-input-elasticsearch.gemspec +1 -1
- data/spec/inputs/elasticsearch_spec.rb +48 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74690fbfa461c4c9087181c3f95e4feb33f68e6398cc357a1c8d12d6bca8d837
|
4
|
+
data.tar.gz: 67425c9a092529e779e0c7693cc8afa9eaed0cfb188509026881d1972f970f3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63482d80b537ba41ca5d3ed34a1e35dc6550887747b7d50a7320564dbd5fcac3336519cae21c21363322616f6a1c66f803743e2246e2d2dc8adf2b03b0a23231
|
7
|
+
data.tar.gz: 98547555319b8d856ea58ed33b8236fcf15c2483594ca45c9c2e09791b4a20f6250ae7019e4e1be341f2000816a90e522b8c6fb21bec3b1aebc6b511cce2e09a
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
## 4.8.0
|
2
|
+
- Added the ability to configure connection-, request-, and socket-timeouts with `connect_timeout_seconds`, `request_timeout_seconds`, and `socket_timeout_seconds` [#121](https://github.com/logstash-plugins/logstash-input-elasticsearch/issues/121)
|
3
|
+
|
1
4
|
## 4.7.1
|
2
5
|
- [DOC] Updated sliced scroll link to resolve to correct location after doc structure change [#135](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/135)
|
3
6
|
- [DOC] Added usage example of docinfo metadata [#98](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/98)
|
data/docs/index.asciidoc
CHANGED
@@ -90,6 +90,7 @@ This plugin supports the following configuration options plus the <<plugins-{typ
|
|
90
90
|
| <<plugins-{type}s-{plugin}-ca_file>> |a valid filesystem path|No
|
91
91
|
| <<plugins-{type}s-{plugin}-cloud_auth>> |<<password,password>>|No
|
92
92
|
| <<plugins-{type}s-{plugin}-cloud_id>> |<<string,string>>|No
|
93
|
+
| <<plugins-{type}s-{plugin}-connect_timeout_seconds>> | <<number,number>>|No
|
93
94
|
| <<plugins-{type}s-{plugin}-docinfo>> |<<boolean,boolean>>|No
|
94
95
|
| <<plugins-{type}s-{plugin}-docinfo_fields>> |<<array,array>>|No
|
95
96
|
| <<plugins-{type}s-{plugin}-docinfo_target>> |<<string,string>>|No
|
@@ -98,11 +99,13 @@ This plugin supports the following configuration options plus the <<plugins-{typ
|
|
98
99
|
| <<plugins-{type}s-{plugin}-password>> |<<password,password>>|No
|
99
100
|
| <<plugins-{type}s-{plugin}-proxy>> |<<uri,uri>>|No
|
100
101
|
| <<plugins-{type}s-{plugin}-query>> |<<string,string>>|No
|
102
|
+
| <<plugins-{type}s-{plugin}-request_timeout_seconds>> | <<number,number>>|No
|
101
103
|
| <<plugins-{type}s-{plugin}-schedule>> |<<string,string>>|No
|
102
104
|
| <<plugins-{type}s-{plugin}-scroll>> |<<string,string>>|No
|
103
105
|
| <<plugins-{type}s-{plugin}-size>> |<<number,number>>|No
|
104
106
|
| <<plugins-{type}s-{plugin}-slices>> |<<number,number>>|No
|
105
107
|
| <<plugins-{type}s-{plugin}-ssl>> |<<boolean,boolean>>|No
|
108
|
+
| <<plugins-{type}s-{plugin}-socket_timeout_seconds>> | <<number,number>>|No
|
106
109
|
| <<plugins-{type}s-{plugin}-user>> |<<string,string>>|No
|
107
110
|
|=======================================================================
|
108
111
|
|
@@ -149,6 +152,15 @@ Cloud ID, from the Elastic Cloud web console. If set `hosts` should not be used.
|
|
149
152
|
|
150
153
|
For more info, check out the https://www.elastic.co/guide/en/logstash/current/connecting-to-cloud.html#_cloud_id[Logstash-to-Cloud documentation]
|
151
154
|
|
155
|
+
[id="plugins-{type}s-{plugin}-connect_timeout_seconds"]
|
156
|
+
===== `connect_timeout_seconds`
|
157
|
+
|
158
|
+
* Value type is <<number,number>>
|
159
|
+
* Default value is `10`
|
160
|
+
|
161
|
+
The maximum amount of time, in seconds, to wait while establishing a connection to Elasticsearch.
|
162
|
+
Connect timeouts tend to occur when Elasticsearch or an intermediate proxy is overloaded with requests and has exhausted its connection pool.
|
163
|
+
|
152
164
|
[id="plugins-{type}s-{plugin}-docinfo"]
|
153
165
|
===== `docinfo`
|
154
166
|
|
@@ -271,6 +283,16 @@ The query to be executed. Read the
|
|
271
283
|
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html[Elasticsearch query DSL documentation]
|
272
284
|
for more information.
|
273
285
|
|
286
|
+
[id="plugins-{type}s-{plugin}-request_timeout_seconds"]
|
287
|
+
===== `request_timeout_seconds`
|
288
|
+
|
289
|
+
* Value type is <<number,number>>
|
290
|
+
* Default value is `60`
|
291
|
+
|
292
|
+
The maximum amount of time, in seconds, for a single request to Elasticsearch.
|
293
|
+
Request timeouts tend to occur when an individual page of data is very large, such as when it contains large-payload
|
294
|
+
documents and/or the <<plugins-{type}s-{plugin}-size>> has been specified as a large value.
|
295
|
+
|
274
296
|
[id="plugins-{type}s-{plugin}-schedule"]
|
275
297
|
===== `schedule`
|
276
298
|
|
@@ -334,6 +356,15 @@ instructions into the query.
|
|
334
356
|
If enabled, SSL will be used when communicating with the Elasticsearch
|
335
357
|
server (i.e. HTTPS will be used instead of plain HTTP).
|
336
358
|
|
359
|
+
[id="plugins-{type}s-{plugin}-socket_timeout_seconds"]
|
360
|
+
===== `socket_timeout_seconds`
|
361
|
+
|
362
|
+
* Value type is <<number,number>>
|
363
|
+
* Default value is `60`
|
364
|
+
|
365
|
+
The maximum amount of time, in seconds, to wait on an incomplete response from Elasticsearch while no additional data has been appended.
|
366
|
+
Socket timeouts usually occur while waiting for the first byte of a response, such as when executing a particularly complex query.
|
367
|
+
|
337
368
|
[id="plugins-{type}s-{plugin}-user"]
|
338
369
|
===== `user`
|
339
370
|
|
@@ -135,6 +135,15 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
|
|
135
135
|
# Basic Auth - password
|
136
136
|
config :password, :validate => :password
|
137
137
|
|
138
|
+
# Connection Timeout, in Seconds
|
139
|
+
config :connect_timeout_seconds, :validate => :positive_whole_number, :default => 10
|
140
|
+
|
141
|
+
# Request Timeout, in Seconds
|
142
|
+
config :request_timeout_seconds, :validate => :positive_whole_number, :default => 60
|
143
|
+
|
144
|
+
# Socket Timeout, in Seconds
|
145
|
+
config :socket_timeout_seconds, :validate => :positive_whole_number, :default => 60
|
146
|
+
|
138
147
|
# Cloud ID, from the Elastic Cloud web console. If set `hosts` should not be used.
|
139
148
|
#
|
140
149
|
# For more info, check out the https://www.elastic.co/guide/en/logstash/current/connecting-to-cloud.html#_cloud_id[Logstash-to-Cloud documentation]
|
@@ -189,6 +198,9 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
|
|
189
198
|
transport_options = {:headers => {}}
|
190
199
|
transport_options[:headers].merge!(setup_basic_auth(user, password))
|
191
200
|
transport_options[:headers].merge!(setup_api_key(api_key))
|
201
|
+
transport_options[:request_timeout] = @request_timeout_seconds unless @request_timeout_seconds.nil?
|
202
|
+
transport_options[:connect_timeout] = @connect_timeout_seconds unless @connect_timeout_seconds.nil?
|
203
|
+
transport_options[:socket_timeout] = @socket_timeout_seconds unless @socket_timeout_seconds.nil?
|
192
204
|
|
193
205
|
hosts = setup_hosts
|
194
206
|
ssl_options = setup_ssl
|
@@ -205,22 +217,7 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
|
|
205
217
|
)
|
206
218
|
end
|
207
219
|
|
208
|
-
##
|
209
|
-
# @override to handle proxy => '' as if none was set
|
210
|
-
# @param value [Array<Object>]
|
211
|
-
# @param validator [nil,Array,Symbol]
|
212
|
-
# @return [Array(true,Object)]: if validation is a success, a tuple containing `true` and the coerced value
|
213
|
-
# @return [Array(false,String)]: if validation is a failure, a tuple containing `false` and the failure reason.
|
214
|
-
def self.validate_value(value, validator)
|
215
|
-
return super unless validator == :uri_or_empty
|
216
|
-
|
217
|
-
value = deep_replace(value)
|
218
|
-
value = hash_or_array(value)
|
219
220
|
|
220
|
-
return true, value.first if value.size == 1 && value.first.empty?
|
221
|
-
|
222
|
-
return super(value, :uri)
|
223
|
-
end
|
224
221
|
|
225
222
|
def run(output_queue)
|
226
223
|
if @schedule
|
@@ -439,4 +436,42 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
|
|
439
436
|
[ cloud_auth.username, cloud_auth.password ]
|
440
437
|
end
|
441
438
|
|
439
|
+
module URIOrEmptyValidator
|
440
|
+
##
|
441
|
+
# @override to provide :uri_or_empty validator
|
442
|
+
# @param value [Array<Object>]
|
443
|
+
# @param validator [nil,Array,Symbol]
|
444
|
+
# @return [Array(true,Object)]: if validation is a success, a tuple containing `true` and the coerced value
|
445
|
+
# @return [Array(false,String)]: if validation is a failure, a tuple containing `false` and the failure reason.
|
446
|
+
def validate_value(value, validator)
|
447
|
+
return super unless validator == :uri_or_empty
|
448
|
+
|
449
|
+
value = deep_replace(value)
|
450
|
+
value = hash_or_array(value)
|
451
|
+
|
452
|
+
return true, value.first if value.size == 1 && value.first.empty?
|
453
|
+
|
454
|
+
return super(value, :uri)
|
455
|
+
end
|
456
|
+
end
|
457
|
+
extend(URIOrEmptyValidator)
|
458
|
+
|
459
|
+
module PositiveWholeNumberValidator
|
460
|
+
##
|
461
|
+
# @override to provide :positive_whole_number validator
|
462
|
+
# @param value [Array<Object>]
|
463
|
+
# @param validator [nil,Array,Symbol]
|
464
|
+
# @return [Array(true,Object)]: if validation is a success, a tuple containing `true` and the coerced value
|
465
|
+
# @return [Array(false,String)]: if validation is a failure, a tuple containing `false` and the failure reason.
|
466
|
+
def validate_value(value, validator)
|
467
|
+
return super unless validator == :positive_whole_number
|
468
|
+
|
469
|
+
is_number, coerced_number = super(value, :number)
|
470
|
+
|
471
|
+
return [true, coerced_number.to_i] if is_number && coerced_number.denominator == 1 && coerced_number > 0
|
472
|
+
|
473
|
+
return [false, "Expected positive whole number, got `#{value.inspect}`"]
|
474
|
+
end
|
475
|
+
end
|
476
|
+
extend(PositiveWholeNumberValidator)
|
442
477
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-input-elasticsearch'
|
4
|
-
s.version = '4.
|
4
|
+
s.version = '4.8.0'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "Reads query results from an Elasticsearch cluster"
|
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"
|
@@ -640,6 +640,54 @@ describe LogStash::Inputs::TestableElasticsearch do
|
|
640
640
|
end
|
641
641
|
end
|
642
642
|
end
|
643
|
+
|
644
|
+
shared_examples'configurable timeout' do |config_name, manticore_transport_option|
|
645
|
+
let(:config_value) { fail NotImplementedError }
|
646
|
+
let(:config) { super().merge(config_name => config_value) }
|
647
|
+
{
|
648
|
+
:string => 'banana',
|
649
|
+
:negative => -123,
|
650
|
+
:zero => 0,
|
651
|
+
}.each do |value_desc, value|
|
652
|
+
let(:config_value) { value }
|
653
|
+
context "with an invalid #{value_desc} value" do
|
654
|
+
it 'prevents instantiation with a helpful message' do
|
655
|
+
expect(described_class.logger).to receive(:error).with(/Expected positive whole number/)
|
656
|
+
expect { described_class.new(config) }.to raise_error(LogStash::ConfigurationError)
|
657
|
+
end
|
658
|
+
end
|
659
|
+
end
|
660
|
+
|
661
|
+
context 'with a valid value' do
|
662
|
+
let(:config_value) { 17 }
|
663
|
+
|
664
|
+
it "instantiates the elasticsearch client with the timeout value set via #{manticore_transport_option} in the transport options" do
|
665
|
+
expect(Elasticsearch::Client).to receive(:new) do |new_elasticsearch_client_params|
|
666
|
+
# We rely on Manticore-specific transport options, fail early if we are using a different
|
667
|
+
# transport or are allowing the client to determine its own transport class.
|
668
|
+
expect(new_elasticsearch_client_params).to include(:transport_class)
|
669
|
+
expect(new_elasticsearch_client_params[:transport_class].name).to match(/\bManticore\b/)
|
670
|
+
|
671
|
+
expect(new_elasticsearch_client_params).to include(:transport_options)
|
672
|
+
transport_options = new_elasticsearch_client_params[:transport_options]
|
673
|
+
expect(transport_options).to include(manticore_transport_option)
|
674
|
+
expect(transport_options[manticore_transport_option]).to eq(config_value.to_i)
|
675
|
+
end
|
676
|
+
|
677
|
+
plugin.register
|
678
|
+
end
|
679
|
+
end
|
680
|
+
end
|
681
|
+
|
682
|
+
context 'connect_timeout_seconds' do
|
683
|
+
include_examples('configurable timeout', 'connect_timeout_seconds', :connect_timeout)
|
684
|
+
end
|
685
|
+
context 'request_timeout_seconds' do
|
686
|
+
include_examples('configurable timeout', 'request_timeout_seconds', :request_timeout)
|
687
|
+
end
|
688
|
+
context 'socket_timeout_seconds' do
|
689
|
+
include_examples('configurable timeout', 'socket_timeout_seconds', :socket_timeout)
|
690
|
+
end
|
643
691
|
end
|
644
692
|
|
645
693
|
context "when scheduling" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-elasticsearch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-08-
|
11
|
+
date: 2020-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|