logstash-filter-rest2 0.5.4 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/logstash/filters/rest.rb +10 -0
- data/logstash-filter-rest.gemspec +1 -1
- data/spec/filters/rest_spec.rb +406 -381
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73bc32f0f3dfe3e5d5595e824370ab60504c4e05fedeeddc95bbf22116f98d99
|
4
|
+
data.tar.gz: 753676d528768372a1caa807862e809d653ef04264eea27692b6c10425725324
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ade33bab3d69e1973e9136fa1bdceefc6cff78a019df97520a0fa05eaec25e6b3841f4cb04dd941cacce11d60dc031c1e00e1c8db5c90dfbf8596890335ceb8d
|
7
|
+
data.tar.gz: 51eb265f4a9d35bcd0238b386bb38cb04aa814914eaaba85183d48ec1a3cee13bae57d899efb0968e1b35eeb08a19672bb361c4c69a9e441a46dce62e52d1c0d
|
data/CHANGELOG.md
CHANGED
@@ -128,6 +128,16 @@ class LogStash::Filters::Rest < LogStash::Filters::Base
|
|
128
128
|
config :tag_on_rest_failure, :validate => :array, :default => ['_restfailure']
|
129
129
|
config :tag_on_json_failure, :validate => :array, :default => ['_jsonparsefailure']
|
130
130
|
|
131
|
+
# If you need to use a custom truststore (`.jks`) specify that here. This does not work with .pem certs!
|
132
|
+
config :truststore, :validate => :path
|
133
|
+
|
134
|
+
# Specify the truststore password here.
|
135
|
+
# Note, most .jks files created with keytool require a password!
|
136
|
+
config :truststore_password, :validate => :password
|
137
|
+
|
138
|
+
# Specify the truststore type here. One of `JKS` or `PKCS12`. Default is `JKS`
|
139
|
+
config :truststore_type, :validate => :string, :default => "JKS"
|
140
|
+
|
131
141
|
public
|
132
142
|
|
133
143
|
def register
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-filter-rest2'
|
3
|
-
s.version = '0.5.
|
3
|
+
s.version = '0.5.5'
|
4
4
|
s.licenses = ['Apache-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/logstash-plugin install logstash-filter-rest2. This gem is not a stand-alone program'
|
data/spec/filters/rest_spec.rb
CHANGED
@@ -7,8 +7,12 @@ describe LogStash::Filters::Rest do
|
|
7
7
|
filter {
|
8
8
|
rest {
|
9
9
|
request => {
|
10
|
-
url => '
|
10
|
+
url => 'https://sbt-otib.sigma.sbrf.ru/otib/rest/application/12'
|
11
|
+
truststore => "/var/app/ca2.jks"
|
12
|
+
truststore_password => "password"
|
11
13
|
}
|
14
|
+
# truststore => "/var/app/ca2.jks"
|
15
|
+
# truststore_password => "password1"
|
12
16
|
json => true
|
13
17
|
target => 'rest'
|
14
18
|
}
|
@@ -23,384 +27,405 @@ describe LogStash::Filters::Rest do
|
|
23
27
|
expect(subject.get('rest')).to_not include('fallback')
|
24
28
|
end
|
25
29
|
end
|
26
|
-
describe 'Set to Rest Filter Get without params
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
end
|
47
|
-
describe 'Set to Rest Filter Get without params
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
end
|
389
|
-
describe '
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
end
|
30
|
+
# describe 'Set to Rest Filter Get without params' do
|
31
|
+
# let(:config) do <<-CONFIG
|
32
|
+
# filter {
|
33
|
+
# rest {
|
34
|
+
# request => {
|
35
|
+
# url => 'http://jsonplaceholder.typicode.com/users/10'
|
36
|
+
# }
|
37
|
+
# json => true
|
38
|
+
# target => 'rest'
|
39
|
+
# }
|
40
|
+
# }
|
41
|
+
# CONFIG
|
42
|
+
# end
|
43
|
+
#
|
44
|
+
# sample('message' => 'some text') do
|
45
|
+
# expect(subject).to include('rest')
|
46
|
+
# expect(subject.get('rest')).to include('id')
|
47
|
+
# expect(subject.get('[rest][id]')).to eq(10)
|
48
|
+
# expect(subject.get('rest')).to_not include('fallback')
|
49
|
+
# end
|
50
|
+
# end
|
51
|
+
# describe 'Set to Rest Filter Get without params custom target' do
|
52
|
+
# let(:config) do <<-CONFIG
|
53
|
+
# filter {
|
54
|
+
# rest {
|
55
|
+
# request => {
|
56
|
+
# url => 'http://jsonplaceholder.typicode.com/users/10'
|
57
|
+
# }
|
58
|
+
# json => true
|
59
|
+
# target => 'testing'
|
60
|
+
# }
|
61
|
+
# }
|
62
|
+
# CONFIG
|
63
|
+
# end
|
64
|
+
#
|
65
|
+
# sample('message' => 'some text') do
|
66
|
+
# expect(subject).to include('testing')
|
67
|
+
# expect(subject.get('testing')).to include('id')
|
68
|
+
# expect(subject.get('[testing][id]')).to eq(10)
|
69
|
+
# expect(subject.get('testing')).to_not include('fallback')
|
70
|
+
# end
|
71
|
+
# end
|
72
|
+
# describe 'Set to Rest Filter Get without params and sprintf' do
|
73
|
+
# let(:config) do <<-CONFIG
|
74
|
+
# filter {
|
75
|
+
# rest {
|
76
|
+
# request => {
|
77
|
+
# url => "http://jsonplaceholder.typicode.com/users/%{message}"
|
78
|
+
# }
|
79
|
+
# json => true
|
80
|
+
# sprintf => true
|
81
|
+
# target => 'rest'
|
82
|
+
# }
|
83
|
+
# }
|
84
|
+
# CONFIG
|
85
|
+
# end
|
86
|
+
#
|
87
|
+
# sample('message' => '10') do
|
88
|
+
# expect(subject).to include('rest')
|
89
|
+
# expect(subject.get('rest')).to include('id')
|
90
|
+
# expect(subject.get('[rest][id]')).to eq(10)
|
91
|
+
# expect(subject.get('rest')).to_not include('fallback')
|
92
|
+
# end
|
93
|
+
# sample('message' => '9') do
|
94
|
+
# expect(subject).to include('rest')
|
95
|
+
# expect(subject.get('rest')).to include('id')
|
96
|
+
# expect(subject.get('[rest][id]')).to eq(9)
|
97
|
+
# expect(subject.get('rest')).to_not include('fallback')
|
98
|
+
# end
|
99
|
+
# end
|
100
|
+
# describe 'Set to Rest Filter Get without params http error' do
|
101
|
+
# let(:config) do <<-CONFIG
|
102
|
+
# filter {
|
103
|
+
# rest {
|
104
|
+
# request => {
|
105
|
+
# url => 'http://httpstat.us/404'
|
106
|
+
# }
|
107
|
+
# json => true
|
108
|
+
# target => 'rest'
|
109
|
+
# }
|
110
|
+
# }
|
111
|
+
# CONFIG
|
112
|
+
# end
|
113
|
+
#
|
114
|
+
# sample('message' => 'some text') do
|
115
|
+
# expect(subject).to_not include('rest')
|
116
|
+
# expect(subject.get('tags')).to include('_restfailure')
|
117
|
+
# end
|
118
|
+
# end
|
119
|
+
# describe 'Set to Rest Filter Get with params' do
|
120
|
+
# let(:config) do <<-CONFIG
|
121
|
+
# filter {
|
122
|
+
# rest {
|
123
|
+
# request => {
|
124
|
+
# url => 'https://jsonplaceholder.typicode.com/posts'
|
125
|
+
# params => {
|
126
|
+
# userId => 10
|
127
|
+
# }
|
128
|
+
# headers => {
|
129
|
+
# 'Content-Type' => 'application/json'
|
130
|
+
# }
|
131
|
+
# }
|
132
|
+
# json => true
|
133
|
+
# target => 'rest'
|
134
|
+
# }
|
135
|
+
# }
|
136
|
+
# CONFIG
|
137
|
+
# end
|
138
|
+
#
|
139
|
+
# sample('message' => 'some text') do
|
140
|
+
# expect(subject).to include('rest')
|
141
|
+
# expect(subject.get('[rest][0]')).to include('userId')
|
142
|
+
# expect(subject.get('[rest][0][userId]')).to eq(10)
|
143
|
+
# expect(subject.get('rest')).to_not include('fallback')
|
144
|
+
# end
|
145
|
+
# end
|
146
|
+
# describe 'empty response' do
|
147
|
+
# let(:config) do <<-CONFIG
|
148
|
+
# filter {
|
149
|
+
# rest {
|
150
|
+
# request => {
|
151
|
+
# url => 'https://jsonplaceholder.typicode.com/posts'
|
152
|
+
# params => {
|
153
|
+
# userId => 0
|
154
|
+
# }
|
155
|
+
# headers => {
|
156
|
+
# 'Content-Type' => 'application/json'
|
157
|
+
# }
|
158
|
+
# }
|
159
|
+
# target => 'rest'
|
160
|
+
# }
|
161
|
+
# }
|
162
|
+
# CONFIG
|
163
|
+
# end
|
164
|
+
#
|
165
|
+
# sample('message' => 'some text') do
|
166
|
+
# expect(subject).to_not include('rest')
|
167
|
+
# expect(subject.get('tags')).to include('_restfailure')
|
168
|
+
# end
|
169
|
+
# end
|
170
|
+
# describe 'Set to Rest Filter Get with params sprintf' do
|
171
|
+
# let(:config) do <<-CONFIG
|
172
|
+
# filter {
|
173
|
+
# rest {
|
174
|
+
# request => {
|
175
|
+
# url => 'https://jsonplaceholder.typicode.com/posts'
|
176
|
+
# params => {
|
177
|
+
# userId => "%{message}"
|
178
|
+
# id => "%{message}"
|
179
|
+
# }
|
180
|
+
# headers => {
|
181
|
+
# 'Content-Type' => 'application/json'
|
182
|
+
# }
|
183
|
+
# }
|
184
|
+
# json => true
|
185
|
+
# target => 'rest'
|
186
|
+
# }
|
187
|
+
# }
|
188
|
+
# CONFIG
|
189
|
+
# end
|
190
|
+
#
|
191
|
+
# sample('message' => '1') do
|
192
|
+
# expect(subject).to include('rest')
|
193
|
+
# expect(subject.get('[rest][0]')).to include('userId')
|
194
|
+
# expect(subject.get('[rest][0][userId]')).to eq(1)
|
195
|
+
# expect(subject.get('[rest][0][id]')).to eq(1)
|
196
|
+
# expect(subject.get('rest').length).to eq(1)
|
197
|
+
# expect(subject.get('rest')).to_not include('fallback')
|
198
|
+
# end
|
199
|
+
# end
|
200
|
+
# describe 'Set to Rest Filter Post with params' do
|
201
|
+
# let(:config) do <<-CONFIG
|
202
|
+
# filter {
|
203
|
+
# rest {
|
204
|
+
# request => {
|
205
|
+
# url => 'https://jsonplaceholder.typicode.com/posts'
|
206
|
+
# method => 'post'
|
207
|
+
# params => {
|
208
|
+
# title => 'foo'
|
209
|
+
# body => 'bar'
|
210
|
+
# userId => 42
|
211
|
+
# }
|
212
|
+
# headers => {
|
213
|
+
# 'Content-Type' => 'application/json'
|
214
|
+
# }
|
215
|
+
# }
|
216
|
+
# json => true
|
217
|
+
# target => 'rest'
|
218
|
+
# }
|
219
|
+
# }
|
220
|
+
# CONFIG
|
221
|
+
# end
|
222
|
+
#
|
223
|
+
# sample('message' => 'some text') do
|
224
|
+
# expect(subject).to include('rest')
|
225
|
+
# expect(subject.get('rest')).to include('id')
|
226
|
+
# expect(subject.get('[rest][userId]')).to eq(42)
|
227
|
+
# expect(subject.get('rest')).to_not include('fallback')
|
228
|
+
# end
|
229
|
+
# end
|
230
|
+
# describe 'Set to Rest Filter Post with params sprintf' do
|
231
|
+
# let(:config) do <<-CONFIG
|
232
|
+
# filter {
|
233
|
+
# rest {
|
234
|
+
# request => {
|
235
|
+
# url => 'https://jsonplaceholder.typicode.com/posts'
|
236
|
+
# method => 'post'
|
237
|
+
# params => {
|
238
|
+
# title => '%{message}'
|
239
|
+
# body => 'bar'
|
240
|
+
# userId => "%{message}"
|
241
|
+
# }
|
242
|
+
# headers => {
|
243
|
+
# 'Content-Type' => 'application/json'
|
244
|
+
# }
|
245
|
+
# }
|
246
|
+
# json => true
|
247
|
+
# target => 'rest'
|
248
|
+
# }
|
249
|
+
# }
|
250
|
+
# CONFIG
|
251
|
+
# end
|
252
|
+
#
|
253
|
+
# sample('message' => '42') do
|
254
|
+
# expect(subject).to include('rest')
|
255
|
+
# expect(subject.get('rest')).to include('id')
|
256
|
+
# expect(subject.get('[rest][title]')).to eq(42)
|
257
|
+
# expect(subject.get('[rest][userId]')).to eq(42)
|
258
|
+
# expect(subject.get('rest')).to_not include('fallback')
|
259
|
+
# end
|
260
|
+
# sample('message' => ':5e?#!-_') do
|
261
|
+
# expect(subject).to include('rest')
|
262
|
+
# expect(subject.get('rest')).to include('id')
|
263
|
+
# expect(subject.get('[rest][title]')).to eq(':5e?#!-_')
|
264
|
+
# expect(subject.get('[rest][userId]')).to eq(':5e?#!-_')
|
265
|
+
# expect(subject.get('rest')).to_not include('fallback')
|
266
|
+
# end
|
267
|
+
# sample('message' => ':4c43=>') do
|
268
|
+
# expect(subject).to include('rest')
|
269
|
+
# expect(subject.get('rest')).to include('id')
|
270
|
+
# expect(subject.get('[rest][title]')).to eq(':4c43=>')
|
271
|
+
# expect(subject.get('[rest][userId]')).to eq(':4c43=>')
|
272
|
+
# expect(subject.get('rest')).to_not include('fallback')
|
273
|
+
# end
|
274
|
+
# end
|
275
|
+
# describe 'Set to Rest Filter Post with body sprintf' do
|
276
|
+
# let(:config) do <<-CONFIG
|
277
|
+
# filter {
|
278
|
+
# rest {
|
279
|
+
# request => {
|
280
|
+
# url => 'https://jsonplaceholder.typicode.com/posts'
|
281
|
+
# method => 'post'
|
282
|
+
# body => {
|
283
|
+
# title => 'foo'
|
284
|
+
# body => 'bar'
|
285
|
+
# userId => "%{message}"
|
286
|
+
# }
|
287
|
+
# headers => {
|
288
|
+
# 'Content-Type' => 'application/json'
|
289
|
+
# }
|
290
|
+
# }
|
291
|
+
# json => true
|
292
|
+
# target => 'rest'
|
293
|
+
# }
|
294
|
+
# }
|
295
|
+
# CONFIG
|
296
|
+
# end
|
297
|
+
#
|
298
|
+
# sample('message' => '42') do
|
299
|
+
# expect(subject).to include('rest')
|
300
|
+
# expect(subject.get('rest')).to include('id')
|
301
|
+
# expect(subject.get('[rest][userId]')).to eq(42)
|
302
|
+
# expect(subject.get('rest')).to_not include('fallback')
|
303
|
+
# end
|
304
|
+
# end
|
305
|
+
# describe 'Set to Rest Filter Post with body sprintf nested params' do
|
306
|
+
# let(:config) do <<-CONFIG
|
307
|
+
# filter {
|
308
|
+
# rest {
|
309
|
+
# request => {
|
310
|
+
# url => 'https://jsonplaceholder.typicode.com/posts'
|
311
|
+
# method => 'post'
|
312
|
+
# body => {
|
313
|
+
# key1 => [
|
314
|
+
# {
|
315
|
+
# "filterType" => "text"
|
316
|
+
# "text" => "salmon"
|
317
|
+
# "boolean" => false
|
318
|
+
# },
|
319
|
+
# {
|
320
|
+
# "filterType" => "unique"
|
321
|
+
# }
|
322
|
+
# ]
|
323
|
+
# key2 => [
|
324
|
+
# {
|
325
|
+
# "message" => "123%{message}"
|
326
|
+
# "boolean" => true
|
327
|
+
# }
|
328
|
+
# ]
|
329
|
+
# key3 => [
|
330
|
+
# {
|
331
|
+
# "text" => "%{message}123"
|
332
|
+
# "filterType" => "text"
|
333
|
+
# "number" => 44
|
334
|
+
# },
|
335
|
+
# {
|
336
|
+
# "filterType" => "unique"
|
337
|
+
# "null" => nil
|
338
|
+
# }
|
339
|
+
# ]
|
340
|
+
# userId => "%{message}"
|
341
|
+
# }
|
342
|
+
# headers => {
|
343
|
+
# 'Content-Type' => 'application/json'
|
344
|
+
# }
|
345
|
+
# }
|
346
|
+
# target => 'rest'
|
347
|
+
# }
|
348
|
+
# }
|
349
|
+
# CONFIG
|
350
|
+
# end
|
351
|
+
#
|
352
|
+
# sample('message' => '42') do
|
353
|
+
# expect(subject).to include('rest')
|
354
|
+
# expect(subject.get('rest')).to include('key1')
|
355
|
+
# expect(subject.get('[rest][key1][0][boolean]')).to eq('false')
|
356
|
+
# expect(subject.get('[rest][key1][1][filterType]')).to eq('unique')
|
357
|
+
# expect(subject.get('[rest][key2][0][message]')).to eq('12342')
|
358
|
+
# expect(subject.get('[rest][key2][0][boolean]')).to eq('true')
|
359
|
+
# expect(subject.get('[rest][key3][0][text]')).to eq('42123')
|
360
|
+
# expect(subject.get('[rest][key3][0][filterType]')).to eq('text')
|
361
|
+
# expect(subject.get('[rest][key3][0][number]')).to eq(44)
|
362
|
+
# expect(subject.get('[rest][key3][1][filterType]')).to eq('unique')
|
363
|
+
# expect(subject.get('[rest][key3][1][null]')).to eq('nil')
|
364
|
+
# expect(subject.get('[rest][userId]')).to eq(42)
|
365
|
+
# expect(subject.get('rest')).to_not include('fallback')
|
366
|
+
# end
|
367
|
+
# end
|
368
|
+
# describe 'fallback' do
|
369
|
+
# let(:config) do <<-CONFIG
|
370
|
+
# filter {
|
371
|
+
# rest {
|
372
|
+
# request => {
|
373
|
+
# url => 'http://jsonplaceholder.typicode.com/users/0'
|
374
|
+
# }
|
375
|
+
# json => true
|
376
|
+
# fallback => {
|
377
|
+
# 'fallback1' => true
|
378
|
+
# 'fallback2' => true
|
379
|
+
# }
|
380
|
+
# target => 'rest'
|
381
|
+
# }
|
382
|
+
# }
|
383
|
+
# CONFIG
|
384
|
+
# end
|
385
|
+
#
|
386
|
+
# sample('message' => 'some text') do
|
387
|
+
# expect(subject).to include('rest')
|
388
|
+
# expect(subject.get('rest')).to include('fallback1')
|
389
|
+
# expect(subject.get('rest')).to include('fallback2')
|
390
|
+
# expect(subject.get('rest')).to_not include('id')
|
391
|
+
# end
|
392
|
+
# end
|
393
|
+
# describe 'empty target exception' do
|
394
|
+
# let(:config) do <<-CONFIG
|
395
|
+
# filter {
|
396
|
+
# rest {
|
397
|
+
# request => {
|
398
|
+
# url => 'http://jsonplaceholder.typicode.com/users/0'
|
399
|
+
# }
|
400
|
+
# json => true
|
401
|
+
# fallback => {
|
402
|
+
# 'fallback1' => true
|
403
|
+
# 'fallback2' => true
|
404
|
+
# }
|
405
|
+
# target => ''
|
406
|
+
# }
|
407
|
+
# }
|
408
|
+
# CONFIG
|
409
|
+
# end
|
410
|
+
# sample('message' => 'some text') do
|
411
|
+
# expect { subject }.to raise_error(LogStash::ConfigurationError)
|
412
|
+
# end
|
413
|
+
# end
|
414
|
+
# describe 'http client throws exception' do
|
415
|
+
# let(:config) do <<-CONFIG
|
416
|
+
# filter {
|
417
|
+
# rest {
|
418
|
+
# request => {
|
419
|
+
# url => 'invalid_url'
|
420
|
+
# }
|
421
|
+
# target => 'rest'
|
422
|
+
# }
|
423
|
+
# }
|
424
|
+
# CONFIG
|
425
|
+
# end
|
426
|
+
# sample('message' => 'some text') do
|
427
|
+
# expect(subject).to_not include('rest')
|
428
|
+
# expect(subject.get('tags')).to include('_restfailure')
|
429
|
+
# end
|
430
|
+
# end
|
406
431
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-filter-rest2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lucas Henning
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-
|
13
|
+
date: 2017-09-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|