logstash-input-elasticsearch 4.5.0 → 4.6.0

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: a5e1d79e9b4b6fdd1deaf7575f6fe3c5c91c578a327478d3dec2172ca3d12cc0
4
- data.tar.gz: 046771cceceb57a4a9f0ad395f55fa273dc80b224fa50eab410c3a3b0212ff2b
3
+ metadata.gz: 0255dad9a7c1cdd4b9feae3431528d84c6dca6665d76e01d49a8671cfd50b7ec
4
+ data.tar.gz: 4f62de728c1b6090338b96d0dc9ed751428bdb35290cc7fc7d677f005733aba9
5
5
  SHA512:
6
- metadata.gz: 24e767e7f20fe2320ad6e103762e0a5158d23d3c63ed781675d1c9fd648bea8fcbc654722bd2c792cedccdc5f534617ac78d552938e60a8b7c957e5b078e1d70
7
- data.tar.gz: 9133d597e944199974171430a9c6bbe1acc7c3709d5d6371176e26152d53b0256dc62cac045e614f8123e10b904aa5af9c31a1d6c58be47b83823c0762d95fda
6
+ metadata.gz: b3e71209504174bcab3cdd2f937d669dd830c8d9e140c3564f50b43abddd89a7b4dc31ad2bf77439a658429f3026e7f10370eb2870a461a3f86d74774c9588bc
7
+ data.tar.gz: aac7f02f589d34f167e6a71e0b0825408df1f24908c9c35289a8aec690c7b22c2cbfb94a6e101ab30e9749cc42c7aefda503064698e45b505127d5f3b77f7e2f
@@ -1,3 +1,6 @@
1
+ ## 4.6.0
2
+ - Feat: added option to specify proxy for ES [#114](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/114)
3
+
1
4
  ## 4.5.0
2
5
  - Feat: Added support for cloud_id / cloud_auth configuration [#112](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/112)
3
6
 
@@ -95,6 +95,7 @@ This plugin supports the following configuration options plus the <<plugins-{typ
95
95
  | <<plugins-{type}s-{plugin}-hosts>> |<<array,array>>|No
96
96
  | <<plugins-{type}s-{plugin}-index>> |<<string,string>>|No
97
97
  | <<plugins-{type}s-{plugin}-password>> |<<password,password>>|No
98
+ | <<plugins-{type}s-{plugin}-proxy>> |<<uri,uri>>|No
98
99
  | <<plugins-{type}s-{plugin}-query>> |<<string,string>>|No
99
100
  | <<plugins-{type}s-{plugin}-schedule>> |<<string,string>>|No
100
101
  | <<plugins-{type}s-{plugin}-scroll>> |<<string,string>>|No
@@ -231,6 +232,16 @@ The password to use together with the username in the `user` option
231
232
  when authenticating to the Elasticsearch server. If set to an empty
232
233
  string authentication will be disabled.
233
234
 
235
+ [id="plugins-{type}s-{plugin}-proxy"]
236
+ ===== `proxy`
237
+
238
+ * Value type is <<uri,uri>>
239
+ * There is no default value for this setting.
240
+
241
+ Set the address of a forward HTTP proxy.
242
+ An empty string is treated as if proxy was not set, this is useful when using
243
+ environment variables e.g. `proxy => '${LS_PROXY:}'`.
244
+
234
245
  [id="plugins-{type}s-{plugin}-query"]
235
246
  ===== `query`
236
247
 
@@ -145,6 +145,9 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
145
145
  # For more info, check out the https://www.elastic.co/guide/en/logstash/current/connecting-to-cloud.html#_cloud_auth[Logstash-to-Cloud documentation]
146
146
  config :cloud_auth, :validate => :password
147
147
 
148
+ # Set the address of a forward HTTP proxy.
149
+ config :proxy, :validate => :uri_or_empty
150
+
148
151
  # SSL
149
152
  config :ssl, :validate => :boolean, :default => false
150
153
 
@@ -197,11 +200,31 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
197
200
  ssl_options = { :ssl => true, :ca_file => @ca_file } if @ssl && @ca_file
198
201
  ssl_options ||= {}
199
202
 
203
+ @logger.warn "Supplied proxy setting (proxy => '') has no effect" if @proxy.eql?('')
204
+
205
+ transport_options[:proxy] = @proxy.to_s if @proxy && !@proxy.eql?('')
206
+
200
207
  @client = Elasticsearch::Client.new(:hosts => hosts, :transport_options => transport_options,
201
208
  :transport_class => ::Elasticsearch::Transport::Transport::HTTP::Manticore,
202
209
  :ssl => ssl_options)
203
210
  end
204
211
 
212
+ ##
213
+ # @override to handle proxy => '' as if none was set
214
+ # @param value [Array<Object>]
215
+ # @param validator [nil,Array,Symbol]
216
+ # @return [Array(true,Object)]: if validation is a success, a tuple containing `true` and the coerced value
217
+ # @return [Array(false,String)]: if validation is a failure, a tuple containing `false` and the failure reason.
218
+ def self.validate_value(value, validator)
219
+ return super unless validator == :uri_or_empty
220
+
221
+ value = deep_replace(value)
222
+ value = hash_or_array(value)
223
+
224
+ return true, value.first if value.size == 1 && value.first.empty?
225
+
226
+ return super(value, :uri)
227
+ end
205
228
 
206
229
  def run(output_queue)
207
230
  if @schedule
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-input-elasticsearch'
4
- s.version = '4.5.0'
4
+ s.version = '4.6.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"
@@ -576,6 +576,29 @@ describe LogStash::Inputs::Elasticsearch do
576
576
  end
577
577
  end
578
578
  end if LOGSTASH_VERSION > '6.0'
579
+
580
+ describe "proxy" do
581
+ let(:config) { super.merge({ 'proxy' => 'http://localhost:1234' }) }
582
+
583
+ it "should set proxy" do
584
+ plugin.register
585
+ client = plugin.send(:client)
586
+ proxy = client.transport.options[:transport_options][:proxy]
587
+
588
+ expect( proxy ).to eql "http://localhost:1234"
589
+ end
590
+
591
+ context 'invalid' do
592
+ let(:config) { super.merge({ 'proxy' => '${A_MISSING_ENV_VAR:}' }) }
593
+
594
+ it "should not set proxy" do
595
+ plugin.register
596
+ client = plugin.send(:client)
597
+
598
+ expect( client.transport.options[:transport_options] ).to_not include(:proxy)
599
+ end
600
+ end
601
+ end
579
602
  end
580
603
 
581
604
  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.5.0
4
+ version: 4.6.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-01-08 00:00:00.000000000 Z
11
+ date: 2020-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement