logstash-filter-rest 0.1.3 → 0.1.4

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: a5964c6a51327b4953e168e475062fe91d8d1abc
4
- data.tar.gz: 9210f9fe34adddca81b46f7104ba7d52ed5658d3
3
+ metadata.gz: c9e0299b703d9633505ab0430805ca396d641797
4
+ data.tar.gz: e4582e84fa6b356034bcd2411fd5c0816ff82be4
5
5
  SHA512:
6
- metadata.gz: f2147cf903f6e68c9f55861bce661bf163722518f2d652229a1a5cb6d75492726734f22d017115e0a8e2d8851002893e53f572ef1b7f769fc3e5ee25cba2184e
7
- data.tar.gz: ea49d12ba7097e89161e4cafb05fad46447664d315cf5a172545bc02639ec6841c2cf3b9a6fa86f5e6cdcedb518b6addb06d3ba9f6ea09af25e1b1f0c28244b1
6
+ metadata.gz: b281e4f79495b734bf63150c57694a36c23c8cd970d7d1103ce6e8751b7d4dee8640153ed1f0ce9dc7557c2360258b5a1ef740dfd62ace80de2b4adaa35a0bd6
7
+ data.tar.gz: aafd124a94396f240bae382b6cb4757a882af5ca86518e5c3ce5e259f48d144c80146f883013943d9d3dc59be1cca12e1fe9678de1ec55783ebf47eb2820d63d
@@ -48,31 +48,12 @@ class LogStash::Filters::Rest < LogStash::Filters::Base
48
48
  public
49
49
  def filter(event)
50
50
  return unless filter?(event)
51
-
52
51
  begin
53
-
54
- if sprintf == true
55
- begin
56
- # sprintf values
57
- @url = event.sprintf(@url)
58
- @header.each do |key, value|
59
- @header[key] = event.sprintf(value)
60
- end
61
- @params.each do |key, value|
62
- @params[key] = event.sprintf(value)
63
- end
64
- rescue
65
- @logger.error("Error during sprintf", :url => url, :method => method, :json => json, :header => header, :params => params)
66
- @logger.error("Rest Error Message:", :message => $!.message)
67
- @logger.error("Backtrace:", :backtrace => $!.backtrace)
68
- end
69
- end
70
-
71
52
  case method
72
53
  when "get"
73
- response = RestClient.get @url, @header
54
+ response = RestClient.get sprint(@sprintf, @url, event), sprint(@sprintf, @header, event)
74
55
  when "post"
75
- response = RestClient.post @url, @params, @header
56
+ response = RestClient.post sprint(@sprintf, @url, event), sprint(@sprintf, @params, event), sprint(@sprintf, @header, event)
76
57
  else
77
58
  response = "invalid method"
78
59
  @logger.error("Invalid method:", :method => method)
@@ -104,4 +85,21 @@ class LogStash::Filters::Rest < LogStash::Filters::Base
104
85
 
105
86
  filter_matched(event)
106
87
  end # def filter
88
+
89
+ def sprint(sprintf, hash, event)
90
+ if sprintf
91
+ if hash.class == Hash
92
+ result = { }
93
+ hash.each do |key, value|
94
+ result[key] = event.sprintf(value)
95
+ end
96
+ return result
97
+ else
98
+ return event.sprintf(hash)
99
+ end
100
+ else
101
+ return hash
102
+ end
103
+ end
104
+
107
105
  end # class LogStash::Filters::Rest
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-filter-rest'
3
- s.version = '0.1.3'
3
+ s.version = '0.1.4'
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"
@@ -7,7 +7,7 @@ describe LogStash::Filters::Rest do
7
7
  filter {
8
8
  rest {
9
9
  url => "http://jsonplaceholder.typicode.com/users/1"
10
- json => true
10
+ json => true
11
11
  }
12
12
  }
13
13
  CONFIG
@@ -15,6 +15,7 @@ describe LogStash::Filters::Rest do
15
15
 
16
16
  sample("message" => "some text") do
17
17
  expect(subject).to include("rest_response")
18
+ expect(subject['rest_response']).to include("id")
18
19
  end
19
20
  end
20
21
  end
metadata CHANGED
@@ -1,17 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-rest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lucas Henning
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-14 00:00:00.000000000 Z
11
+ date: 2015-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- requirement: !ruby/object:Gem::Requirement
14
+ name: logstash-core
15
+ version_requirements: !ruby/object:Gem::Requirement
15
16
  requirements:
16
17
  - - '>='
17
18
  - !ruby/object:Gem::Version
@@ -19,10 +20,7 @@ dependencies:
19
20
  - - <
20
21
  - !ruby/object:Gem::Version
21
22
  version: 2.0.0
22
- name: logstash-core
23
- prerelease: false
24
- type: :runtime
25
- version_requirements: !ruby/object:Gem::Requirement
23
+ requirement: !ruby/object:Gem::Requirement
26
24
  requirements:
27
25
  - - '>='
28
26
  - !ruby/object:Gem::Version
@@ -30,48 +28,50 @@ dependencies:
30
28
  - - <
31
29
  - !ruby/object:Gem::Version
32
30
  version: 2.0.0
31
+ prerelease: false
32
+ type: :runtime
33
33
  - !ruby/object:Gem::Dependency
34
+ name: rest-client
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - '>='
38
+ - !ruby/object:Gem::Version
39
+ version: 1.8.0
34
40
  requirement: !ruby/object:Gem::Requirement
35
41
  requirements:
36
42
  - - '>='
37
43
  - !ruby/object:Gem::Version
38
44
  version: 1.8.0
39
- name: rest-client
40
45
  prerelease: false
41
46
  type: :runtime
47
+ - !ruby/object:Gem::Dependency
48
+ name: logstash-codec-json
42
49
  version_requirements: !ruby/object:Gem::Requirement
43
50
  requirements:
44
51
  - - '>='
45
52
  - !ruby/object:Gem::Version
46
- version: 1.8.0
47
- - !ruby/object:Gem::Dependency
53
+ version: '0'
48
54
  requirement: !ruby/object:Gem::Requirement
49
55
  requirements:
50
56
  - - '>='
51
57
  - !ruby/object:Gem::Version
52
58
  version: '0'
53
- name: logstash-codec-json
54
59
  prerelease: false
55
60
  type: :runtime
61
+ - !ruby/object:Gem::Dependency
62
+ name: logstash-devutils
56
63
  version_requirements: !ruby/object:Gem::Requirement
57
64
  requirements:
58
65
  - - '>='
59
66
  - !ruby/object:Gem::Version
60
67
  version: '0'
61
- - !ruby/object:Gem::Dependency
62
68
  requirement: !ruby/object:Gem::Requirement
63
69
  requirements:
64
70
  - - '>='
65
71
  - !ruby/object:Gem::Version
66
72
  version: '0'
67
- name: logstash-devutils
68
73
  prerelease: false
69
74
  type: :development
70
- version_requirements: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - '>='
73
- - !ruby/object:Gem::Version
74
- version: '0'
75
75
  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
76
76
  email: mail@hurb.de
77
77
  executables: []
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
109
  version: '0'
110
110
  requirements: []
111
111
  rubyforge_project:
112
- rubygems_version: 2.4.5
112
+ rubygems_version: 2.4.6
113
113
  signing_key:
114
114
  specification_version: 4
115
115
  summary: This filter requests data from a RESTful Web Service.