logstash-filter-rest2 0.5.5 → 0.5.6
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 +5 -1
- data/logstash-filter-rest.gemspec +2 -2
- data/spec/filters/rest_spec.rb +381 -406
- metadata +10 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ab5b1d60c37832b9a11a67b2784b0b7de98c44634599f3d26e429a4b6ab5f12
|
4
|
+
data.tar.gz: 18b1e0aba93432f15a6f50802d7e9a5386159b274baeaeaeda5735e5176e002e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa63c876f7c13b3da5714d211f26176c4545bc7a97d9567aab881a41954fe0207ba0722e704a59912fcdfad76dc443b3eb2073861baee8e5f21962b1e25a845f
|
7
|
+
data.tar.gz: 88d7499efe89056b99aa273f688b98e1da4f8c1b5fe0d10d5c20f6ffb23d0e31a9430269bdaa7c48f6cd8ad70fed34e387129b5c91edbb2f62a3dc168ad62ff7
|
@@ -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.6'
|
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'
|
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
|
|
27
27
|
|
28
28
|
# Gem dependencies
|
29
29
|
s.add_runtime_dependency 'logstash-core-plugin-api', '>= 1.60', '<= 2.99'
|
30
|
-
s.add_runtime_dependency 'logstash-mixin-http_client', '>=
|
30
|
+
s.add_runtime_dependency 'logstash-mixin-http_client', '>= 5.0.0', '< 9.0.0'
|
31
31
|
|
32
32
|
s.add_development_dependency 'logstash-devutils', '>= 0', '< 2.0.0'
|
33
33
|
end
|
data/spec/filters/rest_spec.rb
CHANGED
@@ -7,12 +7,8 @@ describe LogStash::Filters::Rest do
|
|
7
7
|
filter {
|
8
8
|
rest {
|
9
9
|
request => {
|
10
|
-
url => '
|
11
|
-
truststore => "/var/app/ca2.jks"
|
12
|
-
truststore_password => "password"
|
10
|
+
url => 'http://jsonplaceholder.typicode.com/users/10'
|
13
11
|
}
|
14
|
-
# truststore => "/var/app/ca2.jks"
|
15
|
-
# truststore_password => "password1"
|
16
12
|
json => true
|
17
13
|
target => 'rest'
|
18
14
|
}
|
@@ -27,405 +23,384 @@ describe LogStash::Filters::Rest do
|
|
27
23
|
expect(subject.get('rest')).to_not include('fallback')
|
28
24
|
end
|
29
25
|
end
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
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
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
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
|
26
|
+
describe 'Set to Rest Filter Get without params custom target' do
|
27
|
+
let(:config) do <<-CONFIG
|
28
|
+
filter {
|
29
|
+
rest {
|
30
|
+
request => {
|
31
|
+
url => 'http://jsonplaceholder.typicode.com/users/10'
|
32
|
+
}
|
33
|
+
json => true
|
34
|
+
target => 'testing'
|
35
|
+
}
|
36
|
+
}
|
37
|
+
CONFIG
|
38
|
+
end
|
39
|
+
|
40
|
+
sample('message' => 'some text') do
|
41
|
+
expect(subject).to include('testing')
|
42
|
+
expect(subject.get('testing')).to include('id')
|
43
|
+
expect(subject.get('[testing][id]')).to eq(10)
|
44
|
+
expect(subject.get('testing')).to_not include('fallback')
|
45
|
+
end
|
46
|
+
end
|
47
|
+
describe 'Set to Rest Filter Get without params and sprintf' do
|
48
|
+
let(:config) do <<-CONFIG
|
49
|
+
filter {
|
50
|
+
rest {
|
51
|
+
request => {
|
52
|
+
url => "http://jsonplaceholder.typicode.com/users/%{message}"
|
53
|
+
}
|
54
|
+
json => true
|
55
|
+
sprintf => true
|
56
|
+
target => 'rest'
|
57
|
+
}
|
58
|
+
}
|
59
|
+
CONFIG
|
60
|
+
end
|
61
|
+
|
62
|
+
sample('message' => '10') do
|
63
|
+
expect(subject).to include('rest')
|
64
|
+
expect(subject.get('rest')).to include('id')
|
65
|
+
expect(subject.get('[rest][id]')).to eq(10)
|
66
|
+
expect(subject.get('rest')).to_not include('fallback')
|
67
|
+
end
|
68
|
+
sample('message' => '9') do
|
69
|
+
expect(subject).to include('rest')
|
70
|
+
expect(subject.get('rest')).to include('id')
|
71
|
+
expect(subject.get('[rest][id]')).to eq(9)
|
72
|
+
expect(subject.get('rest')).to_not include('fallback')
|
73
|
+
end
|
74
|
+
end
|
75
|
+
describe 'Set to Rest Filter Get without params http error' do
|
76
|
+
let(:config) do <<-CONFIG
|
77
|
+
filter {
|
78
|
+
rest {
|
79
|
+
request => {
|
80
|
+
url => 'http://httpstat.us/404'
|
81
|
+
}
|
82
|
+
json => true
|
83
|
+
target => 'rest'
|
84
|
+
}
|
85
|
+
}
|
86
|
+
CONFIG
|
87
|
+
end
|
88
|
+
|
89
|
+
sample('message' => 'some text') do
|
90
|
+
expect(subject).to_not include('rest')
|
91
|
+
expect(subject.get('tags')).to include('_restfailure')
|
92
|
+
end
|
93
|
+
end
|
94
|
+
describe 'Set to Rest Filter Get with params' do
|
95
|
+
let(:config) do <<-CONFIG
|
96
|
+
filter {
|
97
|
+
rest {
|
98
|
+
request => {
|
99
|
+
url => 'https://jsonplaceholder.typicode.com/posts'
|
100
|
+
params => {
|
101
|
+
userId => 10
|
102
|
+
}
|
103
|
+
headers => {
|
104
|
+
'Content-Type' => 'application/json'
|
105
|
+
}
|
106
|
+
}
|
107
|
+
json => true
|
108
|
+
target => 'rest'
|
109
|
+
}
|
110
|
+
}
|
111
|
+
CONFIG
|
112
|
+
end
|
113
|
+
|
114
|
+
sample('message' => 'some text') do
|
115
|
+
expect(subject).to include('rest')
|
116
|
+
expect(subject.get('[rest][0]')).to include('userId')
|
117
|
+
expect(subject.get('[rest][0][userId]')).to eq(10)
|
118
|
+
expect(subject.get('rest')).to_not include('fallback')
|
119
|
+
end
|
120
|
+
end
|
121
|
+
describe 'empty response' do
|
122
|
+
let(:config) do <<-CONFIG
|
123
|
+
filter {
|
124
|
+
rest {
|
125
|
+
request => {
|
126
|
+
url => 'https://jsonplaceholder.typicode.com/posts'
|
127
|
+
params => {
|
128
|
+
userId => 0
|
129
|
+
}
|
130
|
+
headers => {
|
131
|
+
'Content-Type' => 'application/json'
|
132
|
+
}
|
133
|
+
}
|
134
|
+
target => 'rest'
|
135
|
+
}
|
136
|
+
}
|
137
|
+
CONFIG
|
138
|
+
end
|
139
|
+
|
140
|
+
sample('message' => 'some text') do
|
141
|
+
expect(subject).to_not include('rest')
|
142
|
+
expect(subject.get('tags')).to include('_restfailure')
|
143
|
+
end
|
144
|
+
end
|
145
|
+
describe 'Set to Rest Filter Get with params sprintf' do
|
146
|
+
let(:config) do <<-CONFIG
|
147
|
+
filter {
|
148
|
+
rest {
|
149
|
+
request => {
|
150
|
+
url => 'https://jsonplaceholder.typicode.com/posts'
|
151
|
+
params => {
|
152
|
+
userId => "%{message}"
|
153
|
+
id => "%{message}"
|
154
|
+
}
|
155
|
+
headers => {
|
156
|
+
'Content-Type' => 'application/json'
|
157
|
+
}
|
158
|
+
}
|
159
|
+
json => true
|
160
|
+
target => 'rest'
|
161
|
+
}
|
162
|
+
}
|
163
|
+
CONFIG
|
164
|
+
end
|
165
|
+
|
166
|
+
sample('message' => '1') do
|
167
|
+
expect(subject).to include('rest')
|
168
|
+
expect(subject.get('[rest][0]')).to include('userId')
|
169
|
+
expect(subject.get('[rest][0][userId]')).to eq(1)
|
170
|
+
expect(subject.get('[rest][0][id]')).to eq(1)
|
171
|
+
expect(subject.get('rest').length).to eq(1)
|
172
|
+
expect(subject.get('rest')).to_not include('fallback')
|
173
|
+
end
|
174
|
+
end
|
175
|
+
describe 'Set to Rest Filter Post with params' do
|
176
|
+
let(:config) do <<-CONFIG
|
177
|
+
filter {
|
178
|
+
rest {
|
179
|
+
request => {
|
180
|
+
url => 'https://jsonplaceholder.typicode.com/posts'
|
181
|
+
method => 'post'
|
182
|
+
params => {
|
183
|
+
title => 'foo'
|
184
|
+
body => 'bar'
|
185
|
+
userId => 42
|
186
|
+
}
|
187
|
+
headers => {
|
188
|
+
'Content-Type' => 'application/json'
|
189
|
+
}
|
190
|
+
}
|
191
|
+
json => true
|
192
|
+
target => 'rest'
|
193
|
+
}
|
194
|
+
}
|
195
|
+
CONFIG
|
196
|
+
end
|
197
|
+
|
198
|
+
sample('message' => 'some text') do
|
199
|
+
expect(subject).to include('rest')
|
200
|
+
expect(subject.get('rest')).to include('id')
|
201
|
+
expect(subject.get('[rest][userId]')).to eq(42)
|
202
|
+
expect(subject.get('rest')).to_not include('fallback')
|
203
|
+
end
|
204
|
+
end
|
205
|
+
describe 'Set to Rest Filter Post with params sprintf' do
|
206
|
+
let(:config) do <<-CONFIG
|
207
|
+
filter {
|
208
|
+
rest {
|
209
|
+
request => {
|
210
|
+
url => 'https://jsonplaceholder.typicode.com/posts'
|
211
|
+
method => 'post'
|
212
|
+
params => {
|
213
|
+
title => '%{message}'
|
214
|
+
body => 'bar'
|
215
|
+
userId => "%{message}"
|
216
|
+
}
|
217
|
+
headers => {
|
218
|
+
'Content-Type' => 'application/json'
|
219
|
+
}
|
220
|
+
}
|
221
|
+
json => true
|
222
|
+
target => 'rest'
|
223
|
+
}
|
224
|
+
}
|
225
|
+
CONFIG
|
226
|
+
end
|
227
|
+
|
228
|
+
sample('message' => '42') do
|
229
|
+
expect(subject).to include('rest')
|
230
|
+
expect(subject.get('rest')).to include('id')
|
231
|
+
expect(subject.get('[rest][title]')).to eq(42)
|
232
|
+
expect(subject.get('[rest][userId]')).to eq(42)
|
233
|
+
expect(subject.get('rest')).to_not include('fallback')
|
234
|
+
end
|
235
|
+
sample('message' => ':5e?#!-_') do
|
236
|
+
expect(subject).to include('rest')
|
237
|
+
expect(subject.get('rest')).to include('id')
|
238
|
+
expect(subject.get('[rest][title]')).to eq(':5e?#!-_')
|
239
|
+
expect(subject.get('[rest][userId]')).to eq(':5e?#!-_')
|
240
|
+
expect(subject.get('rest')).to_not include('fallback')
|
241
|
+
end
|
242
|
+
sample('message' => ':4c43=>') do
|
243
|
+
expect(subject).to include('rest')
|
244
|
+
expect(subject.get('rest')).to include('id')
|
245
|
+
expect(subject.get('[rest][title]')).to eq(':4c43=>')
|
246
|
+
expect(subject.get('[rest][userId]')).to eq(':4c43=>')
|
247
|
+
expect(subject.get('rest')).to_not include('fallback')
|
248
|
+
end
|
249
|
+
end
|
250
|
+
describe 'Set to Rest Filter Post with body sprintf' do
|
251
|
+
let(:config) do <<-CONFIG
|
252
|
+
filter {
|
253
|
+
rest {
|
254
|
+
request => {
|
255
|
+
url => 'https://jsonplaceholder.typicode.com/posts'
|
256
|
+
method => 'post'
|
257
|
+
body => {
|
258
|
+
title => 'foo'
|
259
|
+
body => 'bar'
|
260
|
+
userId => "%{message}"
|
261
|
+
}
|
262
|
+
headers => {
|
263
|
+
'Content-Type' => 'application/json'
|
264
|
+
}
|
265
|
+
}
|
266
|
+
json => true
|
267
|
+
target => 'rest'
|
268
|
+
}
|
269
|
+
}
|
270
|
+
CONFIG
|
271
|
+
end
|
272
|
+
|
273
|
+
sample('message' => '42') do
|
274
|
+
expect(subject).to include('rest')
|
275
|
+
expect(subject.get('rest')).to include('id')
|
276
|
+
expect(subject.get('[rest][userId]')).to eq(42)
|
277
|
+
expect(subject.get('rest')).to_not include('fallback')
|
278
|
+
end
|
279
|
+
end
|
280
|
+
describe 'Set to Rest Filter Post with body sprintf nested params' do
|
281
|
+
let(:config) do <<-CONFIG
|
282
|
+
filter {
|
283
|
+
rest {
|
284
|
+
request => {
|
285
|
+
url => 'https://jsonplaceholder.typicode.com/posts'
|
286
|
+
method => 'post'
|
287
|
+
body => {
|
288
|
+
key1 => [
|
289
|
+
{
|
290
|
+
"filterType" => "text"
|
291
|
+
"text" => "salmon"
|
292
|
+
"boolean" => false
|
293
|
+
},
|
294
|
+
{
|
295
|
+
"filterType" => "unique"
|
296
|
+
}
|
297
|
+
]
|
298
|
+
key2 => [
|
299
|
+
{
|
300
|
+
"message" => "123%{message}"
|
301
|
+
"boolean" => true
|
302
|
+
}
|
303
|
+
]
|
304
|
+
key3 => [
|
305
|
+
{
|
306
|
+
"text" => "%{message}123"
|
307
|
+
"filterType" => "text"
|
308
|
+
"number" => 44
|
309
|
+
},
|
310
|
+
{
|
311
|
+
"filterType" => "unique"
|
312
|
+
"null" => nil
|
313
|
+
}
|
314
|
+
]
|
315
|
+
userId => "%{message}"
|
316
|
+
}
|
317
|
+
headers => {
|
318
|
+
'Content-Type' => 'application/json'
|
319
|
+
}
|
320
|
+
}
|
321
|
+
target => 'rest'
|
322
|
+
}
|
323
|
+
}
|
324
|
+
CONFIG
|
325
|
+
end
|
326
|
+
|
327
|
+
sample('message' => '42') do
|
328
|
+
expect(subject).to include('rest')
|
329
|
+
expect(subject.get('rest')).to include('key1')
|
330
|
+
expect(subject.get('[rest][key1][0][boolean]')).to eq('false')
|
331
|
+
expect(subject.get('[rest][key1][1][filterType]')).to eq('unique')
|
332
|
+
expect(subject.get('[rest][key2][0][message]')).to eq('12342')
|
333
|
+
expect(subject.get('[rest][key2][0][boolean]')).to eq('true')
|
334
|
+
expect(subject.get('[rest][key3][0][text]')).to eq('42123')
|
335
|
+
expect(subject.get('[rest][key3][0][filterType]')).to eq('text')
|
336
|
+
expect(subject.get('[rest][key3][0][number]')).to eq(44)
|
337
|
+
expect(subject.get('[rest][key3][1][filterType]')).to eq('unique')
|
338
|
+
expect(subject.get('[rest][key3][1][null]')).to eq('nil')
|
339
|
+
expect(subject.get('[rest][userId]')).to eq(42)
|
340
|
+
expect(subject.get('rest')).to_not include('fallback')
|
341
|
+
end
|
342
|
+
end
|
343
|
+
describe 'fallback' do
|
344
|
+
let(:config) do <<-CONFIG
|
345
|
+
filter {
|
346
|
+
rest {
|
347
|
+
request => {
|
348
|
+
url => 'http://jsonplaceholder.typicode.com/users/0'
|
349
|
+
}
|
350
|
+
json => true
|
351
|
+
fallback => {
|
352
|
+
'fallback1' => true
|
353
|
+
'fallback2' => true
|
354
|
+
}
|
355
|
+
target => 'rest'
|
356
|
+
}
|
357
|
+
}
|
358
|
+
CONFIG
|
359
|
+
end
|
360
|
+
|
361
|
+
sample('message' => 'some text') do
|
362
|
+
expect(subject).to include('rest')
|
363
|
+
expect(subject.get('rest')).to include('fallback1')
|
364
|
+
expect(subject.get('rest')).to include('fallback2')
|
365
|
+
expect(subject.get('rest')).to_not include('id')
|
366
|
+
end
|
367
|
+
end
|
368
|
+
describe 'empty target exception' 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 => ''
|
381
|
+
}
|
382
|
+
}
|
383
|
+
CONFIG
|
384
|
+
end
|
385
|
+
sample('message' => 'some text') do
|
386
|
+
expect { subject }.to raise_error(LogStash::ConfigurationError)
|
387
|
+
end
|
388
|
+
end
|
389
|
+
describe 'http client throws exception' do
|
390
|
+
let(:config) do <<-CONFIG
|
391
|
+
filter {
|
392
|
+
rest {
|
393
|
+
request => {
|
394
|
+
url => 'invalid_url'
|
395
|
+
}
|
396
|
+
target => 'rest'
|
397
|
+
}
|
398
|
+
}
|
399
|
+
CONFIG
|
400
|
+
end
|
401
|
+
sample('message' => 'some text') do
|
402
|
+
expect(subject).to_not include('rest')
|
403
|
+
expect(subject.get('tags')).to include('_restfailure')
|
404
|
+
end
|
405
|
+
end
|
431
406
|
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.6
|
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:
|
13
|
+
date: 2020-03-03 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
@@ -22,8 +22,8 @@ dependencies:
|
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: '2.99'
|
24
24
|
name: logstash-core-plugin-api
|
25
|
-
prerelease: false
|
26
25
|
type: :runtime
|
26
|
+
prerelease: false
|
27
27
|
version_requirements: !ruby/object:Gem::Requirement
|
28
28
|
requirements:
|
29
29
|
- - ">="
|
@@ -37,21 +37,21 @@ dependencies:
|
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 5.0.0
|
41
41
|
- - "<"
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
43
|
+
version: 9.0.0
|
44
44
|
name: logstash-mixin-http_client
|
45
|
-
prerelease: false
|
46
45
|
type: :runtime
|
46
|
+
prerelease: false
|
47
47
|
version_requirements: !ruby/object:Gem::Requirement
|
48
48
|
requirements:
|
49
49
|
- - ">="
|
50
50
|
- !ruby/object:Gem::Version
|
51
|
-
version:
|
51
|
+
version: 5.0.0
|
52
52
|
- - "<"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 9.0.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
@@ -62,8 +62,8 @@ dependencies:
|
|
62
62
|
- !ruby/object:Gem::Version
|
63
63
|
version: 2.0.0
|
64
64
|
name: logstash-devutils
|
65
|
-
prerelease: false
|
66
65
|
type: :development
|
66
|
+
prerelease: false
|
67
67
|
version_requirements: !ruby/object:Gem::Requirement
|
68
68
|
requirements:
|
69
69
|
- - ">="
|
@@ -109,8 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
requirements: []
|
112
|
-
|
113
|
-
rubygems_version: 2.6.11
|
112
|
+
rubygems_version: 3.0.6
|
114
113
|
signing_key:
|
115
114
|
specification_version: 4
|
116
115
|
summary: This filter requests data from a RESTful Web Service.
|