fluent-plugin-mutate_filter 1.0.5 → 1.0.6

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
  SHA256:
3
- metadata.gz: ad13425ca3ba43ede3418c4101e3a03ff9caf8c2a92d8c2102e3a505d4d30dfd
4
- data.tar.gz: 0d6062dc6cdb02916f3f901a5f834e64fbdce6a6b9c8e5b97403625c30707b2d
3
+ metadata.gz: 0664bad26658d5673c81a8bf2a16a009da087d73587b80e376c05a5197fe8b6e
4
+ data.tar.gz: 6f7cdc9185ed4978cc003ddea9f98ae7f4e715892b7d7903dcedfa58921931e7
5
5
  SHA512:
6
- metadata.gz: 8ef466b6c236fc6ea8021038624fa989fc803f1319016a8128ed96aac7f56da84c13b97aab062706bf2ada95352e06327d5c1519141ef254e0d8f30058f6599f
7
- data.tar.gz: 9c3f9489112d32c88b5e727fbb73bd9d66d0ae85d7033dde0b25a03e4ca14aa6a0a0bb3fc0eebde04622c0ae475f76f6529b0390a82e88b82b53939d6657390d
6
+ metadata.gz: 94e5be76a90711b400d3027234268e0eddf3f5649c5e5aa7048a3f5a6808a58f0d79b97efd55f69ce4493afe2965ec5bf03f3bafbba26371a90ed43844dae287
7
+ data.tar.gz: 5175dfb54f04ca6d03cc512e8dda1fd1835b2913b85ff4c49e238aaa10e0b965dec30380c058ab32d1dd9daadef9f0c31e433979281f345e991d75deb82f0263
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = "fluent-plugin-mutate_filter"
6
- spec.version = "1.0.5"
6
+ spec.version = "1.0.6"
7
7
  spec.authors = ["Jonathan Serafini"]
8
8
  spec.email = ["jonathan@serafini.ca"]
9
9
 
@@ -62,7 +62,7 @@ module Fluent
62
62
  end
63
63
  when "parse"
64
64
  data.each do |key, value|
65
- if key == "@merge_root"
65
+ if key == "merge_root"
66
66
  data[key] = Fluent::Config.bool_value(value)
67
67
  next
68
68
  end
@@ -428,25 +428,36 @@ module Fluent
428
428
  # Lazily just support json for now
429
429
  # @since 1.0.0
430
430
  def parse(params, event)
431
- merge_root = params.delete("@merge_root")
431
+ merge_root = params.fetch("merge_root", false)
432
432
 
433
433
  params.each do |field, parser|
434
+ next if field == "merge_root"
435
+
434
436
  value = event.get(field)
437
+ parsed = nil
435
438
 
436
439
  unless value.is_a?(String)
437
440
  @log.warn("field value cannot be parsed by #{parser}")
438
441
  next
439
442
  end
440
443
 
441
- if (value.start_with?('{') and value.end_with?('}')) \
442
- or (value.start_with?('[') and value.end_with?(']'))
443
- value = JSON.load(value)
444
+ value = event.get(field).strip
444
445
 
445
- if merge_root
446
- event.update(value)
447
- else
448
- event.set(field, value)
446
+ if value.start_with?('{') and value.end_with?('}')
447
+ parsed = JSON.load(value)
448
+ end
449
+
450
+ if parsed.nil?
451
+ next
452
+ end
453
+
454
+ if merge_root
455
+ parsed.each do |k, v|
456
+ event.set(k, v)
457
+ event.delete(field)
449
458
  end
459
+ else
460
+ event.set(field, parsed)
450
461
  end
451
462
  end
452
463
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-mutate_filter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Serafini