logstash-input-elasticsearch 4.12.0 → 4.12.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: 2c8dcf80b30079fa7b38d9c8cb0a11127bc896af3c5efe9e10b92023a74d0034
4
- data.tar.gz: b6f40095bd604f4770529c621397c86a569494a973aa32dc13d978f68d49ac44
3
+ metadata.gz: 4a4ed685c9f90446a47fc84cb4e52e585f164c5451c9dca3f7359b756077bbd4
4
+ data.tar.gz: 050b54e5c660a4ab436f57ab16ea20d6a64a6b8a8c063eaaca69cc2c77235bd4
5
5
  SHA512:
6
- metadata.gz: 9ff54e3056fedf78f80fa77d11ccb16f267675ff091d0c8f09262368272ec9d063064459acfc5645764f08a066692215d2713e0b0e100c502ad5488873ba549a
7
- data.tar.gz: 7d315f02bdce91ce2f74fa27c85f9962bcdf3548a97a1018d577c480777e370f503301d4482aa28a2a8b68d932f8c2fdde9a6e7f576b6210ded7e43cad692dce
6
+ metadata.gz: 902070db657622bd65bcba8c17470456366134aae23cd38fb70ec89c97686b74da591e6f47d34957f3e5753f0e029ad78b845dd6355d6d559b6c135e0c94d28e
7
+ data.tar.gz: 22391299a87f5ce0a3085b4be7886a7f7251c9e33bd7051996871ea7cc34cbd7fbc53a3d54d841722b319949c4422e0ab7e6ff7d04899db6255543363fc32f66
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
+ ## 4.12.3
2
+ - Fix: update Elasticsearch Ruby client to correctly customize 'user-agent' header[#171](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/171)
3
+
4
+ ## 4.12.2
5
+ - Fix: hosts => "es_host:port" regression [#168](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/168)
6
+
7
+ ## 4.12.1
8
+ - Fixed too_long_frame_exception by passing scroll_id in the body [#159](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/159)
9
+
1
10
  ## 4.12.0
2
- - Feat: Update Elasticsearch client to 7.14.0 [#157](https://github.com/logstash-plugins/logstash-filter-elasticsearch/pull/157)
11
+ - Feat: Update Elasticsearch client to 7.14.0 [#157](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/157)
3
12
 
4
13
  ## 4.11.0
5
14
  - Feat: add user-agent header passed to the Elasticsearch HTTP connection [#158](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/158)
@@ -11,7 +20,7 @@
11
20
  - Fixed SSL handshake hang indefinitely with proxy setup [#156](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/156)
12
21
 
13
22
  ## 4.9.2
14
- - Fix: a regression (in LS 7.14.0) where due the elasticsearch client update (from 5.0.5 to 7.5.0) the `Authorization`
23
+ - Fix: a regression (in LS 7.14.0) where due the elasticsearch client update (from 5.0.5 to 7.5.0) the `Authorization`
15
24
  header isn't passed, this leads to the plugin not being able to leverage `user`/`password` credentials set by the user.
16
25
  [#153](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/153)
17
26
 
@@ -55,7 +64,7 @@
55
64
  - Feat: Added support for cloud_id / cloud_auth configuration [#112](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/112)
56
65
 
57
66
  ## 4.4.0
58
- - Changed Elasticsearch Client transport to use Manticore [#111](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/111)
67
+ - Changed Elasticsearch Client transport to use Manticore [#111](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/111)
59
68
 
60
69
  ## 4.3.3
61
70
  - Loosen restrictions on Elasticsearch gem [#110](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/110)
@@ -94,7 +103,7 @@
94
103
 
95
104
  ## 4.0.2
96
105
  - Bump ES client to 5.0.2 to get content-type: json behavior
97
- - Revert unneeded manticore change
106
+ - Revert unneeded manticore change
98
107
 
99
108
  ## 4.0.1
100
109
  - Switch internal HTTP client to support TLSv1.2
@@ -107,7 +116,7 @@
107
116
  behavior
108
117
  - Improve documentation to show sort by \_doc, and how to add it to custom
109
118
  queries.
110
-
119
+
111
120
  ## 3.0.2
112
121
  - Relax constraint on logstash-core-plugin-api to >= 1.60 <= 2.99
113
122
 
data/Gemfile CHANGED
@@ -9,3 +9,6 @@ if Dir.exist?(logstash_path) && use_logstash_source
9
9
  gem 'logstash-core', :path => "#{logstash_path}/logstash-core"
10
10
  gem 'logstash-core-plugin-api', :path => "#{logstash_path}/logstash-core-plugin-api"
11
11
  end
12
+
13
+ gem 'manticore', ENV['MANTICORE_VERSION'] if ENV['MANTICORE_VERSION']
14
+ gem 'elasticsearch', ENV['ELASTICSEARCH_VERSION'] if ENV['ELASTICSEARCH_VERSION']
@@ -347,7 +347,7 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
347
347
  end
348
348
 
349
349
  def clear_scroll(scroll_id)
350
- @client.clear_scroll(scroll_id: scroll_id) if scroll_id
350
+ @client.clear_scroll(:body => { :scroll_id => scroll_id }) if scroll_id
351
351
  rescue => e
352
352
  # ignore & log any clear_scroll errors
353
353
  logger.warn("Ignoring clear_scroll exception", message: e.message, exception: e.class)
@@ -386,13 +386,13 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
386
386
 
387
387
  def setup_hosts
388
388
  @hosts = Array(@hosts).map { |host| host.to_s } # potential SafeURI#to_s
389
- if @ssl
390
- @hosts.map do |h|
391
- host, port = h.split(":")
392
- { :host => host, :scheme => 'https', :port => port }
389
+ @hosts.map do |h|
390
+ if h.start_with?('http:', 'https:')
391
+ h
392
+ else
393
+ host, port = h.split(':')
394
+ { host: host, port: port, scheme: (@ssl ? 'https' : 'http') }
393
395
  end
394
- else
395
- @hosts
396
396
  end
397
397
  end
398
398
 
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-input-elasticsearch'
4
- s.version = '4.12.0'
4
+ s.version = '4.12.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"
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
25
25
  s.add_runtime_dependency 'logstash-mixin-event_support', '~> 1.0'
26
26
  s.add_runtime_dependency "logstash-mixin-validator_support", '~> 1.0'
27
27
 
28
- s.add_runtime_dependency 'elasticsearch', '>= 7.14.0' # LS >= 6.7 and < 7.14 all used version 5.0.5
28
+ s.add_runtime_dependency 'elasticsearch', '>= 7.17.1'
29
29
 
30
30
  s.add_runtime_dependency 'tzinfo'
31
31
  s.add_runtime_dependency 'tzinfo-data'
@@ -33,7 +33,6 @@ Gem::Specification.new do |s|
33
33
  s.add_runtime_dependency 'manticore', ">= 0.7.1"
34
34
 
35
35
  s.add_development_dependency 'logstash-codec-plain'
36
- s.add_development_dependency 'faraday', "~> 1"
37
36
  s.add_development_dependency 'logstash-devutils'
38
37
  s.add_development_dependency 'timecop'
39
38
  s.add_development_dependency 'cabin', ['~> 0.6']
data/spec/es_helper.rb CHANGED
@@ -7,25 +7,26 @@ module ESHelper
7
7
  end
8
8
  end
9
9
 
10
- def self.get_client(options)
11
- require 'elasticsearch/transport/transport/http/faraday' # supports user/password options
12
- host, port = get_host_port.split(':')
13
- host_opts = { host: host, port: port, scheme: 'http' }
14
- ssl_opts = {}
15
-
16
- if options[:ca_file]
17
- ssl_opts = { ca_file: options[:ca_file], version: 'TLSv1.2', verify: false }
18
- host_opts[:scheme] = 'https'
10
+ def self.curl_and_get_json_response(url, method: :get, args: nil); require 'open3'
11
+ cmd = "curl -s -v --show-error #{args} -X #{method.to_s.upcase} -k #{url}"
12
+ begin
13
+ out, err, status = Open3.capture3(cmd)
14
+ rescue Errno::ENOENT
15
+ fail "curl not available, make sure curl binary is installed and available on $PATH"
19
16
  end
20
17
 
21
- if options[:user] && options[:password]
22
- host_opts[:user] = options[:user]
23
- host_opts[:password] = options[:password]
24
- end
18
+ if status.success?
19
+ http_status = err.match(/< HTTP\/1.1 (.*?)/)[1] || '0' # < HTTP/1.1 200 OK\r\n
20
+ if http_status.strip[0].to_i > 2
21
+ warn out
22
+ fail "#{cmd.inspect} unexpected response: #{http_status}\n\n#{err}"
23
+ end
25
24
 
26
- Elasticsearch::Client.new(hosts: [host_opts],
27
- transport_options: { ssl: ssl_opts },
28
- transport_class: Elasticsearch::Transport::Transport::HTTP::Faraday)
25
+ LogStash::Json.load(out)
26
+ else
27
+ warn out
28
+ fail "#{cmd.inspect} process failed: #{status}\n\n#{err}"
29
+ end
29
30
  end
30
31
 
31
32
  def self.doc_type
@@ -47,7 +47,6 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
47
47
  end
48
48
 
49
49
  it_behaves_like "an interruptible input plugin" do
50
- let(:esclient) { double("elasticsearch-client") }
51
50
  let(:config) do
52
51
  {
53
52
  "schedule" => "* * * * * UTC"
@@ -55,7 +54,8 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
55
54
  end
56
55
 
57
56
  before :each do
58
- allow(Elasticsearch::Client).to receive(:new).and_return(esclient)
57
+ @esclient = double("elasticsearch-client")
58
+ allow(Elasticsearch::Client).to receive(:new).and_return(@esclient)
59
59
  hit = {
60
60
  "_index" => "logstash-2014.10.12",
61
61
  "_type" => "logs",
@@ -63,10 +63,10 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
63
63
  "_score" => 1.0,
64
64
  "_source" => { "message" => ["ohayo"] }
65
65
  }
66
- allow(esclient).to receive(:search) { { "hits" => { "hits" => [hit] } } }
67
- allow(esclient).to receive(:scroll) { { "hits" => { "hits" => [hit] } } }
68
- allow(esclient).to receive(:clear_scroll).and_return(nil)
69
- allow(esclient).to receive(:ping)
66
+ allow(@esclient).to receive(:search) { { "hits" => { "hits" => [hit] } } }
67
+ allow(@esclient).to receive(:scroll) { { "hits" => { "hits" => [hit] } } }
68
+ allow(@esclient).to receive(:clear_scroll).and_return(nil)
69
+ allow(@esclient).to receive(:ping)
70
70
  end
71
71
  end
72
72
 
@@ -933,7 +933,7 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
933
933
  {
934
934
  "hosts" => ["localhost"],
935
935
  "query" => '{ "query": { "match": { "city_name": "Okinawa" } }, "fields": ["message"] }',
936
- "schedule" => "* * * * * UTC"
936
+ "schedule" => "* * * * * * UTC" # every second
937
937
  }
938
938
  end
939
939
 
@@ -942,21 +942,14 @@ describe LogStash::Inputs::Elasticsearch, :ecs_compatibility_support do
942
942
  end
943
943
 
944
944
  it "should properly schedule" do
945
- Timecop.travel(Time.new(2000))
946
- Timecop.scale(60)
947
- runner = Thread.new do
948
- expect(plugin).to receive(:do_run) {
949
- queue << LogStash::Event.new({})
950
- }.at_least(:twice)
951
-
952
- plugin.run(queue)
953
- end
954
- sleep 3
945
+ expect(plugin).to receive(:do_run) {
946
+ queue << LogStash::Event.new({})
947
+ }.at_least(:twice)
948
+ runner = Thread.start { plugin.run(queue) }
949
+ sleep 3.0
955
950
  plugin.stop
956
- runner.kill
957
951
  runner.join
958
- expect(queue.size).to eq(2)
959
- Timecop.return
952
+ expect(queue.size).to be >= 2
960
953
  end
961
954
 
962
955
  end
@@ -6,29 +6,46 @@ require_relative "../../../spec/es_helper"
6
6
 
7
7
  describe LogStash::Inputs::Elasticsearch do
8
8
 
9
- let(:config) { { 'hosts' => [ESHelper.get_host_port],
9
+ SECURE_INTEGRATION = ENV['SECURE_INTEGRATION'].eql? 'true'
10
+
11
+ let(:config) { { 'hosts' => ["http#{SECURE_INTEGRATION ? 's' : nil}://#{ESHelper.get_host_port}"],
10
12
  'index' => 'logs',
11
13
  'query' => '{ "query": { "match": { "message": "Not found"} }}' } }
14
+
12
15
  let(:plugin) { described_class.new(config) }
13
16
  let(:event) { LogStash::Event.new({}) }
14
17
  let(:client_options) { Hash.new }
15
18
 
19
+ let(:user) { ENV['ELASTIC_USER'] || 'simpleuser' }
20
+ let(:password) { ENV['ELASTIC_PASSWORD'] || 'abc123' }
21
+ let(:ca_file) { "spec/fixtures/test_certs/ca.crt" }
22
+
23
+ let(:es_url) do
24
+ es_url = ESHelper.get_host_port
25
+ SECURE_INTEGRATION ? "https://#{es_url}" : "http://#{es_url}"
26
+ end
27
+
28
+ let(:curl_args) do
29
+ config['user'] ? "-u #{config['user']}:#{config['password']}" : ''
30
+ end
31
+
16
32
  before(:each) do
17
- @es = ESHelper.get_client(client_options)
18
33
  # Delete all templates first.
19
34
  # Clean ES of data before we start.
20
- @es.indices.delete_template(:name => "*")
35
+ ESHelper.curl_and_get_json_response "#{es_url}/_index_template/*", method: 'DELETE', args: curl_args
21
36
  # This can fail if there are no indexes, ignore failure.
22
- @es.indices.delete(:index => "*") rescue nil
37
+ ESHelper.curl_and_get_json_response( "#{es_url}/_index/*", method: 'DELETE', args: curl_args) rescue nil
38
+ doc_args = "#{curl_args} -H 'Content-Type: application/json' -d '{\"response\": 404, \"message\":\"Not Found\"}'"
23
39
  10.times do
24
- ESHelper.index_doc(@es, :index => 'logs', :body => { :response => 404, :message=> 'Not Found'})
40
+ ESHelper.curl_and_get_json_response "#{es_url}/logs/_doc", method: 'POST', args: doc_args
25
41
  end
26
- @es.indices.refresh
42
+ ESHelper.curl_and_get_json_response "#{es_url}/_refresh", method: 'POST', args: curl_args
27
43
  end
28
44
 
29
45
  after(:each) do
30
- @es.indices.delete_template(:name => "*")
31
- @es.indices.delete(:index => "*") rescue nil
46
+ ESHelper.curl_and_get_json_response "#{es_url}/_index_template/*", method: 'DELETE', args: curl_args
47
+ # This can fail if there are no indexes, ignore failure.
48
+ ESHelper.curl_and_get_json_response( "#{es_url}/_index/*", method: 'DELETE', args: curl_args) rescue nil
32
49
  end
33
50
 
34
51
  shared_examples 'an elasticsearch index plugin' do
@@ -45,7 +62,7 @@ describe LogStash::Inputs::Elasticsearch do
45
62
  end
46
63
  end
47
64
 
48
- describe 'against an unsecured elasticsearch', :integration => true do
65
+ describe 'against an unsecured elasticsearch', integration: true do
49
66
  before(:each) do
50
67
  plugin.register
51
68
  end
@@ -53,10 +70,7 @@ describe LogStash::Inputs::Elasticsearch do
53
70
  it_behaves_like 'an elasticsearch index plugin'
54
71
  end
55
72
 
56
- describe 'against a secured elasticsearch', :secure_integration => true do
57
- let(:user) { ENV['ELASTIC_USER'] || 'simpleuser' }
58
- let(:password) { ENV['ELASTIC_PASSWORD'] || 'abc123' }
59
- let(:ca_file) { "spec/fixtures/test_certs/ca.crt" }
73
+ describe 'against a secured elasticsearch', secure_integration: true do
60
74
 
61
75
  let(:client_options) { { :ca_file => ca_file, :user => user, :password => password } }
62
76
 
@@ -78,4 +92,28 @@ describe LogStash::Inputs::Elasticsearch do
78
92
  end
79
93
 
80
94
  end
95
+
96
+ context 'setting host:port', integration: true do
97
+
98
+ let(:config) do
99
+ super().merge "hosts" => [ESHelper.get_host_port]
100
+ end
101
+
102
+ it_behaves_like 'an elasticsearch index plugin'
103
+
104
+ end
105
+
106
+ context 'setting host:port (and ssl)', secure_integration: true do
107
+
108
+ let(:client_options) { { :ca_file => ca_file, :user => user, :password => password } }
109
+
110
+ let(:config) do
111
+ config = super().merge "hosts" => [ESHelper.get_host_port]
112
+ config.merge('user' => user, 'password' => password, 'ssl' => true, 'ca_file' => ca_file)
113
+ end
114
+
115
+ it_behaves_like 'an elasticsearch index plugin'
116
+
117
+ end
118
+
81
119
  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.12.0
4
+ version: 4.12.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-11 00:00:00.000000000 Z
11
+ date: 2022-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -77,7 +77,7 @@ dependencies:
77
77
  requirements:
78
78
  - - ">="
79
79
  - !ruby/object:Gem::Version
80
- version: 7.14.0
80
+ version: 7.17.1
81
81
  name: elasticsearch
82
82
  prerelease: false
83
83
  type: :runtime
@@ -85,7 +85,7 @@ dependencies:
85
85
  requirements:
86
86
  - - ">="
87
87
  - !ruby/object:Gem::Version
88
- version: 7.14.0
88
+ version: 7.17.1
89
89
  - !ruby/object:Gem::Dependency
90
90
  requirement: !ruby/object:Gem::Requirement
91
91
  requirements:
@@ -156,20 +156,6 @@ dependencies:
156
156
  - - ">="
157
157
  - !ruby/object:Gem::Version
158
158
  version: '0'
159
- - !ruby/object:Gem::Dependency
160
- requirement: !ruby/object:Gem::Requirement
161
- requirements:
162
- - - "~>"
163
- - !ruby/object:Gem::Version
164
- version: '1'
165
- name: faraday
166
- prerelease: false
167
- type: :development
168
- version_requirements: !ruby/object:Gem::Requirement
169
- requirements:
170
- - - "~>"
171
- - !ruby/object:Gem::Version
172
- version: '1'
173
159
  - !ruby/object:Gem::Dependency
174
160
  requirement: !ruby/object:Gem::Requirement
175
161
  requirements: