logstash-filter-mutate 2.0.6 → 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: 588da888ef1e6f77a5323cd5fc8c94b3d68aa540
4
- data.tar.gz: d33b28c9a9d15130e487f98918bb586b01ffbca7
3
+ metadata.gz: e8a9a7858c32b9ce0cf4e80fd730c07ae5eb7a8d
4
+ data.tar.gz: 66572edaf0428f5a9e46ff5c5128aa2c7db57082
5
5
  SHA512:
6
- metadata.gz: a09e52b31e882563480ac9741045f894cecf44ea8cd7bb5942d07a26c593fc4efcaba50ba38a825df2b428f260259847bfa6d78e422028ed1db9d419ed851fb6
7
- data.tar.gz: 61e714ee16a7bb5d706bd7e3dbb1abf9373b9a08e8c60a0851e6689d37ef2305dedf8018a32d697b046472b166a763f25055e5c29a6d96ec19af3cf8fbbe8bdf
6
+ metadata.gz: 0d610945c97138b48f308d349d614f105ad6c22624034fd92080642ea48102fbd2dbff71877c86067da25940a1ae7a99d249ae4fde2d9ecd3568de7809be557e
7
+ data.tar.gz: 6408f6f8caba5f0754ec09a82534c32e44c351fbd692fdc7fcb2dfc921e66afc1dac5d87eb6b1a11ad6c48e934b1f564e0fb2593ceb29bfe8661587d8a1e77cb
data/CHANGELOG.md CHANGED
@@ -1,3 +1,5 @@
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
1
3
  # 2.0.6
2
4
  - [Internal] Temp fix for patterns path in tests
3
5
  # 2.0.5
data/Gemfile CHANGED
@@ -1,2 +1,4 @@
1
1
  source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in logstash-mass_effect.gemspec
2
4
  gemspec
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012–2015 Elasticsearch <http://www.elastic.co>
1
+ Copyright (c) 2012–2016 Elasticsearch <http://www.elastic.co>
2
2
 
3
3
  Licensed under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License.
data/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # Logstash Plugin
2
2
 
3
- [![Build
4
- Status](http://build-eu-00.elastic.co/view/LS%20Plugins/view/LS%20Filters/job/logstash-plugin-filter-mutate-unit/badge/icon)](http://build-eu-00.elastic.co/view/LS%20Plugins/view/LS%20Filters/job/logstash-plugin-filter-mutate-unit/)
3
+ [![Travis Build Status](https://travis-ci.org/logstash-plugins/logstash-filter-mutate.svg)](https://travis-ci.org/logstash-plugins/logstash-filter-mutate)
5
4
 
6
5
  This is a plugin for [Logstash](https://github.com/elastic/logstash).
7
6
 
@@ -56,7 +55,12 @@ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
56
55
  ```
57
56
  - Install plugin
58
57
  ```sh
58
+ # Logstash 2.3 and higher
59
+ bin/logstash-plugin install --no-verify
60
+
61
+ # Prior to Logstash 2.3
59
62
  bin/plugin install --no-verify
63
+
60
64
  ```
61
65
  - Run Logstash with your plugin
62
66
  ```sh
@@ -74,7 +78,12 @@ gem build logstash-filter-awesome.gemspec
74
78
  ```
75
79
  - Install the plugin from the Logstash home
76
80
  ```sh
77
- bin/plugin install /your/local/plugin/logstash-filter-awesome.gem
81
+ # Logstash 2.3 and higher
82
+ bin/logstash-plugin install --no-verify
83
+
84
+ # Prior to Logstash 2.3
85
+ bin/plugin install --no-verify
86
+
78
87
  ```
79
88
  - Start Logstash and proceed to test the plugin
80
89
 
@@ -244,27 +244,27 @@ class LogStash::Filters::Mutate < LogStash::Filters::Base
244
244
  old = event.sprintf(old)
245
245
  new = event.sprintf(new)
246
246
  next unless event.include?(old)
247
- event[new] = event.remove(old)
247
+ event.set(new, event.remove(old))
248
248
  end
249
249
  end
250
250
 
251
251
  def update(event)
252
252
  @update.each do |field, newvalue|
253
253
  next unless event.include?(field)
254
- event[field] = event.sprintf(newvalue)
254
+ event.set(field, event.sprintf(newvalue))
255
255
  end
256
256
  end
257
257
 
258
258
  def replace(event)
259
259
  @replace.each do |field, newvalue|
260
- event[field] = event.sprintf(newvalue)
260
+ event.set(field, event.sprintf(newvalue))
261
261
  end
262
262
  end
263
263
 
264
264
  def convert(event)
265
265
  @convert.each do |field, type|
266
266
  next unless event.include?(field)
267
- original = event[field]
267
+ original = event.get(field)
268
268
  # calls convert_{string,integer,float,boolean} depending on type requested.
269
269
  converter = method(CONVERT_PREFIX + type)
270
270
 
@@ -272,11 +272,11 @@ class LogStash::Filters::Mutate < LogStash::Filters::Base
272
272
  when Hash
273
273
  @logger.debug? && @logger.debug("I don't know how to type convert a hash, skipping", :field => field, :value => original)
274
274
  when Array
275
- event[field] = original.map { |v| converter.call(v) }
275
+ event.set(field, original.map { |v| converter.call(v) })
276
276
  when NilClass
277
277
  # ignore
278
278
  else
279
- event[field] = converter.call(original)
279
+ event.set(field, converter.call(original))
280
280
  end
281
281
  end
282
282
  end
@@ -313,10 +313,10 @@ class LogStash::Filters::Mutate < LogStash::Filters::Base
313
313
  needle = config[:needle]
314
314
  replacement = config[:replacement]
315
315
 
316
- value = event[field]
316
+ value = event.get(field)
317
317
  case value
318
318
  when Array
319
- event[field] = value.map do |v|
319
+ result = value.map do |v|
320
320
  if v.is_a?(String)
321
321
  gsub_dynamic_fields(event, v, needle, replacement)
322
322
  else
@@ -324,10 +324,11 @@ class LogStash::Filters::Mutate < LogStash::Filters::Base
324
324
  v
325
325
  end
326
326
  end
327
+ event.set(field, result)
327
328
  when String
328
- event[field] = gsub_dynamic_fields(event, value, needle, replacement)
329
+ event.set(field, gsub_dynamic_fields(event, value, needle, replacement))
329
330
  else
330
- @logger.debug? && @logger.debug("gsub mutation is only applicable for Strings, skipping", :field => field, :value => event[field])
331
+ @logger.debug? && @logger.debug("gsub mutation is only applicable for Strings, skipping", :field => field, :value => event.get(field))
331
332
  end
332
333
  end
333
334
  end
@@ -343,32 +344,33 @@ class LogStash::Filters::Mutate < LogStash::Filters::Base
343
344
 
344
345
  def uppercase(event)
345
346
  @uppercase.each do |field|
346
- original = event[field]
347
+ original = event.get(field)
347
348
  # in certain cases JRuby returns a proxy wrapper of the event[field] value
348
349
  # therefore we can't assume that we are modifying the actual value behind
349
350
  # the key so read, modify and overwrite
350
- event[field] = case original
351
- when Array
352
- # can't map upcase! as it replaces an already upcase value with nil
353
- # ["ABCDEF"].map(&:upcase!) => [nil]
354
- original.map do |elem|
355
- (elem.is_a?(String) ? elem.upcase : elem)
351
+ result = case original
352
+ when Array
353
+ # can't map upcase! as it replaces an already upcase value with nil
354
+ # ["ABCDEF"].map(&:upcase!) => [nil]
355
+ original.map do |elem|
356
+ (elem.is_a?(String) ? elem.upcase : elem)
357
+ end
358
+ when String
359
+ # nil means no change was made to the String
360
+ original.upcase! || original
361
+ else
362
+ @logger.debug? && @logger.debug("Can't uppercase something that isn't a string", :field => field, :value => original)
363
+ original
356
364
  end
357
- when String
358
- # nil means no change was made to the String
359
- original.upcase! || original
360
- else
361
- @logger.debug? && @logger.debug("Can't uppercase something that isn't a string", :field => field, :value => original)
362
- original
363
- end
365
+ event.set(field, result)
364
366
  end
365
367
  end
366
368
 
367
369
  def lowercase(event)
368
370
  #see comments for #uppercase
369
371
  @lowercase.each do |field|
370
- original = event[field]
371
- event[field] = case original
372
+ original = event.get(field)
373
+ result = case original
372
374
  when Array
373
375
  original.map! do |elem|
374
376
  (elem.is_a?(String) ? elem.downcase : elem)
@@ -379,37 +381,38 @@ class LogStash::Filters::Mutate < LogStash::Filters::Base
379
381
  @logger.debug? && @logger.debug("Can't lowercase something that isn't a string", :field => field, :value => original)
380
382
  original
381
383
  end
384
+ event.set(field, result)
382
385
  end
383
386
  end
384
387
 
385
388
  def split(event)
386
389
  @split.each do |field, separator|
387
- value = event[field]
390
+ value = eventget(field)
388
391
  if value.is_a?(String)
389
- event[field] = value.split(separator)
392
+ event.set(field, value.split(separator))
390
393
  else
391
- @logger.debug? && @logger.debug("Can't split something that isn't a string", :field => field, :value => event[field])
394
+ @logger.debug? && @logger.debug("Can't split something that isn't a string", :field => field, :value => event.get(field))
392
395
  end
393
396
  end
394
397
  end
395
398
 
396
399
  def join(event)
397
400
  @join.each do |field, separator|
398
- value = event[field]
401
+ value = event.get(field)
399
402
  if value.is_a?(Array)
400
- event[field] = value.join(separator)
403
+ event.set(field, value.join(separator))
401
404
  end
402
405
  end
403
406
  end
404
407
 
405
408
  def strip(event)
406
409
  @strip.each do |field|
407
- value = event[field]
410
+ value = event.get(field)
408
411
  case value
409
412
  when Array
410
- event[field] = value.map{|s| s.strip }
413
+ event.set(field, value.map{|s| s.strip })
411
414
  when String
412
- event[field] = value.strip
415
+ event.set(field, value.strip)
413
416
  end
414
417
  end
415
418
  end
@@ -418,10 +421,10 @@ class LogStash::Filters::Mutate < LogStash::Filters::Base
418
421
  @merge.each do |dest_field, added_fields|
419
422
  # When multiple calls, added_field is an array
420
423
 
421
- dest_field_value = event[dest_field]
424
+ dest_field_value = event.get(dest_field)
422
425
 
423
426
  Array(added_fields).each do |added_field|
424
- added_field_value = event[added_field]
427
+ added_field_value = event.get(added_field)
425
428
 
426
429
  if dest_field_value.is_a?(Hash) ^ added_field_value.is_a?(Hash)
427
430
  @logger.error("Not possible to merge an array and a hash: ", :dest_field => dest_field, :added_field => added_field )
@@ -433,15 +436,14 @@ class LogStash::Filters::Mutate < LogStash::Filters::Base
433
436
  # do not use event[dest_field].update because the returned object from event[dest_field]
434
437
  # can/will be a copy of the actual event data and directly updating it will not update
435
438
  # the Event internal data. The updated value must be reassigned in the Event.
436
- event[dest_field] = dest_field_value.update(added_field_value)
439
+ event.set(dest_field, dest_field_value.update(added_field_value))
437
440
  else
438
441
  # do not use event[dest_field].concat because the returned object from event[dest_field]
439
442
  # can/will be a copy of the actual event data and directly updating it will not update
440
443
  # the Event internal data. The updated value must be reassigned in the Event.
441
- event[dest_field] = Array(dest_field_value).concat(Array(added_field_value))
444
+ event.set(dest_field, Array(dest_field_value).concat(Array(added_field_value)))
442
445
  end
443
446
  end
444
447
  end
445
448
  end
446
-
447
449
  end
@@ -1,17 +1,17 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-filter-mutate'
4
- s.version = '2.0.6'
4
+ s.version = '3.0.0'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "The mutate filter allows you to perform general mutations on fields. You can rename, remove, replace, and modify fields in your events."
7
- 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
+ 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"
8
8
  s.authors = ["Elastic"]
9
9
  s.email = 'info@elastic.co'
10
10
  s.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html"
11
11
  s.require_paths = ["lib"]
12
12
 
13
13
  # Files
14
- s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
14
+ s.files = Dir['lib/**/*','spec/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
15
15
 
16
16
  # Tests
17
17
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
@@ -20,8 +20,8 @@ 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"
24
- s.add_runtime_dependency 'logstash-patterns-core'
25
- s.add_runtime_dependency 'logstash-filter-grok'
26
- s.add_development_dependency 'logstash-devutils'
23
+ s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0"
24
+ s.add_development_dependency "logstash-patterns-core"
25
+ s.add_development_dependency "logstash-filter-grok"
26
+ s.add_development_dependency "logstash-devutils"
27
27
  end
@@ -54,17 +54,17 @@ CONFIG
54
54
 
55
55
  it 'change case of the target, bar value is lowercase' do
56
56
  result = results.first
57
- expect(result["bar"]).to eq('world')
57
+ expect(result.get("bar")).to eq('world')
58
58
  end
59
59
 
60
60
  it 'change case of the target, lower1 value is lowercase' do
61
61
  result = results.first
62
- expect(result["lower1"]).to eq("ppqqrrss")
62
+ expect(result.get("lower1")).to eq("ppqqrrss")
63
63
  end
64
64
 
65
65
  it 'change case of the target, lower2 value is lowercase' do
66
66
  result = results.first
67
- expect(result["lower2"]).to eq("pppqqq")
67
+ expect(result.get("lower2")).to eq("pppqqq")
68
68
  end
69
69
 
70
70
  end
@@ -50,7 +50,7 @@ describe LogStash::Filters::Mutate do
50
50
 
51
51
  it "should convert only string elements" do
52
52
  subject.filter(event)
53
- expect(event["array_of"]).to eq(["A", 2, "C"])
53
+ expect(event.get("array_of")).to eq(["A", 2, "C"])
54
54
  end
55
55
  end
56
56
 
@@ -68,7 +68,7 @@ describe LogStash::Filters::Mutate do
68
68
 
69
69
  it "should convert only string elements" do
70
70
  subject.filter(event)
71
- expect(event["array_of"]).to eq(["a", 2, "c"])
71
+ expect(event.get("array_of")).to eq(["a", 2, "c"])
72
72
  end
73
73
  end
74
74
 
@@ -96,7 +96,7 @@ describe LogStash::Filters::Mutate do
96
96
 
97
97
  it "should cleam trailing spaces" do
98
98
  subject.filter(event)
99
- expect(event["path"]).to eq("/store.php")
99
+ expect(event.get("path")).to eq("/store.php")
100
100
  end
101
101
 
102
102
  context "when converting multiple attributed at once" do
@@ -109,8 +109,8 @@ describe LogStash::Filters::Mutate do
109
109
 
110
110
  it "should cleam trailing spaces" do
111
111
  subject.filter(event)
112
- expect(event["foo"]).to eq("/bar.php")
113
- expect(event["bar"]).to eq("foo")
112
+ expect(event.get("foo")).to eq("/bar.php")
113
+ expect(event.get("bar")).to eq("foo")
114
114
  end
115
115
  end
116
116
  end
@@ -181,22 +181,22 @@ describe LogStash::Filters::Mutate do
181
181
  }
182
182
 
183
183
  sample event do
184
- expect(subject["lowerme"]).to eq 'example'
185
- expect(subject["upperme"]).to eq 'EXAMPLE'
186
- expect(subject["Lowerme"]).to eq 'example'
187
- expect(subject["Upperme"]).to eq 'EXAMPLE'
188
- expect(subject["lowerMe"]).to eq ['example', 'example']
189
- expect(subject["upperMe"]).to eq ['EXAMPLE', 'EXAMPLE']
190
- expect(subject["intme"] ).to eq [1234, 7890, 7]
191
- expect(subject["floatme"]).to eq [1234.455]
184
+ expect(subject.get("lowerme")).to eq 'example'
185
+ expect(subject.get("upperme")).to eq 'EXAMPLE'
186
+ expect(subject.get("Lowerme")).to eq 'example'
187
+ expect(subject.get("Upperme")).to eq 'EXAMPLE'
188
+ expect(subject.get("lowerMe")).to eq ['example', 'example']
189
+ expect(subject.get("upperMe")).to eq ['EXAMPLE', 'EXAMPLE']
190
+ expect(subject.get("intme") ).to eq [1234, 7890, 7]
191
+ expect(subject.get("floatme")).to eq [1234.455]
192
192
  expect(subject).not_to include("rename1")
193
- expect(subject["rename2"]).to eq [ "hello world" ]
193
+ expect(subject.get("rename2")).to eq [ "hello world" ]
194
194
  expect(subject).not_to include("removeme")
195
195
 
196
196
  expect(subject).to include("newfield")
197
- expect(subject["newfield"]).to eq "newnew"
197
+ expect(subject.get("newfield")).to eq "newnew"
198
198
  expect(subject).not_to include("nosuchfield")
199
- expect(subject["updateme"]).to eq "updated"
199
+ expect(subject.get("updateme")).to eq "updated"
200
200
  end
201
201
  end
202
202
 
@@ -217,8 +217,8 @@ describe LogStash::Filters::Mutate do
217
217
 
218
218
  sample event do
219
219
  # ATM, only the ASCII characters will case change
220
- expect(subject["lowerme"]).to eq [ "АБВГД\0mmm", "こにちわ", "xyzółć", "nÎcË gÛŸ"]
221
- expect(subject["upperme"]).to eq [ "аБвгд\0MMM", "こにちわ", "XYZółć", "NîCë Gûÿ"]
220
+ expect(subject.get("lowerme")).to eq [ "АБВГД\0mmm", "こにちわ", "xyzółć", "nÎcË gÛŸ"]
221
+ expect(subject.get("upperme")).to eq [ "аБвгд\0MMM", "こにちわ", "XYZółć", "NîCë Gûÿ"]
222
222
  end
223
223
  end
224
224
 
@@ -237,12 +237,12 @@ describe LogStash::Filters::Mutate do
237
237
  "survivor" => "Hello.",
238
238
  "one" => { "two" => "wee" }
239
239
  ) do
240
- expect(subject["survivor"]).to eq "Hello."
240
+ expect(subject.get("survivor")).to eq "Hello."
241
241
 
242
242
  expect(subject).not_to include("remove-me")
243
243
  expect(subject).not_to include("remove-me2")
244
244
  expect(subject).not_to include("diedie")
245
- expect(subject["one"]).not_to include("two")
245
+ expect(subject.get("one")).not_to include("two")
246
246
  end
247
247
  end
248
248
 
@@ -257,10 +257,10 @@ describe LogStash::Filters::Mutate do
257
257
  sample(
258
258
  "abc" => "def"
259
259
  ) do
260
- insist { subject["abc"] } == "def"
260
+ insist { subject.get("abc") } == "def"
261
261
  end
262
262
  end
263
-
263
+
264
264
 
265
265
  describe "remove with dynamic fields (%{})" do
266
266
  config '
@@ -287,7 +287,7 @@ describe LogStash::Filters::Mutate do
287
287
  }'
288
288
 
289
289
  sample("unicorns" => 1234) do
290
- expect(subject["unicorns"]).to eq "1234"
290
+ expect(subject.get("unicorns")).to eq "1234"
291
291
  end
292
292
  end
293
293
 
@@ -323,17 +323,17 @@ describe LogStash::Filters::Mutate do
323
323
  "wrong_field" => "none of the above"
324
324
  }
325
325
  sample event do
326
- expect(subject["true_field"] ).to eq(true)
327
- expect(subject["false_field"]).to eq(false)
328
- expect(subject["true_upper"] ).to eq(true)
329
- expect(subject["false_upper"]).to eq(false)
330
- expect(subject["true_one"] ).to eq(true)
331
- expect(subject["false_zero"] ).to eq(false)
332
- expect(subject["true_yes"] ).to eq(true)
333
- expect(subject["false_no"] ).to eq(false)
334
- expect(subject["true_y"] ).to eq(true)
335
- expect(subject["false_n"] ).to eq(false)
336
- expect(subject["wrong_field"]).to eq("none of the above")
326
+ expect(subject.get("true_field") ).to eq(true)
327
+ expect(subject.get("false_field")).to eq(false)
328
+ expect(subject.get("true_upper") ).to eq(true)
329
+ expect(subject.get("false_upper")).to eq(false)
330
+ expect(subject.get("true_one") ).to eq(true)
331
+ expect(subject.get("false_zero") ).to eq(false)
332
+ expect(subject.get("true_yes") ).to eq(true)
333
+ expect(subject.get("false_no") ).to eq(false)
334
+ expect(subject.get("true_y") ).to eq(true)
335
+ expect(subject.get("false_n") ).to eq(false)
336
+ expect(subject.get("wrong_field")).to eq("none of the above")
337
337
  end
338
338
  end
339
339
 
@@ -346,7 +346,7 @@ describe LogStash::Filters::Mutate do
346
346
  }'
347
347
 
348
348
  sample("unicorns" => "Magnificient, but extinct, animals") do
349
- expect(subject["unicorns"]).to eq "Magnificient, and common, animals"
349
+ expect(subject.get("unicorns")).to eq "Magnificient, and common, animals"
350
350
  end
351
351
  end
352
352
 
@@ -361,7 +361,7 @@ describe LogStash::Filters::Mutate do
361
361
  sample("unicorns" => [
362
362
  "Magnificient extinct animals", "Other extinct ideas" ]
363
363
  ) do
364
- expect(subject["unicorns"]).to eq [
364
+ expect(subject.get("unicorns")).to eq [
365
365
  "Magnificient common animals",
366
366
  "Other common ideas"
367
367
  ]
@@ -378,8 +378,8 @@ describe LogStash::Filters::Mutate do
378
378
  }'
379
379
 
380
380
  sample("colors" => "One red car", "shapes" => "Four red squares") do
381
- expect(subject["colors"]).to eq "One blue car"
382
- expect(subject["shapes"]).to eq "Four red circles"
381
+ expect(subject.get("colors")).to eq "One blue car"
382
+ expect(subject.get("shapes")).to eq "Four red circles"
383
383
  end
384
384
  end
385
385
 
@@ -392,7 +392,7 @@ describe LogStash::Filters::Mutate do
392
392
  }'
393
393
 
394
394
  sample("colors" => "red3") do
395
- expect(subject["colors"]).to eq "redblue"
395
+ expect(subject.get("colors")).to eq "redblue"
396
396
  end
397
397
  end
398
398
 
@@ -409,7 +409,7 @@ describe LogStash::Filters::Mutate do
409
409
  CONFIG
410
410
 
411
411
  sample "HELLO WORLD" do
412
- expect(subject["foo"]).to eq "hello"
412
+ expect(subject.get("foo")).to eq "hello"
413
413
  end
414
414
  end
415
415
 
@@ -468,8 +468,8 @@ describe LogStash::Filters::Mutate do
468
468
  CONFIG
469
469
 
470
470
  sample({ "foo" => { "bar" => "1000" } }) do
471
- expect(subject["[foo][bar]"]).to eq 1000
472
- expect(subject["[foo][bar]"]).to be_a(Fixnum)
471
+ expect(subject.get("[foo][bar]")).to eq 1000
472
+ expect(subject.get("[foo][bar]")).to be_a(Fixnum)
473
473
  end
474
474
  end
475
475
 
@@ -483,8 +483,8 @@ describe LogStash::Filters::Mutate do
483
483
  CONFIG
484
484
 
485
485
  sample({ "foo" => ["100", "200"] }) do
486
- expect(subject["[foo][0]"]).to eq 100
487
- expect(subject["[foo][0]"]).to be_a(Fixnum)
486
+ expect(subject.get("[foo][0]")).to eq 100
487
+ expect(subject.get("[foo][0]")).to be_a(Fixnum)
488
488
  end
489
489
  end
490
490
 
@@ -498,7 +498,7 @@ describe LogStash::Filters::Mutate do
498
498
  }'
499
499
 
500
500
  sample("unicorns" => "Unicorns of type blue are common", "unicorn_type" => "blue") do
501
- expect(subject["unicorns"]).to eq "Unicorns green are common"
501
+ expect(subject.get("unicorns")).to eq "Unicorns green are common"
502
502
  end
503
503
  end
504
504
 
@@ -512,7 +512,7 @@ describe LogStash::Filters::Mutate do
512
512
  }'
513
513
 
514
514
  sample("unicorns2" => "Unicorns of type blue are common", "unicorn_color" => "blue") do
515
- expect(subject["unicorns2"]).to eq "Unicorns blue and green are common"
515
+ expect(subject.get("unicorns2")).to eq "Unicorns blue and green are common"
516
516
  end
517
517
  end
518
518
 
@@ -529,7 +529,7 @@ describe LogStash::Filters::Mutate do
529
529
  "Unicorns of type blue are found in Alaska", "Unicorns of type blue are extinct" ],
530
530
  "color" => "blue"
531
531
  ) do
532
- expect(subject["unicorns_array"]).to eq [
532
+ expect(subject.get("unicorns_array")).to eq [
533
533
  "Unicorns blue and green are found in Alaska",
534
534
  "Unicorns blue and green are extinct"
535
535
  ]
@@ -545,8 +545,8 @@ describe LogStash::Filters::Mutate do
545
545
  }'
546
546
 
547
547
  sample("foo" => "bar") do
548
- expect(subject["list"]).to eq ["bar"]
549
- expect(subject["foo"]).to eq "bar"
548
+ expect(subject.get("list")).to eq ["bar"]
549
+ expect(subject.get("foo")).to eq "bar"
550
550
  end
551
551
  end
552
552
 
@@ -559,8 +559,8 @@ describe LogStash::Filters::Mutate do
559
559
  }'
560
560
 
561
561
  sample("foo" => "bar", "list" => []) do
562
- expect(subject["list"]).to eq ["bar"]
563
- expect(subject["foo"]).to eq "bar"
562
+ expect(subject.get("list")).to eq ["bar"]
563
+ expect(subject.get("foo")).to eq "bar"
564
564
  end
565
565
  end
566
566
 
@@ -573,8 +573,8 @@ describe LogStash::Filters::Mutate do
573
573
  }'
574
574
 
575
575
  sample("foo" => "bar", "list" => ["baz"]) do
576
- expect(subject["list"]).to eq ["baz", "bar"]
577
- expect(subject["foo"]).to eq "bar"
576
+ expect(subject.get("list")).to eq ["baz", "bar"]
577
+ expect(subject.get("foo")).to eq "bar"
578
578
  end
579
579
  end
580
580
 
@@ -587,8 +587,8 @@ describe LogStash::Filters::Mutate do
587
587
  }'
588
588
 
589
589
  sample("foo" => ["bar"], "list" => ["baz"]) do
590
- expect(subject["list"]).to eq ["baz", "bar"]
591
- expect(subject["foo"]).to eq ["bar"]
590
+ expect(subject.get("list")).to eq ["baz", "bar"]
591
+ expect(subject.get("foo")).to eq ["bar"]
592
592
  end
593
593
  end
594
594
 
@@ -601,8 +601,8 @@ describe LogStash::Filters::Mutate do
601
601
  }'
602
602
 
603
603
  sample("foo" => [], "list" => ["baz"]) do
604
- expect(subject["list"]).to eq ["baz"]
605
- expect(subject["foo"]).to eq []
604
+ expect(subject.get("list")).to eq ["baz"]
605
+ expect(subject.get("foo")).to eq []
606
606
  end
607
607
  end
608
608
 
@@ -615,8 +615,8 @@ describe LogStash::Filters::Mutate do
615
615
  }'
616
616
 
617
617
  sample("foo" => ["bar"], "list" => "baz") do
618
- expect(subject["list"]).to eq ["baz", "bar"]
619
- expect(subject["foo"]).to eq ["bar"]
618
+ expect(subject.get("list")).to eq ["baz", "bar"]
619
+ expect(subject.get("foo")).to eq ["bar"]
620
620
  end
621
621
  end
622
622
 
@@ -629,8 +629,8 @@ describe LogStash::Filters::Mutate do
629
629
  }'
630
630
 
631
631
  sample("foo" => "bar", "list" => "baz") do
632
- expect(subject["list"]).to eq ["baz", "bar"]
633
- expect(subject["foo"]).to eq "bar"
632
+ expect(subject.get("list")).to eq ["baz", "bar"]
633
+ expect(subject.get("foo")).to eq "bar"
634
634
  end
635
635
  end
636
636
 
metadata CHANGED
@@ -1,72 +1,74 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-mutate
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.6
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-03-24 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
14
  name: logstash-core-plugin-api
15
- version_requirements: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ~>
18
- - !ruby/object:Gem::Version
19
- version: '1.0'
20
15
  requirement: !ruby/object:Gem::Requirement
21
16
  requirements:
22
- - - ~>
17
+ - - "~>"
23
18
  - !ruby/object:Gem::Version
24
- version: '1.0'
25
- prerelease: false
19
+ version: '2.0'
26
20
  type: :runtime
27
- - !ruby/object:Gem::Dependency
28
- name: logstash-patterns-core
21
+ prerelease: false
29
22
  version_requirements: !ruby/object:Gem::Requirement
30
23
  requirements:
31
- - - '>='
24
+ - - "~>"
32
25
  - !ruby/object:Gem::Version
33
- version: '0'
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: logstash-patterns-core
34
29
  requirement: !ruby/object:Gem::Requirement
35
30
  requirements:
36
- - - '>='
31
+ - - ">="
37
32
  - !ruby/object:Gem::Version
38
33
  version: '0'
34
+ type: :development
39
35
  prerelease: false
40
- type: :runtime
41
- - !ruby/object:Gem::Dependency
42
- name: logstash-filter-grok
43
36
  version_requirements: !ruby/object:Gem::Requirement
44
37
  requirements:
45
- - - '>='
38
+ - - ">="
46
39
  - !ruby/object:Gem::Version
47
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: logstash-filter-grok
48
43
  requirement: !ruby/object:Gem::Requirement
49
44
  requirements:
50
- - - '>='
45
+ - - ">="
51
46
  - !ruby/object:Gem::Version
52
47
  version: '0'
48
+ type: :development
53
49
  prerelease: false
54
- type: :runtime
55
- - !ruby/object:Gem::Dependency
56
- name: logstash-devutils
57
50
  version_requirements: !ruby/object:Gem::Requirement
58
51
  requirements:
59
- - - '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: logstash-devutils
62
57
  requirement: !ruby/object:Gem::Requirement
63
58
  requirements:
64
- - - '>='
59
+ - - ">="
65
60
  - !ruby/object:Gem::Version
66
61
  version: '0'
67
- prerelease: false
68
62
  type: :development
69
- 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
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: This gem is a Logstash plugin required to be installed on top of the
70
+ Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This
71
+ gem is not a stand-alone program
70
72
  email: info@elastic.co
71
73
  executables: []
72
74
  extensions: []
@@ -88,26 +90,27 @@ licenses:
88
90
  metadata:
89
91
  logstash_plugin: 'true'
90
92
  logstash_group: filter
91
- post_install_message:
93
+ post_install_message:
92
94
  rdoc_options: []
93
95
  require_paths:
94
96
  - lib
95
97
  required_ruby_version: !ruby/object:Gem::Requirement
96
98
  requirements:
97
- - - '>='
99
+ - - ">="
98
100
  - !ruby/object:Gem::Version
99
101
  version: '0'
100
102
  required_rubygems_version: !ruby/object:Gem::Requirement
101
103
  requirements:
102
- - - '>='
104
+ - - ">="
103
105
  - !ruby/object:Gem::Version
104
106
  version: '0'
105
107
  requirements: []
106
- rubyforge_project:
107
- rubygems_version: 2.4.8
108
- signing_key:
108
+ rubyforge_project:
109
+ rubygems_version: 2.5.1
110
+ signing_key:
109
111
  specification_version: 4
110
- summary: The mutate filter allows you to perform general mutations on fields. You can rename, remove, replace, and modify fields in your events.
112
+ summary: The mutate filter allows you to perform general mutations on fields. You
113
+ can rename, remove, replace, and modify fields in your events.
111
114
  test_files:
112
115
  - spec/filters/integration/multi_stage_spec.rb
113
116
  - spec/filters/mutate_spec.rb