logstash-filter-rest 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/logstash/filters/rest.rb +7 -6
- data/logstash-filter-rest.gemspec +1 -1
- data/spec/filters/rest_spec.rb +12 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2af5930ffb298925b7a340afd929ac9c85559f4f
|
4
|
+
data.tar.gz: 57e160ff830adbc6b63d22968e4f20047b1779a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bedafb7870ae6c5d0fc22c81f4fcedd5b1384d6524afd8394da949502f6af8ce9d551615fa73751e112db6e44acfb51b90854874ac4199f0cc3cf53e55a7951a
|
7
|
+
data.tar.gz: cb947ea8b5cbd4f666afcb297f2e45cc2f8bf5655db1f16b66de7a7a649eefc01332fb6e3156076b92ada1986d9e469027c5a8552f1880ab0a69be55f86efc1e
|
@@ -106,7 +106,7 @@ class LogStash::Filters::Rest < LogStash::Filters::Base
|
|
106
106
|
public
|
107
107
|
|
108
108
|
def register
|
109
|
-
@request = normalize_request(@request)
|
109
|
+
@request = normalize_request(@request).freeze
|
110
110
|
end # def register
|
111
111
|
|
112
112
|
private
|
@@ -190,11 +190,12 @@ class LogStash::Filters::Rest < LogStash::Filters::Base
|
|
190
190
|
|
191
191
|
def filter(event)
|
192
192
|
return unless filter?(event)
|
193
|
-
|
194
|
-
|
195
|
-
|
193
|
+
request = @request.dup
|
194
|
+
request[2][:params] = sprint(@sprintf, @request[2][:params], event) if request[2].key?(:params)
|
195
|
+
request[2][:body] = sprint(@sprintf, @request[2][:body], event) if request[2].key?(:body)
|
196
|
+
request[1] = sprint(@sprintf, @request[1], event)
|
196
197
|
|
197
|
-
code, body = request_http(
|
198
|
+
code, body = request_http(request)
|
198
199
|
if code.between?(200, 299)
|
199
200
|
event = process_response(body, event)
|
200
201
|
@logger.debug? && @logger.debug('Sucess received', :code => code, :body => body)
|
@@ -202,7 +203,7 @@ class LogStash::Filters::Rest < LogStash::Filters::Base
|
|
202
203
|
@logger.debug? && @logger.debug('Http error received', :code => code, :body => body)
|
203
204
|
if @fallback.empty?
|
204
205
|
@tag_on_rest_failure.each { |tag| event.tag(tag) }
|
205
|
-
@logger.error('Error in Rest filter', :request =>
|
206
|
+
@logger.error('Error in Rest filter', :request => request, :json => @json, :code => code, :body => body)
|
206
207
|
else
|
207
208
|
event = add_to_event(@fallback, event)
|
208
209
|
@logger.debug? && @logger.debug('Setting fallback', :fallback => @fallback)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-filter-rest'
|
3
|
-
s.version = '0.2.
|
3
|
+
s.version = '0.2.1'
|
4
4
|
s.licenses = ['Apache License (2.0)']
|
5
5
|
s.summary = 'This filter requests data from a RESTful Web Service.'
|
6
6
|
s.description = 'This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program'
|
data/spec/filters/rest_spec.rb
CHANGED
@@ -63,6 +63,12 @@ describe LogStash::Filters::Rest do
|
|
63
63
|
expect(subject['rest']['id']).to eq(10)
|
64
64
|
expect(subject['rest']).to_not include("fallback")
|
65
65
|
end
|
66
|
+
sample("message" => "9") do
|
67
|
+
expect(subject).to include('rest')
|
68
|
+
expect(subject['rest']).to include("id")
|
69
|
+
expect(subject['rest']['id']).to eq(9)
|
70
|
+
expect(subject['rest']).to_not include("fallback")
|
71
|
+
end
|
66
72
|
end
|
67
73
|
describe "Set to Rest Filter Get without params http error" do
|
68
74
|
let(:config) do <<-CONFIG
|
@@ -134,6 +140,12 @@ describe LogStash::Filters::Rest do
|
|
134
140
|
expect(subject['rest'][0]['userId']).to eq(10)
|
135
141
|
expect(subject['rest']).to_not include("fallback")
|
136
142
|
end
|
143
|
+
sample("message" => "9") do
|
144
|
+
expect(subject).to include('rest')
|
145
|
+
expect(subject['rest'][0]).to include("userId")
|
146
|
+
expect(subject['rest'][0]['userId']).to eq(9)
|
147
|
+
expect(subject['rest']).to_not include("fallback")
|
148
|
+
end
|
137
149
|
end
|
138
150
|
describe "Set to Rest Filter Post with params" do
|
139
151
|
let(:config) do <<-CONFIG
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-filter-rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lucas Henning
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-08-
|
12
|
+
date: 2016-08-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
135
|
version: '0'
|
136
136
|
requirements: []
|
137
137
|
rubyforge_project:
|
138
|
-
rubygems_version: 2.
|
138
|
+
rubygems_version: 2.4.8
|
139
139
|
signing_key:
|
140
140
|
specification_version: 4
|
141
141
|
summary: This filter requests data from a RESTful Web Service.
|