logstash-filter-elasticsearch 2.1.0 → 2.1.1
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4449efda65f5a277f728141753eb1c950e83ef04
|
4
|
+
data.tar.gz: e56e6b5c256c27117461b6db0bea22bfbb527d34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f59ef828868090acfef220f3ad3dd6e01154963a4e362d40438a8bbb67a33f17fc71286c0b5b4133430738d97b7256defa34e6a6c5cd62569fd9ec5e03f225c7
|
7
|
+
data.tar.gz: 30932b8f798136089e5c609bb1ad801441779a2053f452d11b3b3acab493874f6895a304241e4d63b52400826753657d8a41d3c7a1c457e4c3669ebd08dfb9c8
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
## 2.1.1
|
2
|
+
- Fix: wrong usage of search params, now if index is properly specified
|
3
|
+
it's passed to search so it's performed not to all indices if this is not the explicit intention.
|
1
4
|
## 2.1.0
|
2
5
|
- Improved the configuration options to be more easy to understand and
|
3
6
|
match what the expectations are from the documentation.
|
@@ -74,8 +74,7 @@ class LogStash::Filters::Elasticsearch < LogStash::Filters::Base
|
|
74
74
|
:ssl => @ssl,
|
75
75
|
:hosts => @hosts,
|
76
76
|
:ca_file => @ca_file,
|
77
|
-
:logger => @logger
|
78
|
-
:index => @index
|
77
|
+
:logger => @logger
|
79
78
|
}
|
80
79
|
@client = LogStash::Filters::ElasticsearchClient.new(@user, @password, options)
|
81
80
|
end # def register
|
@@ -83,7 +82,8 @@ class LogStash::Filters::Elasticsearch < LogStash::Filters::Base
|
|
83
82
|
def filter(event)
|
84
83
|
begin
|
85
84
|
query_str = event.sprintf(@query)
|
86
|
-
|
85
|
+
|
86
|
+
params = { :q => query_str, :size => result_size, :index => @index }
|
87
87
|
params[:sort] = @sort if @enable_sort
|
88
88
|
results = @client.search(params)
|
89
89
|
|
@@ -97,7 +97,7 @@ class LogStash::Filters::Elasticsearch < LogStash::Filters::Base
|
|
97
97
|
end
|
98
98
|
end
|
99
99
|
rescue => e
|
100
|
-
@logger.warn("Failed to query elasticsearch for previous event", :index
|
100
|
+
@logger.warn("Failed to query elasticsearch for previous event", :index => @index, :query => query_str, :event => event, :error => e)
|
101
101
|
@tag_on_failure.each{|tag| event.tag(tag)}
|
102
102
|
end
|
103
103
|
filter_matched(event)
|
@@ -23,7 +23,7 @@ module LogStash
|
|
23
23
|
transport_options[:ssl] = { ca_file: options[:ca_file] } if ssl && options[:ca_file]
|
24
24
|
|
25
25
|
@logger.info("New ElasticSearch filter", :hosts => hosts)
|
26
|
-
@client = ::Elasticsearch::Client.new(
|
26
|
+
@client = ::Elasticsearch::Client.new(hosts: hosts, transport_options: transport_options)
|
27
27
|
end
|
28
28
|
|
29
29
|
def search(params)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-filter-elasticsearch'
|
4
|
-
s.version = '2.1.
|
4
|
+
s.version = '2.1.1'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "Search elasticsearch for a previous log event and copy some fields from it into the current event"
|
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"
|
@@ -43,6 +43,28 @@ describe LogStash::Filters::Elasticsearch do
|
|
43
43
|
expect(event["code"]).to eq(404)
|
44
44
|
end
|
45
45
|
|
46
|
+
it "should receive all necessary params to perform the search" do
|
47
|
+
expect(client).to receive(:search).with({:q=>"response: 404", :size=>1, :index=>"", :sort=>"@timestamp:desc"})
|
48
|
+
plugin.filter(event)
|
49
|
+
end
|
50
|
+
|
51
|
+
context "when asking to hit specific index" do
|
52
|
+
|
53
|
+
let(:config) do
|
54
|
+
{
|
55
|
+
"index" => "foo*",
|
56
|
+
"hosts" => ["localhost:9200"],
|
57
|
+
"query" => "response: 404",
|
58
|
+
"fields" => [ ["response", "code"] ],
|
59
|
+
}
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should receive all necessary params to perform the search" do
|
63
|
+
expect(client).to receive(:search).with({:q=>"response: 404", :size=>1, :index=>"foo*", :sort=>"@timestamp:desc"})
|
64
|
+
plugin.filter(event)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
46
68
|
context "when asking for more than one result" do
|
47
69
|
|
48
70
|
let(:config) do
|
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: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|