logstash-filter-kv 2.1.0 → 3.0.0

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: 63ffef94da43256770287a0a3f1e25791617f74a
4
- data.tar.gz: e36145dfaf5d8184e4dd7d60418c9c36dcfab319
3
+ metadata.gz: ce56ac9539711025a45de58bdac21db2b31cc422
4
+ data.tar.gz: 10efa6007a01d8489895835362d3d30ba9c3fa07
5
5
  SHA512:
6
- metadata.gz: f7bd945d5df9b1eaae90b399910612d5236c8ff0bcf55ab4feedbe87995e39a0dcb09cccc3139a6afd2dafdaf998ed1ed02625f31a957e76cae812285fc72780
7
- data.tar.gz: ff374c0ac7d74d7c2f3f772a28481c89122cc21fcac883843a4873475c508d71f31e85eec0aac4a11baa947ea9a624e3bfbcfbfaf8128f6ded14c5082271681b
6
+ metadata.gz: 5d9e9c20fb456e6030793b40e88ddc2e82a94c46f72caafb2a27945d574bd5d976caabffb01520f1cffdd9c7780d49304d4c26e7939c8269d5e514c6c6459d41
7
+ data.tar.gz: cf72c8ae0888c2e6a69c9ce0644929ed93b409b76b1ac849fe646a951819ca515adf8179f76ac10ef62de274d9de0d1d16b635ac7194b5151b09995bca2b2c69
data/CHANGELOG.md CHANGED
@@ -1,6 +1,5 @@
1
- # 2.1.0
2
- - Adds :transform_value and :transform_key options to lowercase/upcase or capitalize all keys/values
3
-
1
+ ## 3.0.0
2
+ - Update the plugin to the version 2.0 of the plugin api, this change is required for Logstash 5.0 compatibility. See https://github.com/elastic/logstash/issues/5141
4
3
  # 2.0.7
5
4
  - With include_brackets enabled, angle brackets (\< and \>) are treated the same as square brackets and parentheses, making it easy to parse strings like "a=\<b\> c=\<d\>".
6
5
  - An empty value_split option value now gives a useful error message.
data/Gemfile CHANGED
@@ -1,2 +1,4 @@
1
1
  source 'https://rubygems.org'
2
- gemspec
2
+
3
+ # Specify your gem's dependencies in logstash-mass_effect.gemspec
4
+ gemspec
@@ -29,11 +29,6 @@ require "logstash/namespace"
29
29
  class LogStash::Filters::KV < LogStash::Filters::Base
30
30
  config_name "kv"
31
31
 
32
- # Constants used for transform check
33
- TRANSFORM_LOWERCASE_KEY = "lowercase"
34
- TRANSFORM_UPPERCASE_KEY = "uppercase"
35
- TRANSFORM_CAPITALIZE_KEY = "capitalize"
36
-
37
32
  # A string of characters to trim from the value. This is useful if your
38
33
  # values are wrapped in brackets or are terminated with commas (like postfix
39
34
  # logs).
@@ -65,28 +60,6 @@ class LogStash::Filters::KV < LogStash::Filters::Base
65
60
  # }
66
61
  config :trimkey, :validate => :string
67
62
 
68
- # Transform values to lower case, upper case or capitals.
69
- #
70
- # For example, to capitalize all values:
71
- # [source,ruby]
72
- # filter {
73
- # kv {
74
- # transform_value => "capitalize"
75
- # }
76
- # }
77
- config :transform_value, :validate => [TRANSFORM_LOWERCASE_KEY, TRANSFORM_UPPERCASE_KEY, TRANSFORM_CAPITALIZE_KEY]
78
-
79
- # Transform keys to lower case, upper case or capitals.
80
- #
81
- # For example, to lowercase all keys:
82
- # [source,ruby]
83
- # filter {
84
- # kv {
85
- # transform_key => "lowercase"
86
- # }
87
- # }
88
- config :transform_key, :validate => [TRANSFORM_LOWERCASE_KEY, TRANSFORM_UPPERCASE_KEY, TRANSFORM_CAPITALIZE_KEY]
89
-
90
63
  # A string of characters to use as delimiters for parsing out key-value pairs.
91
64
  #
92
65
  # These characters form a regex character class and thus you must escape special regex
@@ -262,7 +235,7 @@ class LogStash::Filters::KV < LogStash::Filters::Base
262
235
 
263
236
  def filter(event)
264
237
  kv = Hash.new
265
- value = event[@source]
238
+ value = event.get(@source)
266
239
 
267
240
  case value
268
241
  when nil
@@ -282,9 +255,9 @@ class LogStash::Filters::KV < LogStash::Filters::Base
282
255
 
283
256
  if @target
284
257
  @logger.debug? && @logger.debug("Overwriting existing target field", :target => @target)
285
- event[@target] = kv
258
+ event.set(@target, kv)
286
259
  else
287
- kv.each{|k, v| event[k] = v}
260
+ kv.each{|k, v| event.set(k, v)}
288
261
  end
289
262
 
290
263
  filter_matched(event)
@@ -296,17 +269,6 @@ class LogStash::Filters::KV < LogStash::Filters::Base
296
269
  s =~ @value_split_re
297
270
  end
298
271
 
299
- def transform(text, method)
300
- case method
301
- when TRANSFORM_LOWERCASE_KEY
302
- return text.downcase
303
- when TRANSFORM_UPPERCASE_KEY
304
- return text.upcase
305
- when TRANSFORM_CAPITALIZE_KEY
306
- return text.capitalize
307
- end
308
- end
309
-
310
272
  def parse(text, event, kv_keys)
311
273
  # short circuit parsing if the text does not contain the @value_split
312
274
  return kv_keys unless has_value_splitter?(text)
@@ -318,7 +280,6 @@ class LogStash::Filters::KV < LogStash::Filters::Base
318
280
  text.scan(@scan_re) do |key, v1, v2, v3, v4, v5, v6|
319
281
  value = v1 || v2 || v3 || v4 || v5 || v6
320
282
  key = @trimkey ? key.gsub(@trimkey_re, "") : key
321
- key = @transform_key ? transform(key, @transform_key) : key
322
283
 
323
284
  # Bail out as per the values of include_keys and exclude_keys
324
285
  next if not include_keys.empty? and not include_keys.include?(key)
@@ -328,7 +289,6 @@ class LogStash::Filters::KV < LogStash::Filters::Base
328
289
  key = event.sprintf(@prefix) + key
329
290
 
330
291
  value = @trim ? value.gsub(@trim_re, "") : value
331
- value = @transform_value ? transform(value, @transform_value) : value
332
292
 
333
293
  # Bail out if inserting duplicate value in key mapping when unique_values
334
294
  # option is set to true.
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-filter-kv'
4
- s.version = '2.1.0'
4
+ s.version = '3.0.0'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "This filter helps automatically parse messages (or specific event fields) which are of the 'foo=bar' variety."
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"
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.metadata = { "logstash_plugin" => "true", "logstash_group" => "filter" }
21
21
 
22
22
  # Gem dependencies
23
- s.add_runtime_dependency "logstash-core-plugin-api", "~> 1.0"
23
+ s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0"
24
24
 
25
25
  s.add_development_dependency 'logstash-devutils'
26
26
  end
@@ -15,74 +15,14 @@ describe LogStash::Filters::KV do
15
15
  CONFIG
16
16
 
17
17
  sample "hello=world foo=bar baz=fizz doublequoted=\"hello world\" singlequoted='hello world' bracketsone=(hello world) bracketstwo=[hello world] bracketsthree=<hello world>" do
18
- insist { subject["hello"] } == "world"
19
- insist { subject["foo"] } == "bar"
20
- insist { subject["baz"] } == "fizz"
21
- insist { subject["doublequoted"] } == "hello world"
22
- insist { subject["singlequoted"] } == "hello world"
23
- insist { subject["bracketsone"] } == "hello world"
24
- insist { subject["bracketstwo"] } == "hello world"
25
- insist { subject["bracketsthree"] } == "hello world"
26
- end
27
- end
28
-
29
- describe "test transforming keys to uppercase and values to lowercase" do
30
- config <<-CONFIG
31
- filter {
32
- kv {
33
- transform_key => "uppercase"
34
- transform_value => "lowercase"
35
- }
36
- }
37
- CONFIG
38
-
39
- sample "hello = world Foo =Bar BAZ= FIZZ doublequoteD = \"hellO worlD\" Singlequoted= 'Hello World' brAckets =(hello World)" do
40
- insist { subject["HELLO"] } == "world"
41
- insist { subject["FOO"] } == "bar"
42
- insist { subject["BAZ"] } == "fizz"
43
- insist { subject["DOUBLEQUOTED"] } == "hello world"
44
- insist { subject["SINGLEQUOTED"] } == "hello world"
45
- insist { subject["BRACKETS"] } == "hello world"
46
- end
47
- end
48
-
49
- describe "test transforming keys to lowercase and values to uppercase" do
50
- config <<-CONFIG
51
- filter {
52
- kv {
53
- transform_key => "lowercase"
54
- transform_value => "uppercase"
55
- }
56
- }
57
- CONFIG
58
-
59
- sample "Hello = World fOo =bar baz= FIZZ DOUBLEQUOTED = \"hellO worlD\" singlequoted= 'hEllo wOrld' brackets =(HELLO world)" do
60
- insist { subject["hello"] } == "WORLD"
61
- insist { subject["foo"] } == "BAR"
62
- insist { subject["baz"] } == "FIZZ"
63
- insist { subject["doublequoted"] } == "HELLO WORLD"
64
- insist { subject["singlequoted"] } == "HELLO WORLD"
65
- insist { subject["brackets"] } == "HELLO WORLD"
66
- end
67
- end
68
-
69
- describe "test transforming keys and values to capitals" do
70
- config <<-CONFIG
71
- filter {
72
- kv {
73
- transform_key => "capitalize"
74
- transform_value => "capitalize"
75
- }
76
- }
77
- CONFIG
78
-
79
- sample "Hello = World fOo =bar baz= FIZZ DOUBLEQUOTED = \"hellO worlD\" singlequoted= 'hEllo wOrld' brackets =(HELLO world)" do
80
- insist { subject["Hello"] } == "World"
81
- insist { subject["Foo"] } == "Bar"
82
- insist { subject["Baz"] } == "Fizz"
83
- insist { subject["Doublequoted"] } == "Hello world"
84
- insist { subject["Singlequoted"] } == "Hello world"
85
- insist { subject["Brackets"] } == "Hello world"
18
+ insist { subject.get("hello") } == "world"
19
+ insist { subject.get("foo") } == "bar"
20
+ insist { subject.get("baz") } == "fizz"
21
+ insist { subject.get("doublequoted") } == "hello world"
22
+ insist { subject.get("singlequoted") } == "hello world"
23
+ insist { subject.get("bracketsone") } == "hello world"
24
+ insist { subject.get("bracketstwo") } == "hello world"
25
+ insist { subject.get("bracketsthree") } == "hello world"
86
26
  end
87
27
  end
88
28
 
@@ -94,12 +34,12 @@ describe LogStash::Filters::KV do
94
34
  CONFIG
95
35
 
96
36
  sample "hello = world foo =bar baz= fizz doublequoted = \"hello world\" singlequoted= 'hello world' brackets =(hello world)" do
97
- insist { subject["hello"] } == "world"
98
- insist { subject["foo"] } == "bar"
99
- insist { subject["baz"] } == "fizz"
100
- insist { subject["doublequoted"] } == "hello world"
101
- insist { subject["singlequoted"] } == "hello world"
102
- insist { subject["brackets"] } == "hello world"
37
+ insist { subject.get("hello") } == "world"
38
+ insist { subject.get("foo") } == "bar"
39
+ insist { subject.get("baz") } == "fizz"
40
+ insist { subject.get("doublequoted") } == "hello world"
41
+ insist { subject.get("singlequoted") } == "hello world"
42
+ insist { subject.get("brackets") } == "hello world"
103
43
  end
104
44
  end
105
45
 
@@ -111,8 +51,8 @@ describe LogStash::Filters::KV do
111
51
  CONFIG
112
52
 
113
53
  sample 'IKE:=Quick\ Mode\ completion IKE\ IDs:=subnet:\ x.x.x.x\ (mask=\ 255.255.255.254)\ and\ host:\ y.y.y.y' do
114
- insist { subject["IKE"] } == '=Quick\ Mode\ completion'
115
- insist { subject['IKE\ IDs'] } == '=subnet:\ x.x.x.x\ (mask=\ 255.255.255.254)\ and\ host:\ y.y.y.y'
54
+ insist { subject.get("IKE") } == '=Quick\ Mode\ completion'
55
+ insist { subject.get('IKE\ IDs') } == '=subnet:\ x.x.x.x\ (mask=\ 255.255.255.254)\ and\ host:\ y.y.y.y'
116
56
  end
117
57
  end
118
58
 
@@ -125,12 +65,12 @@ describe LogStash::Filters::KV do
125
65
  CONFIG
126
66
 
127
67
  sample "hello:=world foo:bar baz=:fizz doublequoted:\"hello world\" singlequoted:'hello world' brackets:(hello world)" do
128
- insist { subject["hello"] } == "=world"
129
- insist { subject["foo"] } == "bar"
130
- insist { subject["baz="] } == "fizz"
131
- insist { subject["doublequoted"] } == "hello world"
132
- insist { subject["singlequoted"] } == "hello world"
133
- insist { subject["brackets"] } == "hello world"
68
+ insist { subject.get("hello") } == "=world"
69
+ insist { subject.get("foo") } == "bar"
70
+ insist { subject.get("baz=") } == "fizz"
71
+ insist { subject.get("doublequoted") } == "hello world"
72
+ insist { subject.get("singlequoted") } == "hello world"
73
+ insist { subject.get("brackets") } == "hello world"
134
74
  end
135
75
  end
136
76
  end
@@ -177,7 +117,7 @@ describe LogStash::Filters::KV do
177
117
 
178
118
  it "should extract kv" do
179
119
  subject.filter(event)
180
- expect(event["foo"]).to eq(inner)
120
+ expect(event.get("foo")).to eq(inner)
181
121
  end
182
122
 
183
123
  it "should short circuit" do
@@ -198,8 +138,8 @@ describe LogStash::Filters::KV do
198
138
 
199
139
  it "should extract kv" do
200
140
  subject.filter(event)
201
- expect(event["foo"]).to eq(foo_val)
202
- expect(event["[bar][baz]"]).to eq(baz_val)
141
+ expect(event.get("foo")).to eq(foo_val)
142
+ expect(event.get("[bar][baz]")).to eq(baz_val)
203
143
  end
204
144
 
205
145
  it "should short circuit" do
@@ -229,12 +169,12 @@ describe LogStash::Filters::KV do
229
169
  CONFIG
230
170
 
231
171
  sample "?hello=world&foo=bar&baz=fizz&doublequoted=\"hello world\"&singlequoted='hello world'&ignoreme&foo12=bar12" do
232
- insist { subject["hello"] } == "world"
233
- insist { subject["foo"] } == "bar"
234
- insist { subject["baz"] } == "fizz"
235
- insist { subject["doublequoted"] } == "hello world"
236
- insist { subject["singlequoted"] } == "hello world"
237
- insist { subject["foo12"] } == "bar12"
172
+ insist { subject.get("hello") } == "world"
173
+ insist { subject.get("foo") } == "bar"
174
+ insist { subject.get("baz") } == "fizz"
175
+ insist { subject.get("doublequoted") } == "hello world"
176
+ insist { subject.get("singlequoted") } == "hello world"
177
+ insist { subject.get("foo12") } == "bar12"
238
178
  end
239
179
  end
240
180
 
@@ -246,8 +186,8 @@ describe LogStash::Filters::KV do
246
186
  CONFIG
247
187
 
248
188
  sample "bracketsone=(hello world) bracketstwo=[hello world]" do
249
- insist { subject["bracketsone"] } == "(hello"
250
- insist { subject["bracketstwo"] } == "[hello"
189
+ insist { subject.get("bracketsone") } == "(hello"
190
+ insist { subject.get("bracketstwo") } == "[hello"
251
191
  end
252
192
  end
253
193
 
@@ -261,10 +201,10 @@ describe LogStash::Filters::KV do
261
201
  CONFIG
262
202
 
263
203
  sample 'IKE="Quick Mode completion" IKE\ IDs = (subnet= x.x.x.x mask= 255.255.255.254 and host=y.y.y.y)' do
264
- insist { subject["IKE"] } == 'Quick Mode completion'
265
- insist { subject['IKE\ IDs']['subnet'] } == 'x.x.x.x'
266
- insist { subject['IKE\ IDs']['mask'] } == '255.255.255.254'
267
- insist { subject['IKE\ IDs']['host'] } == 'y.y.y.y'
204
+ insist { subject.get("IKE") } == 'Quick Mode completion'
205
+ insist { subject.get('IKE\ IDs')['subnet'] } == 'x.x.x.x'
206
+ insist { subject.get('IKE\ IDs')['mask'] } == '255.255.255.254'
207
+ insist { subject.get('IKE\ IDs')['host'] } == 'y.y.y.y'
268
208
  end
269
209
  end
270
210
 
@@ -276,9 +216,9 @@ describe LogStash::Filters::KV do
276
216
  CONFIG
277
217
 
278
218
  sample "field1=test|field2=another test|field3=test3" do
279
- insist { subject["field1"] } == "test"
280
- insist { subject["field2"] } == "another test"
281
- insist { subject["field3"] } == "test3"
219
+ insist { subject.get("field1") } == "test"
220
+ insist { subject.get("field2") } == "another test"
221
+ insist { subject.get("field3") } == "test3"
282
222
  end
283
223
  end
284
224
 
@@ -290,11 +230,11 @@ describe LogStash::Filters::KV do
290
230
  CONFIG
291
231
 
292
232
  sample "hello=world foo=bar baz=fizz doublequoted=\"hello world\" singlequoted='hello world'" do
293
- insist { subject["__hello"] } == "world"
294
- insist { subject["__foo"] } == "bar"
295
- insist { subject["__baz"] } == "fizz"
296
- insist { subject["__doublequoted"] } == "hello world"
297
- insist { subject["__singlequoted"] } == "hello world"
233
+ insist { subject.get("__hello") } == "world"
234
+ insist { subject.get("__foo") } == "bar"
235
+ insist { subject.get("__baz") } == "fizz"
236
+ insist { subject.get("__doublequoted") } == "hello world"
237
+ insist { subject.get("__singlequoted") } == "hello world"
298
238
  end
299
239
 
300
240
  end
@@ -335,8 +275,8 @@ describe LogStash::Filters::KV do
335
275
  CONFIG
336
276
 
337
277
  sample "hello=world" do
338
- insist { subject["hello"] } == "world"
339
- insist { subject["tags"] }.include?("hello")
278
+ insist { subject.get("hello") } == "world"
279
+ insist { subject.get("tags") }.include?("hello")
340
280
  end
341
281
  end
342
282
  context "should not activate when failing" do
@@ -347,7 +287,7 @@ describe LogStash::Filters::KV do
347
287
  CONFIG
348
288
 
349
289
  sample "this is not key value" do
350
- insist { subject["tags"] }.nil?
290
+ insist { subject.get("tags") }.nil?
351
291
  end
352
292
  end
353
293
  end
@@ -361,8 +301,8 @@ describe LogStash::Filters::KV do
361
301
  CONFIG
362
302
 
363
303
  sample "hello=world" do
364
- insist { subject["hello"] } == "world"
365
- insist { subject["whoa"] } == "fancypants"
304
+ insist { subject.get("hello") } == "world"
305
+ insist { subject.get("whoa") } == "fancypants"
366
306
  end
367
307
  end
368
308
 
@@ -374,7 +314,7 @@ describe LogStash::Filters::KV do
374
314
  CONFIG
375
315
 
376
316
  sample "this is not key value" do
377
- reject { subject["whoa"] } == "fancypants"
317
+ reject { subject.get("whoa") } == "fancypants"
378
318
  end
379
319
  end
380
320
  end
@@ -388,12 +328,12 @@ describe LogStash::Filters::KV do
388
328
  CONFIG
389
329
 
390
330
  sample "hello=world foo=bar baz=fizz doublequoted=\"hello world\" singlequoted='hello world'" do
391
- insist { subject["kv"]["hello"] } == "world"
392
- insist { subject["kv"]["foo"] } == "bar"
393
- insist { subject["kv"]["baz"] } == "fizz"
394
- insist { subject["kv"]["doublequoted"] } == "hello world"
395
- insist { subject["kv"]["singlequoted"] } == "hello world"
396
- insist {subject["kv"].count } == 5
331
+ insist { subject.get("kv")["hello"] } == "world"
332
+ insist { subject.get("kv")["foo"] } == "bar"
333
+ insist { subject.get("kv")["baz"] } == "fizz"
334
+ insist { subject.get("kv")["doublequoted"] } == "hello world"
335
+ insist { subject.get("kv")["singlequoted"] } == "hello world"
336
+ insist {subject.get("kv").count } == 5
397
337
  end
398
338
 
399
339
  end
@@ -406,7 +346,7 @@ describe LogStash::Filters::KV do
406
346
  CONFIG
407
347
 
408
348
  sample "hello:world:foo:bar:baz:fizz" do
409
- insist { subject["kv"] } == nil
349
+ insist { subject.get("kv") } == nil
410
350
  end
411
351
  end
412
352
 
@@ -420,11 +360,11 @@ describe LogStash::Filters::KV do
420
360
  }
421
361
  CONFIG
422
362
  sample("data" => "hello=world foo=bar baz=fizz doublequoted=\"hello world\" singlequoted='hello world'") do
423
- insist { subject["hello"] } == "world"
424
- insist { subject["foo"] } == "bar"
425
- insist { subject["baz"] } == "fizz"
426
- insist { subject["doublequoted"] } == "hello world"
427
- insist { subject["singlequoted"] } == "hello world"
363
+ insist { subject.get("hello") } == "world"
364
+ insist { subject.get("foo") } == "bar"
365
+ insist { subject.get("baz") } == "fizz"
366
+ insist { subject.get("doublequoted") } == "hello world"
367
+ insist { subject.get("singlequoted") } == "hello world"
428
368
  end
429
369
  end
430
370
 
@@ -437,11 +377,11 @@ describe LogStash::Filters::KV do
437
377
  }
438
378
  CONFIG
439
379
  sample({"@data" => "hello=world foo=bar baz=fizz doublequoted=\"hello world\" singlequoted='hello world'"}) do
440
- insist { subject["hello"] } == "world"
441
- insist { subject["foo"] } == "bar"
442
- insist { subject["baz"] } == "fizz"
443
- insist { subject["doublequoted"] } == "hello world"
444
- insist { subject["singlequoted"] } == "hello world"
380
+ insist { subject.get("hello") } == "world"
381
+ insist { subject.get("foo") } == "bar"
382
+ insist { subject.get("baz") } == "fizz"
383
+ insist { subject.get("doublequoted") } == "hello world"
384
+ insist { subject.get("singlequoted") } == "hello world"
445
385
  end
446
386
  end
447
387
 
@@ -456,12 +396,12 @@ describe LogStash::Filters::KV do
456
396
  }
457
397
  CONFIG
458
398
  sample("data" => "hello=world foo=bar baz=fizz doublequoted=\"hello world\" singlequoted='hello world'") do
459
- insist { subject["kv"]["hello"] } == "world"
460
- insist { subject["kv"]["foo"] } == "bar"
461
- insist { subject["kv"]["baz"] } == "fizz"
462
- insist { subject["kv"]["doublequoted"] } == "hello world"
463
- insist { subject["kv"]["singlequoted"] } == "hello world"
464
- insist { subject["kv"].count } == 5
399
+ insist { subject.get("kv")["hello"] } == "world"
400
+ insist { subject.get("kv")["foo"] } == "bar"
401
+ insist { subject.get("kv")["baz"] } == "fizz"
402
+ insist { subject.get("kv")["doublequoted"] } == "hello world"
403
+ insist { subject.get("kv")["singlequoted"] } == "hello world"
404
+ insist { subject.get("kv").count } == 5
465
405
  end
466
406
  end
467
407
 
@@ -475,8 +415,8 @@ describe LogStash::Filters::KV do
475
415
  }
476
416
  CONFIG
477
417
  sample "" do
478
- insist { subject["non-exisiting-field"] } == nil
479
- insist { subject["kv"] } == nil
418
+ insist { subject.get("non-exisiting-field") } == nil
419
+ insist { subject.get("kv") } == nil
480
420
  end
481
421
  end
482
422
 
@@ -490,8 +430,8 @@ describe LogStash::Filters::KV do
490
430
  CONFIG
491
431
 
492
432
  sample "hello=world foo=bar baz=fizz doublequoted=\"hello world\" singlequoted='hello world'" do
493
- insist { subject["foo"] } == "bar"
494
- insist { subject["singlequoted"] } == "hello world"
433
+ insist { subject.get("foo") } == "bar"
434
+ insist { subject.get("singlequoted") } == "hello world"
495
435
  end
496
436
  end
497
437
 
@@ -505,9 +445,9 @@ describe LogStash::Filters::KV do
505
445
  CONFIG
506
446
 
507
447
  sample "hello=world foo=bar baz=fizz doublequoted=\"hello world\" singlequoted='hello world'" do
508
- insist { subject["hello"] } == "world"
509
- insist { subject["baz"] } == "fizz"
510
- insist { subject["doublequoted"] } == "hello world"
448
+ insist { subject.get("hello") } == "world"
449
+ insist { subject.get("baz") } == "fizz"
450
+ insist { subject.get("doublequoted") } == "hello world"
511
451
  end
512
452
  end
513
453
 
@@ -522,8 +462,8 @@ describe LogStash::Filters::KV do
522
462
  CONFIG
523
463
 
524
464
  sample "hello=world foo=bar baz=fizz doublequoted=\"hello world\" singlequoted='hello world'" do
525
- insist { subject["__foo"] } == "bar"
526
- insist { subject["__singlequoted"] } == "hello world"
465
+ insist { subject.get("__foo") } == "bar"
466
+ insist { subject.get("__singlequoted") } == "hello world"
527
467
  end
528
468
  end
529
469
 
@@ -538,9 +478,9 @@ describe LogStash::Filters::KV do
538
478
  CONFIG
539
479
 
540
480
  sample "hello=world foo=bar baz=fizz doublequoted=\"hello world\" singlequoted='hello world'" do
541
- insist { subject["__hello"] } == "world"
542
- insist { subject["__baz"] } == "fizz"
543
- insist { subject["__doublequoted"] } == "hello world"
481
+ insist { subject.get("__hello") } == "world"
482
+ insist { subject.get("__baz") } == "fizz"
483
+ insist { subject.get("__doublequoted") } == "hello world"
544
484
  end
545
485
  end
546
486
 
@@ -555,8 +495,8 @@ describe LogStash::Filters::KV do
555
495
  CONFIG
556
496
 
557
497
  sample({"data" => "foo=bar baz=fizz", "key" => "foo"}) do
558
- insist { subject["foo"] } == "bar"
559
- insist { subject["baz"] } == nil
498
+ insist { subject.get("foo") } == "bar"
499
+ insist { subject.get("baz") } == nil
560
500
  end
561
501
  end
562
502
 
@@ -571,8 +511,8 @@ describe LogStash::Filters::KV do
571
511
  CONFIG
572
512
 
573
513
  sample({"data" => "foo=bar baz=fizz", "key" => "foo"}) do
574
- insist { subject["foo"] } == nil
575
- insist { subject["baz"] } == "fizz"
514
+ insist { subject.get("foo") } == nil
515
+ insist { subject.get("baz") } == "fizz"
576
516
  end
577
517
  end
578
518
 
@@ -605,12 +545,12 @@ describe LogStash::Filters::KV do
605
545
  CONFIG
606
546
 
607
547
  sample "hello=world foo=bar baz=fizz doublequoted=\"hello world\" singlequoted='hello world'" do
608
- insist { subject["hello"] } == "world"
609
- insist { subject["foo"] } == "bar"
610
- insist { subject["goo"] } == "yyy"
611
- insist { subject["baz"] } == "fizz"
612
- insist { subject["doublequoted"] } == "hello world"
613
- insist { subject["singlequoted"] } == "hello world"
548
+ insist { subject.get("hello") } == "world"
549
+ insist { subject.get("foo") } == "bar"
550
+ insist { subject.get("goo") } == "yyy"
551
+ insist { subject.get("baz") } == "fizz"
552
+ insist { subject.get("doublequoted") } == "hello world"
553
+ insist { subject.get("singlequoted") } == "hello world"
614
554
  end
615
555
  end
616
556
 
@@ -625,8 +565,8 @@ describe LogStash::Filters::KV do
625
565
  CONFIG
626
566
 
627
567
  sample("happy" => "foo=bar baz=fizz") do
628
- insist { subject["[happy][foo]"] } == "bar"
629
- insist { subject["[happy][baz]"] } == "fizz"
568
+ insist { subject.get("[happy][foo]") } == "bar"
569
+ insist { subject.get("[happy][baz]") } == "fizz"
630
570
  end
631
571
 
632
572
  end
@@ -643,7 +583,7 @@ describe LogStash::Filters::KV do
643
583
  CONFIG
644
584
 
645
585
  sample("source" => "foo=bar&foo=yeah&foo=yeah") do
646
- insist { subject["[foo]"] } == ["bar", "yeah"]
586
+ insist { subject.get("[foo]") } == ["bar", "yeah"]
647
587
  end
648
588
  end
649
589
 
@@ -658,7 +598,7 @@ describe LogStash::Filters::KV do
658
598
  CONFIG
659
599
 
660
600
  sample("source" => "foo=bar&foo=yeah&foo=yeah") do
661
- insist { subject["[foo]"] } == ["bar", "yeah", "yeah"]
601
+ insist { subject.get("[foo]") } == ["bar", "yeah", "yeah"]
662
602
  end
663
603
  end
664
604
 
@@ -683,8 +623,8 @@ describe LogStash::Filters::KV do
683
623
  context "key and splitters with no value" do
684
624
  it "should ignore the incomplete key/value pairs" do
685
625
  subject.filter(event)
686
- expect(event["AccountStatus"]).to eq("4")
687
- expect(event["IsSuccess"]).to eq("True")
626
+ expect(event.get("AccountStatus")).to eq("4")
627
+ expect(event.get("IsSuccess")).to eq("True")
688
628
  expect(event.to_hash.keys.sort).to eq(
689
629
  ["@timestamp", "@version", "AccountStatus", "IsSuccess", "message"])
690
630
  end
metadata CHANGED
@@ -1,44 +1,46 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-kv
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-20 00:00:00.000000000 Z
11
+ date: 2016-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
+ name: logstash-core-plugin-api
14
15
  requirement: !ruby/object:Gem::Requirement
15
16
  requirements:
16
17
  - - "~>"
17
18
  - !ruby/object:Gem::Version
18
- version: '1.0'
19
- name: logstash-core-plugin-api
20
- prerelease: false
19
+ version: '2.0'
21
20
  type: :runtime
21
+ prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.0'
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
+ name: logstash-devutils
28
29
  requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
31
  - - ">="
31
32
  - !ruby/object:Gem::Version
32
33
  version: '0'
33
- name: logstash-devutils
34
- prerelease: false
35
34
  type: :development
35
+ prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- 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
41
+ description: This gem is a Logstash plugin required to be installed on top of the
42
+ Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This
43
+ gem is not a stand-alone program
42
44
  email: info@elastic.co
43
45
  executables: []
44
46
  extensions: []
@@ -59,7 +61,7 @@ licenses:
59
61
  metadata:
60
62
  logstash_plugin: 'true'
61
63
  logstash_group: filter
62
- post_install_message:
64
+ post_install_message:
63
65
  rdoc_options: []
64
66
  require_paths:
65
67
  - lib
@@ -74,10 +76,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
76
  - !ruby/object:Gem::Version
75
77
  version: '0'
76
78
  requirements: []
77
- rubyforge_project:
78
- rubygems_version: 2.6.3
79
- signing_key:
79
+ rubyforge_project:
80
+ rubygems_version: 2.5.1
81
+ signing_key:
80
82
  specification_version: 4
81
- summary: This filter helps automatically parse messages (or specific event fields) which are of the 'foo=bar' variety.
83
+ summary: This filter helps automatically parse messages (or specific event fields)
84
+ which are of the 'foo=bar' variety.
82
85
  test_files:
83
86
  - spec/filters/kv_spec.rb