logstash-input-elasticsearch 4.3.2 → 4.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: b0323fd0462661ab2568f90769666a59f17574aa5bfb9ed6e3c280ba32d6e52e
4
- data.tar.gz: c65aabfa5514d75b7414d32cf2d7411d1690f52721193467b3d97316f28cd30d
3
+ metadata.gz: 72f28226e8297df8d4eda501ef9a99a67c11bab0574711f553797c678cd5e9a8
4
+ data.tar.gz: d141edd1c0664b1f77f4ddc757cda564781aeaa2ada1ebee828ac2f76268c1de
5
5
  SHA512:
6
- metadata.gz: cd91e70ac02af9d834337649dc11ba13b4a39ce9165b19419b7a1922d6907b240dbf735436700709cffc0747708238d943ddcc5a4bb9a8b7b390a82d65242c57
7
- data.tar.gz: 9b9d390c39ef7394c87aa799c38e0039af8955696b1c8fc98f360e8e1331091f33e583d6192f57e0a957df9a6436778b59f1366fdb87ce94fc97fcb104ed7b72
6
+ metadata.gz: 468f91f896d037895c7479e7ae377cee60c4b0c22b05918695f35b6e56bdfa405524fd04d03440133ac40a71fa4ed00251ad27e38792f7c30a8b736ffaa186c9
7
+ data.tar.gz: 5ba240ae691f622ab6bf410b7603ebbb959ee5c50cddc90748dd26a1a349fcc36057e9147a15d0501ea1e4f0bbc2861f3042c0addc070568ec805cdd6668d999
@@ -1,3 +1,6 @@
1
+ ## 4.3.3
2
+ - Loosen restrictions on Elasticsearch gem [#110](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/110)
3
+
1
4
  ## 4.3.2
2
5
  - Fixed broken link to Elasticsearch Reference [#106](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/106)
3
6
 
@@ -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.2'
4
+ s.version = '4.3.3'
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'
@@ -0,0 +1,40 @@
1
+ module ESHelper
2
+ def self.get_host_port
3
+ return "http://elasticsearch:9200" if ENV["INTEGRATION"] == "true"
4
+ raise "This setting is only used for integration tests"
5
+ end
6
+
7
+ def self.get_client
8
+ Elasticsearch::Client.new(:hosts => [get_host_port])
9
+ end
10
+
11
+ def self.doc_type
12
+ if ESHelper.es_version_satisfies?(">=8")
13
+ nil
14
+ elsif ESHelper.es_version_satisfies?(">=7")
15
+ "_doc"
16
+ else
17
+ "doc"
18
+ end
19
+ end
20
+
21
+ def self.index_doc(es, params)
22
+ type = doc_type
23
+ params[:type] = doc_type unless type.nil?
24
+ es.index(params)
25
+ end
26
+
27
+ def self.es_version
28
+ ENV['ES_VERSION'] || ENV['ELASTIC_STACK_VERSION']
29
+ end
30
+
31
+ def self.es_version_satisfies?(*requirement)
32
+ es_version = RSpec.configuration.filter[:es_version] || ENV['ES_VERSION'] || ENV['ELASTIC_STACK_VERSION']
33
+ if es_version.nil?
34
+ puts "Info: ES_VERSION, ELASTIC_STACK_VERSION or 'es_version' tag wasn't set. Returning false to all `es_version_satisfies?` call."
35
+ return false
36
+ end
37
+ es_release_version = Gem::Version.new(es_version).release
38
+ Gem::Requirement.new(requirement).satisfied_by?(es_release_version)
39
+ end
40
+ end
@@ -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
@@ -0,0 +1,43 @@
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, :integration => true 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
+
15
+ before(:each) do
16
+ @es = ESHelper.get_client
17
+ # Delete all templates first.
18
+ # Clean ES of data before we start.
19
+ @es.indices.delete_template(:name => "*")
20
+ # This can fail if there are no indexes, ignore failure.
21
+ @es.indices.delete(:index => "*") rescue nil
22
+ 10.times do
23
+ ESHelper.index_doc(@es, :index => 'logs', :body => { :response => 404, :message=> 'Not Found'})
24
+ end
25
+ @es.indices.refresh
26
+ plugin.register
27
+ end
28
+
29
+ after(:each) do
30
+ @es.indices.delete_template(:name => "*")
31
+ @es.indices.delete(:index => "*") rescue nil
32
+ end
33
+
34
+ describe 'smoke test' do
35
+ it "should retrieve json event from elasticseach" do
36
+ queue = []
37
+ plugin.run(queue)
38
+ event = queue.pop
39
+ expect(event).to be_a(LogStash::Event)
40
+ expect(event.get("response")).to eql(404)
41
+ end
42
+ end
43
+ end
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.2
4
+ version: 4.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-31 00:00:00.000000000 Z
11
+ date: 2019-11-12 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:
@@ -179,7 +173,9 @@ files:
179
173
  - docs/index.asciidoc
180
174
  - lib/logstash/inputs/elasticsearch.rb
181
175
  - logstash-input-elasticsearch.gemspec
176
+ - spec/es_helper.rb
182
177
  - spec/inputs/elasticsearch_spec.rb
178
+ - spec/inputs/integration/elasticsearch_spec.rb
183
179
  homepage: http://www.elastic.co/guide/en/logstash/current/index.html
184
180
  licenses:
185
181
  - Apache License (2.0)
@@ -207,4 +203,6 @@ signing_key:
207
203
  specification_version: 4
208
204
  summary: Reads query results from an Elasticsearch cluster
209
205
  test_files:
206
+ - spec/es_helper.rb
210
207
  - spec/inputs/elasticsearch_spec.rb
208
+ - spec/inputs/integration/elasticsearch_spec.rb