logstash-filter-elasticsearch 3.0.0 → 3.0.1

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
  SHA1:
3
- metadata.gz: c49921dd793aef36a733aea0ed8a5779b18436b1
4
- data.tar.gz: 87a9620d7ab1ecb01ae9beb754e6792b4a98b79d
3
+ metadata.gz: c1a7fa7e023885cbf1a40246c09c81e7280d06dd
4
+ data.tar.gz: 7cfd59b8225d3d6e820aef510882e189b2d77526
5
5
  SHA512:
6
- metadata.gz: c5a2a6405f93d584e3f72130eebd95ce722ea6a2921fa0042893b25b49998013bd38767b1b9c1e3ad611ba75571a70ce2385a18cdee85b73a5e02835f4fb1cf5
7
- data.tar.gz: 8cdd41e4935039db5f7efaf6885f87556d0be62a882b4ad3839c426010d40b6a8e205113495464e7d3049ba62ac3d1c1ac6c891d9db4c3cbb2264b3d7c75456d
6
+ metadata.gz: 713ee393456513db2a61e19fc9790fb12204053688fc3c7649fbc5d4fbb2d2d3aef72f5c6698416e71245b9a0f587fe6cf192bd97fa6824312292d3246240aee
7
+ data.tar.gz: b5a3909c49610544c19db58bb08814f99e49a73d1f12533d7396a48ec8c388c0539793143d39542d13d4f3d6ec31d211f4f0a2334468d9c9cfe699bfef091c41
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 3.0.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
  ## 3.0.0
2
5
  - Breaking: Updated plugin to use new Java Event APIs
3
6
  ## 2.1.0
@@ -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
@@ -84,7 +83,7 @@ class LogStash::Filters::Elasticsearch < LogStash::Filters::Base
84
83
  begin
85
84
  query_str = event.sprintf(@query)
86
85
 
87
- params = { :q => query_str, :size => result_size }
86
+ params = { :q => query_str, :size => result_size, :index => @index }
88
87
  params[:sort] = @sort if @enable_sort
89
88
  results = @client.search(params)
90
89
 
@@ -98,7 +97,7 @@ class LogStash::Filters::Elasticsearch < LogStash::Filters::Base
98
97
  end
99
98
  end
100
99
  rescue => e
101
- @logger.warn("Failed to query elasticsearch for previous event", :index, @index, :query => query_str, :event => event, :error => e)
100
+ @logger.warn("Failed to query elasticsearch for previous event", :index => @index, :query => query_str, :event => event, :error => e)
102
101
  @tag_on_failure.each{|tag| event.tag(tag)}
103
102
  end
104
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(index: options[:index], hosts: hosts, transport_options: transport_options)
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 = '3.0.0'
4
+ s.version = '3.0.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.get("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: 3.0.0
4
+ version: 3.0.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-06-21 00:00:00.000000000 Z
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