logstash-filter-elasticsearch 3.11.0 → 3.11.1
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/Gemfile +3 -0
- data/lib/logstash/filters/elasticsearch/client.rb +12 -1
- data/logstash-filter-elasticsearch.gemspec +1 -1
- data/spec/es_helper.rb +20 -12
- data/spec/filters/elasticsearch_spec.rb +7 -3
- data/spec/filters/fixtures/test_certs/ca.crt +20 -0
- data/spec/filters/fixtures/test_certs/ca.key +27 -0
- data/spec/filters/fixtures/test_certs/es.crt +20 -0
- data/spec/filters/fixtures/test_certs/es.key +27 -0
- data/spec/filters/integration/elasticsearch_spec.rb +37 -10
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d5a56362567a5c8949cb77f1615659c709449c5999fe46e5b558212045d3197
|
4
|
+
data.tar.gz: ba77cec6eda6ea51f037541223d257532a5161081cf64609c2ea6590c6d37ed4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b3415eb21cb9e6bbe25b692514037cdae4c5a64827e99412433b4bf184308fca1a6e307e1b724f0ba7b6c311e2b463346189d6176e78c56941e4dc0af0d8b9b
|
7
|
+
data.tar.gz: 24dad4a1105f97e5c55f94c281d62091db76020c27242253e3307946db755e1093a41c751d175fd23ed07fcb01890e8753fd54691d854b0f456792adbd667b18
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
## 3.11.1
|
2
|
+
- Fix: hosts => "es_host:port" regression [#156](https://github.com/logstash-plugins/logstash-filter-elasticsearch/pull/156)
|
3
|
+
|
1
4
|
## 3.11.0
|
2
5
|
- Feat: update Elasticsearch client to 7.14.0 [#150](https://github.com/logstash-plugins/logstash-filter-elasticsearch/pull/150)
|
3
6
|
|
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']
|
@@ -26,7 +26,7 @@ module LogStash
|
|
26
26
|
logger.warn "Supplied proxy setting (proxy => '') has no effect" if @proxy.eql?('')
|
27
27
|
transport_options[:proxy] = proxy.to_s if proxy && !proxy.eql?('')
|
28
28
|
|
29
|
-
hosts = hosts
|
29
|
+
hosts = setup_hosts(hosts, ssl)
|
30
30
|
# set ca_file even if ssl isn't on, since the host can be an https url
|
31
31
|
ssl_options = { ssl: true, ca_file: options[:ca_file] } if options[:ca_file]
|
32
32
|
ssl_options ||= {}
|
@@ -41,6 +41,17 @@ module LogStash
|
|
41
41
|
|
42
42
|
private
|
43
43
|
|
44
|
+
def setup_hosts(hosts, ssl)
|
45
|
+
hosts.map do |h|
|
46
|
+
if h.start_with?('http:/', 'https:/')
|
47
|
+
h
|
48
|
+
else
|
49
|
+
host, port = h.split(':')
|
50
|
+
{ host: host, port: port, scheme: (ssl ? 'https' : 'http') }
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
44
55
|
def setup_basic_auth(user, password)
|
45
56
|
return {} unless user && password && password.value
|
46
57
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-filter-elasticsearch'
|
4
|
-
s.version = '3.11.
|
4
|
+
s.version = '3.11.1'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "Copies fields from previous log events in Elasticsearch to current events "
|
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"
|
data/spec/es_helper.rb
CHANGED
@@ -7,12 +7,26 @@ module ESHelper
|
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
-
def self.
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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"
|
16
|
+
end
|
17
|
+
|
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
|
24
|
+
|
25
|
+
LogStash::Json.load(out)
|
26
|
+
else
|
27
|
+
warn out
|
28
|
+
fail "#{cmd.inspect} process failed: #{status}\n\n#{err}"
|
29
|
+
end
|
16
30
|
end
|
17
31
|
|
18
32
|
def self.doc_type
|
@@ -25,12 +39,6 @@ module ESHelper
|
|
25
39
|
end
|
26
40
|
end
|
27
41
|
|
28
|
-
def self.index_doc(es, params)
|
29
|
-
type = doc_type
|
30
|
-
params[:type] = doc_type unless type.nil?
|
31
|
-
es.index(params)
|
32
|
-
end
|
33
|
-
|
34
42
|
def self.es_version
|
35
43
|
ENV['ES_VERSION'] || ENV['ELASTIC_STACK_VERSION']
|
36
44
|
end
|
@@ -9,6 +9,10 @@ require "uri"
|
|
9
9
|
|
10
10
|
describe LogStash::Filters::Elasticsearch do
|
11
11
|
|
12
|
+
subject(:plugin) { described_class.new(config) }
|
13
|
+
|
14
|
+
let(:event) { LogStash::Event.new({}) }
|
15
|
+
|
12
16
|
context "registration" do
|
13
17
|
|
14
18
|
let(:plugin) { LogStash::Plugin.lookup("filter", "elasticsearch").new({}) }
|
@@ -53,8 +57,6 @@ describe LogStash::Filters::Elasticsearch do
|
|
53
57
|
"aggregation_fields" => { "bytes_avg" => "bytes_avg_ls_field" }
|
54
58
|
}
|
55
59
|
end
|
56
|
-
let(:plugin) { described_class.new(config) }
|
57
|
-
let(:event) { LogStash::Event.new({}) }
|
58
60
|
|
59
61
|
let(:response) do
|
60
62
|
LogStash::Json.load(File.read(File.join(File.dirname(__FILE__), "fixtures", "request_x_1.json")))
|
@@ -569,7 +571,9 @@ describe LogStash::Filters::Elasticsearch do
|
|
569
571
|
it "should set localhost:9200 as hosts" do
|
570
572
|
plugin.register
|
571
573
|
client = plugin.send(:get_client).client
|
572
|
-
|
574
|
+
hosts = extract_transport(client).hosts
|
575
|
+
expect( hosts.size ).to be 1
|
576
|
+
expect( hosts[0] ).to include(:host => "localhost", :port => 9200, :scheme => "http")
|
573
577
|
end
|
574
578
|
end
|
575
579
|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIIDSTCCAjGgAwIBAgIUUcAg9c8B8jiliCkOEJyqoAHrmccwDQYJKoZIhvcNAQEL
|
3
|
+
BQAwNDEyMDAGA1UEAxMpRWxhc3RpYyBDZXJ0aWZpY2F0ZSBUb29sIEF1dG9nZW5l
|
4
|
+
cmF0ZWQgQ0EwHhcNMjEwODEyMDUxNDU1WhcNMjQwODExMDUxNDU1WjA0MTIwMAYD
|
5
|
+
VQQDEylFbGFzdGljIENlcnRpZmljYXRlIFRvb2wgQXV0b2dlbmVyYXRlZCBDQTCC
|
6
|
+
ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAK1HuusRuGNsztd4EQvqwcMr
|
7
|
+
8XvnNNaalerpMOorCGySEFrNf0HxDIVMGMCrOv1F8SvlcGq3XANs2MJ4F2xhhL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jOkrhxXPkchc9TY4EM7/1XeKvEidlIp0gvRAoGAAurz4zYvW2QhXaR2hhaT
|
19
|
+
p2XSLXiKM8AUndo3rH3U0/lhrvrEZicZsMj2LF88xg20U27sIaD/eJo13Y4XqaPk
|
20
|
+
ykPY6D9srv574SeIeMpx/8PxPiBcoDd+BNc0L1VkgVBoouORAwq5I9HjKKBjdEmI
|
21
|
+
UDw3i0X5KYvDm6fXVAZ0HXUCgYBWc4To8KiXPqNpq2sVzrSkBaWJSmj2G7u7Q6b/
|
22
|
+
RTs3is72v3gjHG6iiaE5URY7mnu4rjlRhAP9Vnsy6uHMrCJZEBTf/sPEYHZj9iGZ
|
23
|
+
EOduOAF3U1tsmaaebbDtm8hdhSOBvITy9kQlSIZAt1r17Ulytz5pj0AySFzJUIkz
|
24
|
+
a0SZkQKBgCWixtUxiK8PAdWhyS++90WJeJn8eqjuSAz+VMtFQFRRWDUbkiHvGMRu
|
25
|
+
o/Hhk6zS46gSF2Evb1d26uUEenXnJlIp6YWzb0DLPrfy5P53kPA6YEvYq5MSAg3l
|
26
|
+
DZOJUF+ko7cWXSZkeTIBH/jrGOdP4tTALZt6DNt+Gz7xwPO5tGgV
|
27
|
+
-----END RSA PRIVATE KEY-----
|
@@ -7,11 +7,12 @@ require_relative "../../../spec/es_helper"
|
|
7
7
|
describe LogStash::Filters::Elasticsearch, :integration => true do
|
8
8
|
|
9
9
|
ELASTIC_SECURITY_ENABLED = ENV['ELASTIC_SECURITY_ENABLED'].eql? 'true'
|
10
|
+
SECURE_INTEGRATION = ENV['SECURE_INTEGRATION'].eql? 'true'
|
10
11
|
|
11
12
|
let(:base_config) do
|
12
13
|
{
|
13
14
|
"index" => 'logs',
|
14
|
-
"hosts" => [ESHelper.get_host_port],
|
15
|
+
"hosts" => ["http#{SECURE_INTEGRATION ? 's' : nil}://#{ESHelper.get_host_port}"],
|
15
16
|
"query" => "response: 404",
|
16
17
|
"sort" => "response",
|
17
18
|
"fields" => [ ["response", "code"] ],
|
@@ -19,27 +20,40 @@ describe LogStash::Filters::Elasticsearch, :integration => true do
|
|
19
20
|
end
|
20
21
|
|
21
22
|
let(:credentials) do
|
22
|
-
|
23
|
+
if SECURE_INTEGRATION
|
24
|
+
{ 'user' => 'tests', 'password' => 'Tests123' } # added user
|
25
|
+
else
|
26
|
+
{ 'user' => 'elastic', 'password' => ENV['ELASTIC_PASSWORD'] }
|
27
|
+
end
|
23
28
|
end
|
24
29
|
|
25
30
|
let(:config) do
|
26
|
-
ELASTIC_SECURITY_ENABLED ? base_config.merge(credentials) : base_config
|
31
|
+
config = ELASTIC_SECURITY_ENABLED ? base_config.merge(credentials) : base_config
|
32
|
+
config = { 'ca_file' => ca_path }.merge(config) if SECURE_INTEGRATION
|
33
|
+
config
|
34
|
+
end
|
35
|
+
|
36
|
+
let(:ca_path) do
|
37
|
+
File.expand_path('../fixtures/test_certs/ca.crt', File.dirname(__FILE__))
|
27
38
|
end
|
28
39
|
|
29
40
|
let(:plugin) { described_class.new(config) }
|
30
41
|
let(:event) { LogStash::Event.new({}) }
|
31
42
|
|
32
43
|
before(:each) do
|
33
|
-
|
34
|
-
|
44
|
+
es_url = ESHelper.get_host_port
|
45
|
+
es_url = SECURE_INTEGRATION ? "https://#{es_url}" : "http://#{es_url}"
|
46
|
+
args = ELASTIC_SECURITY_ENABLED ? "-u #{credentials['user']}:#{credentials['password']}" : ''
|
35
47
|
# Clean ES of data before we start.
|
36
|
-
|
48
|
+
# Delete all templates first.
|
49
|
+
ESHelper.curl_and_get_json_response "#{es_url}/_index_template/*", method: 'DELETE', args: args
|
37
50
|
# This can fail if there are no indexes, ignore failure.
|
38
|
-
|
51
|
+
ESHelper.curl_and_get_json_response "#{es_url}/_index/*", method: 'DELETE', args: args
|
52
|
+
doc_args = "#{args} -H 'Content-Type: application/json' -d '{\"response\": 404, \"this\":\"that\"}'"
|
39
53
|
10.times do
|
40
|
-
ESHelper.
|
54
|
+
ESHelper.curl_and_get_json_response "#{es_url}/logs/_doc", method: 'POST', args: doc_args
|
41
55
|
end
|
42
|
-
|
56
|
+
ESHelper.curl_and_get_json_response "#{es_url}/_refresh", method: 'POST', args: args
|
43
57
|
end
|
44
58
|
|
45
59
|
it "should enhance the current event with new data" do
|
@@ -69,10 +83,23 @@ describe LogStash::Filters::Elasticsearch, :integration => true do
|
|
69
83
|
super().reject { |key, _| key == 'password' }
|
70
84
|
end
|
71
85
|
|
72
|
-
it "
|
86
|
+
it "fails to register plugin" do
|
73
87
|
expect { plugin.register }.to raise_error Elasticsearch::Transport::Transport::Errors::Unauthorized
|
74
88
|
end
|
75
89
|
|
76
90
|
end if ELASTIC_SECURITY_ENABLED
|
77
91
|
|
92
|
+
context 'setting host:port (and ssl)' do # reproduces GH-155
|
93
|
+
|
94
|
+
let(:config) do
|
95
|
+
super().merge "hosts" => [ESHelper.get_host_port], "ssl" => SECURE_INTEGRATION
|
96
|
+
end
|
97
|
+
|
98
|
+
it "works" do
|
99
|
+
expect { plugin.register }.to_not raise_error
|
100
|
+
plugin.filter(event)
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
78
105
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-filter-elasticsearch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.11.
|
4
|
+
version: 3.11.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,6 +128,10 @@ files:
|
|
128
128
|
- spec/filters/fixtures/request_size0_agg.json
|
129
129
|
- spec/filters/fixtures/request_x_1.json
|
130
130
|
- spec/filters/fixtures/request_x_10.json
|
131
|
+
- spec/filters/fixtures/test_certs/ca.crt
|
132
|
+
- spec/filters/fixtures/test_certs/ca.key
|
133
|
+
- spec/filters/fixtures/test_certs/es.crt
|
134
|
+
- spec/filters/fixtures/test_certs/es.key
|
131
135
|
- spec/filters/integration/elasticsearch_spec.rb
|
132
136
|
homepage: http://www.elastic.co/guide/en/logstash/current/index.html
|
133
137
|
licenses:
|
@@ -164,4 +168,8 @@ test_files:
|
|
164
168
|
- spec/filters/fixtures/request_size0_agg.json
|
165
169
|
- spec/filters/fixtures/request_x_1.json
|
166
170
|
- spec/filters/fixtures/request_x_10.json
|
171
|
+
- spec/filters/fixtures/test_certs/ca.crt
|
172
|
+
- spec/filters/fixtures/test_certs/ca.key
|
173
|
+
- spec/filters/fixtures/test_certs/es.crt
|
174
|
+
- spec/filters/fixtures/test_certs/es.key
|
167
175
|
- spec/filters/integration/elasticsearch_spec.rb
|