logstash-input-elasticsearch 4.3.1 → 4.6.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: a87e0f6689410ccaef80bdc7d83b61d414c1f72ba63ea4524b479723931d390a
4
- data.tar.gz: 6bc8fc519e80e98ecdeeaf69d6043464eee30850bcd09a8fa245751c2500a79f
3
+ metadata.gz: 0255dad9a7c1cdd4b9feae3431528d84c6dca6665d76e01d49a8671cfd50b7ec
4
+ data.tar.gz: 4f62de728c1b6090338b96d0dc9ed751428bdb35290cc7fc7d677f005733aba9
5
5
  SHA512:
6
- metadata.gz: 8c4ce2ec0b83e77be2022ecea02e716bc5d87d3c1d8f82f61e616b6e3725f8636e0e02f1035bb51feef75d1c00594c5cd2a53e52622878c7a438e309f42124e4
7
- data.tar.gz: 1c5cfcf1f0a57c94dc03cb4ed83f968f8d66b372acdf96792db6da4dd8a11f12ece1c00fe3c9cdad3d4aa8c6035ed2be49be47152d4e166b3c7ab31a1ce7793e
6
+ metadata.gz: b3e71209504174bcab3cdd2f937d669dd830c8d9e140c3564f50b43abddd89a7b4dc31ad2bf77439a658429f3026e7f10370eb2870a461a3f86d74774c9588bc
7
+ data.tar.gz: aac7f02f589d34f167e6a71e0b0825408df1f24908c9c35289a8aec690c7b22c2cbfb94a6e101ab30e9749cc42c7aefda503064698e45b505127d5f3b77f7e2f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
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
+
4
+ ## 4.5.0
5
+ - Feat: Added support for cloud_id / cloud_auth configuration [#112](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/112)
6
+
7
+ ## 4.4.0
8
+ - Changed Elasticsearch Client transport to use Manticore [#111](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/111)
9
+
10
+ ## 4.3.3
11
+ - Loosen restrictions on Elasticsearch gem [#110](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/110)
12
+
13
+ ## 4.3.2
14
+ - Fixed broken link to Elasticsearch Reference [#106](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/106)
15
+
1
16
  ## 4.3.1
2
17
  - Fixed deeplink to Elasticsearch Reference [#103](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/103)
3
18
 
data/docs/index.asciidoc CHANGED
@@ -87,12 +87,15 @@ This plugin supports the following configuration options plus the <<plugins-{typ
87
87
  |=======================================================================
88
88
  |Setting |Input type|Required
89
89
  | <<plugins-{type}s-{plugin}-ca_file>> |a valid filesystem path|No
90
+ | <<plugins-{type}s-{plugin}-cloud_auth>> |<<password,password>>|No
91
+ | <<plugins-{type}s-{plugin}-cloud_id>> |<<string,string>>|No
90
92
  | <<plugins-{type}s-{plugin}-docinfo>> |<<boolean,boolean>>|No
91
93
  | <<plugins-{type}s-{plugin}-docinfo_fields>> |<<array,array>>|No
92
94
  | <<plugins-{type}s-{plugin}-docinfo_target>> |<<string,string>>|No
93
95
  | <<plugins-{type}s-{plugin}-hosts>> |<<array,array>>|No
94
96
  | <<plugins-{type}s-{plugin}-index>> |<<string,string>>|No
95
97
  | <<plugins-{type}s-{plugin}-password>> |<<password,password>>|No
98
+ | <<plugins-{type}s-{plugin}-proxy>> |<<uri,uri>>|No
96
99
  | <<plugins-{type}s-{plugin}-query>> |<<string,string>>|No
97
100
  | <<plugins-{type}s-{plugin}-schedule>> |<<string,string>>|No
98
101
  | <<plugins-{type}s-{plugin}-scroll>> |<<string,string>>|No
@@ -113,8 +116,27 @@ input plugins.
113
116
  * Value type is <<path,path>>
114
117
  * There is no default value for this setting.
115
118
 
116
- SSL Certificate Authority file in PEM encoded format, must also
117
- include any chain certificates as necessary.
119
+ SSL Certificate Authority file in PEM encoded format, must also include any chain certificates as necessary.
120
+
121
+ [id="plugins-{type}s-{plugin}-cloud_auth"]
122
+ ===== `cloud_auth`
123
+
124
+ * Value type is <<password,password>>
125
+ * There is no default value for this setting.
126
+
127
+ Cloud authentication string ("<username>:<password>" format) is an alternative for the `user`/`password` pair.
128
+
129
+ For more info, check out the https://www.elastic.co/guide/en/logstash/current/connecting-to-cloud.html#_cloud_auth[Logstash-to-Cloud documentation]
130
+
131
+ [id="plugins-{type}s-{plugin}-cloud_id"]
132
+ ===== `cloud_id`
133
+
134
+ * Value type is <<string,string>>
135
+ * There is no default value for this setting.
136
+
137
+ Cloud ID, from the Elastic Cloud web console. If set `hosts` should not be used.
138
+
139
+ For more info, check out the https://www.elastic.co/guide/en/logstash/current/connecting-to-cloud.html#_cloud_id[Logstash-to-Cloud documentation]
118
140
 
119
141
  [id="plugins-{type}s-{plugin}-docinfo"]
120
142
  ===== `docinfo`
@@ -210,6 +232,16 @@ The password to use together with the username in the `user` option
210
232
  when authenticating to the Elasticsearch server. If set to an empty
211
233
  string authentication will be disabled.
212
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
+
213
245
  [id="plugins-{type}s-{plugin}-query"]
214
246
  ===== `query`
215
247
 
@@ -259,7 +291,7 @@ This allows you to set the maximum number of hits returned per scroll.
259
291
 
260
292
  In some cases, it is possible to improve overall throughput by consuming multiple
261
293
  distinct slices of a query simultaneously using the
262
- https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html#sliced-scroll[Sliced Scroll API],
294
+ https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html#sliced-scroll[Sliced Scroll API],
263
295
  especially if the pipeline is spending significant time waiting on Elasticsearch
264
296
  to provide results.
265
297
 
@@ -2,8 +2,10 @@
2
2
  require "logstash/inputs/base"
3
3
  require "logstash/namespace"
4
4
  require "logstash/json"
5
+ require "logstash/util/safe_uri"
5
6
  require "base64"
6
7
 
8
+
7
9
  # .Compatibility Note
8
10
  # [NOTE]
9
11
  # ================================================================================
@@ -68,6 +70,11 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
68
70
  # Port defaults to 9200
69
71
  config :hosts, :validate => :array
70
72
 
73
+ # Cloud ID, from the Elastic Cloud web console. If set `hosts` should not be used.
74
+ #
75
+ # For more info, check out the https://www.elastic.co/guide/en/logstash/current/connecting-to-cloud.html#_cloud_id[Logstash-to-Cloud documentation]
76
+ config :cloud_id, :validate => :string
77
+
71
78
  # The index or alias to search.
72
79
  config :index, :validate => :string, :default => "logstash-*"
73
80
 
@@ -133,6 +140,14 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
133
140
  # Basic Auth - password
134
141
  config :password, :validate => :password
135
142
 
143
+ # Cloud authentication string ("<username>:<password>" format) is an alternative for the `user`/`password` configuration.
144
+ #
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
+ config :cloud_auth, :validate => :password
147
+
148
+ # Set the address of a forward HTTP proxy.
149
+ config :proxy, :validate => :uri_or_empty
150
+
136
151
  # SSL
137
152
  config :ssl, :validate => :boolean, :default => false
138
153
 
@@ -149,6 +164,7 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
149
164
  def register
150
165
  require "elasticsearch"
151
166
  require "rufus/scheduler"
167
+ require "elasticsearch/transport/transport/http/manticore"
152
168
 
153
169
  @options = {
154
170
  :index => @index,
@@ -163,12 +179,17 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
163
179
 
164
180
  transport_options = {}
165
181
 
182
+ fill_user_password_from_cloud_auth
183
+
166
184
  if @user && @password
167
185
  token = Base64.strict_encode64("#{@user}:#{@password.value}")
168
186
  transport_options[:headers] = { :Authorization => "Basic #{token}" }
169
187
  end
170
188
 
171
- hosts = if @ssl then
189
+ fill_hosts_from_cloud_id
190
+ @hosts = Array(@hosts).map { |host| host.to_s } # potential SafeURI#to_s
191
+
192
+ hosts = if @ssl
172
193
  @hosts.map do |h|
173
194
  host, port = h.split(":")
174
195
  { :host => host, :scheme => 'https', :port => port }
@@ -176,14 +197,34 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
176
197
  else
177
198
  @hosts
178
199
  end
200
+ ssl_options = { :ssl => true, :ca_file => @ca_file } if @ssl && @ca_file
201
+ ssl_options ||= {}
179
202
 
180
- if @ssl && @ca_file
181
- transport_options[:ssl] = { :ca_file => @ca_file }
182
- end
203
+ @logger.warn "Supplied proxy setting (proxy => '') has no effect" if @proxy.eql?('')
183
204
 
184
- @client = Elasticsearch::Client.new(:hosts => hosts, :transport_options => transport_options)
205
+ transport_options[:proxy] = @proxy.to_s if @proxy && !@proxy.eql?('')
206
+
207
+ @client = Elasticsearch::Client.new(:hosts => hosts, :transport_options => transport_options,
208
+ :transport_class => ::Elasticsearch::Transport::Transport::HTTP::Manticore,
209
+ :ssl => ssl_options)
185
210
  end
186
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
187
228
 
188
229
  def run(output_queue)
189
230
  if @schedule
@@ -273,10 +314,70 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
273
314
  end
274
315
 
275
316
  def scroll_request scroll_id
276
- @client.scroll(:body => { :scroll_id => scroll_id }, :scroll => @scroll)
317
+ client.scroll(:body => { :scroll_id => scroll_id }, :scroll => @scroll)
277
318
  end
278
319
 
279
320
  def search_request(options)
280
- @client.search(options)
321
+ client.search(options)
322
+ end
323
+
324
+ attr_reader :client
325
+
326
+ def hosts_default?(hosts)
327
+ hosts.nil? || ( hosts.is_a?(Array) && hosts.empty? )
328
+ end
329
+
330
+ def fill_hosts_from_cloud_id
331
+ return unless @cloud_id
332
+
333
+ if @hosts && !hosts_default?(@hosts)
334
+ raise LogStash::ConfigurationError, 'Both cloud_id and hosts specified, please only use one of those.'
335
+ end
336
+ @hosts = parse_host_uri_from_cloud_id(@cloud_id)
337
+ end
338
+
339
+ def fill_user_password_from_cloud_auth
340
+ return unless @cloud_auth
341
+
342
+ if @user || @password
343
+ raise LogStash::ConfigurationError, 'Both cloud_auth and user/password specified, please only use one.'
344
+ end
345
+ @user, @password = parse_user_password_from_cloud_auth(@cloud_auth)
346
+ params['user'], params['password'] = @user, @password
347
+ end
348
+
349
+ def parse_host_uri_from_cloud_id(cloud_id)
350
+ begin # might not be available on older LS
351
+ require 'logstash/util/cloud_setting_id'
352
+ rescue LoadError
353
+ raise LogStash::ConfigurationError, 'The cloud_id setting is not supported by your version of Logstash, ' +
354
+ 'please upgrade your installation (or set hosts instead).'
355
+ end
356
+
357
+ begin
358
+ cloud_id = LogStash::Util::CloudSettingId.new(cloud_id) # already does append ':{port}' to host
359
+ rescue ArgumentError => e
360
+ raise LogStash::ConfigurationError, e.message.to_s.sub(/Cloud Id/i, 'cloud_id')
361
+ end
362
+ cloud_uri = "#{cloud_id.elasticsearch_scheme}://#{cloud_id.elasticsearch_host}"
363
+ LogStash::Util::SafeURI.new(cloud_uri)
281
364
  end
365
+
366
+ def parse_user_password_from_cloud_auth(cloud_auth)
367
+ begin # might not be available on older LS
368
+ require 'logstash/util/cloud_setting_auth'
369
+ rescue LoadError
370
+ raise LogStash::ConfigurationError, 'The cloud_auth setting is not supported by your version of Logstash, ' +
371
+ 'please upgrade your installation (or set user/password instead).'
372
+ end
373
+
374
+ cloud_auth = cloud_auth.value if cloud_auth.is_a?(LogStash::Util::Password)
375
+ begin
376
+ cloud_auth = LogStash::Util::CloudSettingAuth.new(cloud_auth)
377
+ rescue ArgumentError => e
378
+ raise LogStash::ConfigurationError, e.message.to_s.sub(/Cloud Auth/i, 'cloud_auth')
379
+ end
380
+ [ cloud_auth.username, cloud_auth.password ]
381
+ end
382
+
282
383
  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.3.1'
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"
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
22
22
  # Gem dependencies
23
23
  s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
24
24
 
25
- s.add_runtime_dependency 'elasticsearch', ['>= 5.0.3', '< 6.0.0']
25
+ s.add_runtime_dependency 'elasticsearch', '>= 5.0.3'
26
26
 
27
27
  s.add_runtime_dependency 'logstash-codec-json'
28
28
  s.add_runtime_dependency 'logstash-codec-plain'
@@ -30,6 +30,8 @@ Gem::Specification.new do |s|
30
30
  s.add_runtime_dependency 'tzinfo'
31
31
  s.add_runtime_dependency 'tzinfo-data'
32
32
  s.add_runtime_dependency 'rufus-scheduler'
33
+ s.add_runtime_dependency 'manticore', "~> 0.6"
34
+ s.add_runtime_dependency 'faraday', "~> 0.15.4"
33
35
 
34
36
  s.add_development_dependency 'logstash-devutils'
35
37
  s.add_development_dependency 'timecop'
data/spec/es_helper.rb ADDED
@@ -0,0 +1,59 @@
1
+ module ESHelper
2
+ def self.get_host_port
3
+ return "elasticsearch:9200" if ENV["INTEGRATION"] == "true" || ENV["SECURE_INTEGRATION"] == "true"
4
+ raise "This setting is only used for integration tests"
5
+ end
6
+
7
+ def self.get_client(options = {})
8
+ ssl_options = {}
9
+ hosts = [get_host_port]
10
+
11
+ if options[:ca_file]
12
+ ssl_options = { :ssl => true, :ca_file => options[:ca_file] }
13
+ hosts.map! do |h|
14
+ host, port = h.split(":")
15
+ { :host => host, :scheme => 'https', :port => port }
16
+ end
17
+ end
18
+
19
+ transport_options = {}
20
+
21
+ if options[:user] && options[:password]
22
+ token = Base64.strict_encode64("#{options[:user]}:#{options[:password]}")
23
+ transport_options[:headers] = { :Authorization => "Basic #{token}" }
24
+ end
25
+
26
+ @client = Elasticsearch::Client.new(:hosts => hosts, :transport_options => transport_options, :ssl => ssl_options,
27
+ :transport_class => ::Elasticsearch::Transport::Transport::HTTP::Manticore)
28
+ end
29
+
30
+ def self.doc_type
31
+ if ESHelper.es_version_satisfies?(">=8")
32
+ nil
33
+ elsif ESHelper.es_version_satisfies?(">=7")
34
+ "_doc"
35
+ else
36
+ "doc"
37
+ end
38
+ end
39
+
40
+ def self.index_doc(es, params)
41
+ type = doc_type
42
+ params[:type] = doc_type unless type.nil?
43
+ es.index(params)
44
+ end
45
+
46
+ def self.es_version
47
+ ENV['ES_VERSION'] || ENV['ELASTIC_STACK_VERSION']
48
+ end
49
+
50
+ def self.es_version_satisfies?(*requirement)
51
+ es_version = RSpec.configuration.filter[:es_version] || ENV['ES_VERSION'] || ENV['ELASTIC_STACK_VERSION']
52
+ if es_version.nil?
53
+ puts "Info: ES_VERSION, ELASTIC_STACK_VERSION or 'es_version' tag wasn't set. Returning false to all `es_version_satisfies?` call."
54
+ return false
55
+ end
56
+ es_release_version = Gem::Version.new(es_version).release
57
+ Gem::Requirement.new(requirement).satisfied_by?(es_release_version)
58
+ end
59
+ end
@@ -0,0 +1,32 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIFeTCCA2GgAwIBAgIUU+VHJ91JsLLA1GJYC+UchNfw3hEwDQYJKoZIhvcNAQEL
3
+ BQAwTDELMAkGA1UEBhMCUFQxCzAJBgNVBAgMAk5BMQ8wDQYDVQQHDAZMaXNib24x
4
+ DjA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4x5ZL/etfwj7Dyj9EqsERm6R0ebc1ECtstbfekGLugmQ
45
+ qNhRcTu3EXpZz8oq5NJUwVBef1TJ6zwBAoIBAQC7Oq5AdmLzYOX0AYUuT3Cjgl0u
46
+ 3Tq1c1uqlVaxQGjA3oqua4SR0+kvmRZbZGLpLAVnnwOjUEfUFBBYgP/5Mo/OiCkQ
47
+ C8eWkSQKXy6OFy5wh4mbL5oJttKjM4ZoB0gpF31+tGOmrfJwacqEPnyZLKzkgBdG
48
+ djVVKP+HH4XUdB2VXst8tvcif+VTrUsD1nuhGMOgbiHZkdx3eug05wfhnYvWljA+
49
+ r/4xcq7TmKSoJqkb0OcOkhqjeZWleA6xRtEvHPGRzbEM67FVsVTxr/N9BX5tS9zu
50
+ YLCNI3tTNsDV0Ac+4rl46rghQ/n2TNSEpwvA/pjytsdPXLOpoapWirrsEiXf
51
+ -----END RSA PRIVATE KEY-----
@@ -375,15 +375,13 @@ describe LogStash::Inputs::Elasticsearch do
375
375
  end
376
376
 
377
377
  it 'merges the values if the `docinfo_target` already exist in the `_source` document' do
378
- metadata_field = 'metadata_with_hash'
379
-
380
378
  config_metadata_with_hash = %Q[
381
379
  input {
382
380
  elasticsearch {
383
381
  hosts => ["localhost"]
384
382
  query => '{ "query": { "match": { "city_name": "Okinawa" } }, "fields": ["message"] }'
385
383
  docinfo => true
386
- docinfo_target => '#{metadata_field}'
384
+ docinfo_target => 'metadata_with_hash'
387
385
  }
388
386
  }
389
387
  ]
@@ -392,33 +390,23 @@ describe LogStash::Inputs::Elasticsearch do
392
390
  queue.pop
393
391
  end
394
392
 
395
- expect(event.get("[#{metadata_field}][_index]")).to eq('logstash-2014.10.12')
396
- expect(event.get("[#{metadata_field}][_type]")).to eq('logs')
397
- expect(event.get("[#{metadata_field}][_id]")).to eq('C5b2xLQwTZa76jBmHIbwHQ')
398
- expect(event.get("[#{metadata_field}][awesome]")).to eq("logstash")
393
+ expect(event.get("[metadata_with_hash][_index]")).to eq('logstash-2014.10.12')
394
+ expect(event.get("[metadata_with_hash][_type]")).to eq('logs')
395
+ expect(event.get("[metadata_with_hash][_id]")).to eq('C5b2xLQwTZa76jBmHIbwHQ')
396
+ expect(event.get("[metadata_with_hash][awesome]")).to eq("logstash")
399
397
  end
400
398
 
401
- it 'thows an exception if the `docinfo_target` exist but is not of type hash' do
402
- metadata_field = 'metadata_with_string'
403
-
404
- config_metadata_with_string = %Q[
405
- input {
406
- elasticsearch {
407
- hosts => ["localhost"]
408
- query => '{ "query": { "match": { "city_name": "Okinawa" } }, "fields": ["message"] }'
409
- docinfo => true
410
- docinfo_target => '#{metadata_field}'
411
- }
412
- }
413
- ]
414
-
415
- pipeline = new_pipeline_from_string(config_metadata_with_string)
416
- queue = Queue.new
417
- pipeline.instance_eval do
418
- @output_func = lambda { |event| queue << event }
399
+ context 'if the `docinfo_target` exist but is not of type hash' do
400
+ let (:config) { {
401
+ "hosts" => ["localhost"],
402
+ "query" => '{ "query": { "match": { "city_name": "Okinawa" } }, "fields": ["message"] }',
403
+ "docinfo" => true,
404
+ "docinfo_target" => 'metadata_with_string'
405
+ } }
406
+ it 'thows an exception if the `docinfo_target` exist but is not of type hash' do
407
+ plugin.register
408
+ expect { plugin.run([]) }.to raise_error(Exception, /incompatible event/)
419
409
  end
420
-
421
- expect { pipeline.run }.to raise_error(Exception, /incompatible event/)
422
410
  end
423
411
 
424
412
  it "should move the document info to the @metadata field" do
@@ -516,6 +504,103 @@ describe LogStash::Inputs::Elasticsearch do
516
504
  end
517
505
  end
518
506
 
507
+ describe "client" do
508
+ let(:config) do
509
+ {
510
+
511
+ }
512
+ end
513
+ let(:plugin) { described_class.new(config) }
514
+ let(:event) { LogStash::Event.new({}) }
515
+
516
+ describe "cloud.id" do
517
+ let(:valid_cloud_id) do
518
+ 'sample:dXMtY2VudHJhbDEuZ2NwLmNsb3VkLmVzLmlvJGFjMzFlYmI5MDI0MTc3MzE1NzA0M2MzNGZkMjZmZDQ2OjkyNDMkYTRjMDYyMzBlNDhjOGZjZTdiZTg4YTA3NGEzYmIzZTA6OTI0NA=='
519
+ end
520
+
521
+ let(:config) { super.merge({ 'cloud_id' => valid_cloud_id }) }
522
+
523
+ it "should set host(s)" do
524
+ plugin.register
525
+ client = plugin.send(:client)
526
+ expect( client.transport.hosts ).to eql [{
527
+ :scheme => "https",
528
+ :host => "ac31ebb90241773157043c34fd26fd46.us-central1.gcp.cloud.es.io",
529
+ :port => 9243,
530
+ :path => "",
531
+ :protocol => "https"
532
+ }]
533
+ end
534
+
535
+ context 'invalid' do
536
+ let(:config) { super.merge({ 'cloud_id' => 'invalid:dXMtY2VudHJhbDEuZ2NwLmNsb3VkLmVzLmlv' }) }
537
+
538
+ it "should fail" do
539
+ expect { plugin.register }.to raise_error LogStash::ConfigurationError, /cloud_id.*? is invalid/
540
+ end
541
+ end
542
+
543
+ context 'hosts also set' do
544
+ let(:config) { super.merge({ 'cloud_id' => valid_cloud_id, 'hosts' => [ 'localhost:9200' ] }) }
545
+
546
+ it "should fail" do
547
+ expect { plugin.register }.to raise_error LogStash::ConfigurationError, /cloud_id and hosts/
548
+ end
549
+ end
550
+ end if LOGSTASH_VERSION > '6.0'
551
+
552
+ describe "cloud.auth" do
553
+ let(:config) { super.merge({ 'cloud_auth' => LogStash::Util::Password.new('elastic:my-passwd-00') }) }
554
+
555
+ it "should set authorization" do
556
+ plugin.register
557
+ client = plugin.send(:client)
558
+ auth_header = client.transport.options[:transport_options][:headers][:Authorization]
559
+
560
+ expect( auth_header ).to eql "Basic #{Base64.encode64('elastic:my-passwd-00').rstrip}"
561
+ end
562
+
563
+ context 'invalid' do
564
+ let(:config) { super.merge({ 'cloud_auth' => 'invalid-format' }) }
565
+
566
+ it "should fail" do
567
+ expect { plugin.register }.to raise_error LogStash::ConfigurationError, /cloud_auth.*? format/
568
+ end
569
+ end
570
+
571
+ context 'user also set' do
572
+ let(:config) { super.merge({ 'cloud_auth' => 'elastic:my-passwd-00', 'user' => 'another' }) }
573
+
574
+ it "should fail" do
575
+ expect { plugin.register }.to raise_error LogStash::ConfigurationError, /cloud_auth and user/
576
+ end
577
+ end
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
602
+ end
603
+
519
604
  context "when scheduling" do
520
605
  let(:config) do
521
606
  {
@@ -525,39 +610,11 @@ describe LogStash::Inputs::Elasticsearch do
525
610
  }
526
611
  end
527
612
 
528
- response = {
529
- "_scroll_id" => "cXVlcnlUaGVuRmV0Y2g",
530
- "took" => 27,
531
- "timed_out" => false,
532
- "_shards" => {
533
- "total" => 169,
534
- "successful" => 169,
535
- "failed" => 0
536
- },
537
- "hits" => {
538
- "total" => 1,
539
- "max_score" => 1.0,
540
- "hits" => [ {
541
- "_index" => "logstash-2014.10.12",
542
- "_type" => "logs",
543
- "_id" => "C5b2xLQwTZa76jBmHIbwHQ",
544
- "_score" => 1.0,
545
- "_source" => { "message" => ["ohayo"] }
546
- } ]
547
- }
548
- }
549
-
550
- scroll_reponse = {
551
- "_scroll_id" => "r453Wc1jh0caLJhSDg",
552
- "hits" => { "hits" => [] }
553
- }
554
-
555
613
  before do
556
614
  plugin.register
557
615
  end
558
616
 
559
617
  it "should properly schedule" do
560
-
561
618
  Timecop.travel(Time.new(2000))
562
619
  Timecop.scale(60)
563
620
  runner = Thread.new do
@@ -576,5 +633,4 @@ describe LogStash::Inputs::Elasticsearch do
576
633
  end
577
634
 
578
635
  end
579
-
580
636
  end
@@ -0,0 +1,63 @@
1
+ # encoding: utf-8
2
+ require "logstash/devutils/rspec/spec_helper"
3
+ require "logstash/plugin"
4
+ require "logstash/inputs/elasticsearch"
5
+ require_relative "../../../spec/es_helper"
6
+
7
+ describe LogStash::Inputs::Elasticsearch do
8
+
9
+ let(:config) { { 'hosts' => [ESHelper.get_host_port],
10
+ 'index' => 'logs',
11
+ 'query' => '{ "query": { "match": { "message": "Not found"} }}' } }
12
+ let(:plugin) { described_class.new(config) }
13
+ let(:event) { LogStash::Event.new({}) }
14
+ let(:client_options) {{}}
15
+
16
+ before(:each) do
17
+ @es = ESHelper.get_client(client_options)
18
+ # Delete all templates first.
19
+ # Clean ES of data before we start.
20
+ @es.indices.delete_template(:name => "*")
21
+ # This can fail if there are no indexes, ignore failure.
22
+ @es.indices.delete(:index => "*") rescue nil
23
+ 10.times do
24
+ ESHelper.index_doc(@es, :index => 'logs', :body => { :response => 404, :message=> 'Not Found'})
25
+ end
26
+ @es.indices.refresh
27
+ plugin.register
28
+ end
29
+
30
+ after(:each) do
31
+ @es.indices.delete_template(:name => "*")
32
+ @es.indices.delete(:index => "*") rescue nil
33
+ end
34
+
35
+ shared_examples 'an elasticsearch index plugin' do
36
+ it 'should retrieve json event from elasticsearch' do
37
+ queue = []
38
+ plugin.run(queue)
39
+ event = queue.pop
40
+ expect(event).to be_a(LogStash::Event)
41
+ expect(event.get("response")).to eql(404)
42
+ end
43
+ end
44
+
45
+ describe 'against an unsecured elasticsearch', :integration => true do
46
+ it_behaves_like 'an elasticsearch index plugin'
47
+ end
48
+
49
+ describe 'against a secured elasticsearch', :secure_integration => true do
50
+ let(:user) { 'simpleuser' }
51
+ let(:password) { 'abc123' }
52
+ let(:ca_file) { "spec/fixtures/test_certs/test.crt" }
53
+ let(:client_options) {{:ca_file => ca_file, :user => user, :password => password}}
54
+ let(:config) { super.merge({
55
+ 'user' => user,
56
+ 'password' => password,
57
+ 'ssl' => true,
58
+ 'ca_file' => ca_file })
59
+ }
60
+ it_behaves_like 'an elasticsearch index plugin'
61
+ end
62
+ end
63
+
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.3.1
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: 2019-05-01 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
@@ -36,9 +36,6 @@ dependencies:
36
36
  - - ">="
37
37
  - !ruby/object:Gem::Version
38
38
  version: 5.0.3
39
- - - "<"
40
- - !ruby/object:Gem::Version
41
- version: 6.0.0
42
39
  name: elasticsearch
43
40
  prerelease: false
44
41
  type: :runtime
@@ -47,9 +44,6 @@ dependencies:
47
44
  - - ">="
48
45
  - !ruby/object:Gem::Version
49
46
  version: 5.0.3
50
- - - "<"
51
- - !ruby/object:Gem::Version
52
- version: 6.0.0
53
47
  - !ruby/object:Gem::Dependency
54
48
  requirement: !ruby/object:Gem::Requirement
55
49
  requirements:
@@ -134,6 +128,34 @@ dependencies:
134
128
  - - ">="
135
129
  - !ruby/object:Gem::Version
136
130
  version: '0'
131
+ - !ruby/object:Gem::Dependency
132
+ requirement: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - "~>"
135
+ - !ruby/object:Gem::Version
136
+ version: '0.6'
137
+ name: manticore
138
+ prerelease: false
139
+ type: :runtime
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - "~>"
143
+ - !ruby/object:Gem::Version
144
+ version: '0.6'
145
+ - !ruby/object:Gem::Dependency
146
+ requirement: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - "~>"
149
+ - !ruby/object:Gem::Version
150
+ version: 0.15.4
151
+ name: faraday
152
+ prerelease: false
153
+ type: :runtime
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - "~>"
157
+ - !ruby/object:Gem::Version
158
+ version: 0.15.4
137
159
  - !ruby/object:Gem::Dependency
138
160
  requirement: !ruby/object:Gem::Requirement
139
161
  requirements:
@@ -179,7 +201,13 @@ files:
179
201
  - docs/index.asciidoc
180
202
  - lib/logstash/inputs/elasticsearch.rb
181
203
  - logstash-input-elasticsearch.gemspec
204
+ - spec/es_helper.rb
205
+ - spec/fixtures/test_certs/ca/ca.crt
206
+ - spec/fixtures/test_certs/ca/ca.key
207
+ - spec/fixtures/test_certs/test.crt
208
+ - spec/fixtures/test_certs/test.key
182
209
  - spec/inputs/elasticsearch_spec.rb
210
+ - spec/inputs/integration/elasticsearch_spec.rb
183
211
  homepage: http://www.elastic.co/guide/en/logstash/current/index.html
184
212
  licenses:
185
213
  - Apache License (2.0)
@@ -207,4 +235,10 @@ signing_key:
207
235
  specification_version: 4
208
236
  summary: Reads query results from an Elasticsearch cluster
209
237
  test_files:
238
+ - spec/es_helper.rb
239
+ - spec/fixtures/test_certs/ca/ca.crt
240
+ - spec/fixtures/test_certs/ca/ca.key
241
+ - spec/fixtures/test_certs/test.crt
242
+ - spec/fixtures/test_certs/test.key
210
243
  - spec/inputs/elasticsearch_spec.rb
244
+ - spec/inputs/integration/elasticsearch_spec.rb