fluent-plugin-mutate_filter 1.0.3 → 1.0.5

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: 79f746bd9c44d86ef7ab074a10776185edd537fb420d0cdef9c4f73ae7caa043
4
- data.tar.gz: baeed48ef9eced0336745871771a724ebcd759e48f09f700b367a60abe0af97c
3
+ metadata.gz: ad13425ca3ba43ede3418c4101e3a03ff9caf8c2a92d8c2102e3a505d4d30dfd
4
+ data.tar.gz: 0d6062dc6cdb02916f3f901a5f834e64fbdce6a6b9c8e5b97403625c30707b2d
5
5
  SHA512:
6
- metadata.gz: f1bc65b2293d7bd5bacd2141f6ab9c9c1986c01f9a7bbe687636daef2fe5cc86765b674a6d56131b6e7b36e61ec85044c872e484fc5c101510d9079850d1c125
7
- data.tar.gz: 9a79a1e2cb37ffbc1c04690fde427f8a995b61f0008ba94a843ba9975ce5ae37e1be73fe432c06b73c563507874e9b5d16cb8a3d8e8be10f0291615cdc3fae08
6
+ metadata.gz: 8ef466b6c236fc6ea8021038624fa989fc803f1319016a8128ed96aac7f56da84c13b97aab062706bf2ada95352e06327d5c1519141ef254e0d8f30058f6599f
7
+ data.tar.gz: 9c3f9489112d32c88b5e727fbb73bd9d66d0ae85d7033dde0b25a03e4ca14aa6a0a0bb3fc0eebde04622c0ae475f76f6529b0390a82e88b82b53939d6657390d
data/README.md CHANGED
@@ -95,6 +95,8 @@ Merge the value of source\_field, which may be an Array or a Map, into the key's
95
95
 
96
96
  Parse a key's value from JSON to a object.
97
97
 
98
+ Additionally, a `@merge_root` boolean field may be defined to have the resulting object be merge into the root of the record.
99
+
98
100
  ##### `rename <new_name>`
99
101
 
100
102
  Rename a key to a new key name.
@@ -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.3"
6
+ spec.version = "1.0.5"
7
7
  spec.authors = ["Jonathan Serafini"]
8
8
  spec.email = ["jonathan@serafini.ca"]
9
9
 
@@ -4,8 +4,8 @@ require "fluent/plugin/mixin/mutate_event"
4
4
 
5
5
  module Fluent
6
6
  module Plugin
7
- class MutateFilter2 < Fluent::Plugin::Filter
8
- Fluent::Plugin.register_filter("mutate2", self)
7
+ class MutateFilter < Fluent::Plugin::Filter
8
+ Fluent::Plugin.register_filter("mutate", self)
9
9
 
10
10
  # Treat periods as nested field names
11
11
  config_param :expand_nesting, :bool, default: true
@@ -62,6 +62,11 @@ module Fluent
62
62
  end
63
63
  when "parse"
64
64
  data.each do |key, value|
65
+ if key == "@merge_root"
66
+ data[key] = Fluent::Config.bool_value(value)
67
+ next
68
+ end
69
+
65
70
  unless VALID_PARSERS.include?(value)
66
71
  raise Fluent::ConfigError, "mutate #{type} action " +
67
72
  "received an invalid type for #{key}, should be one " +
@@ -423,6 +428,8 @@ module Fluent
423
428
  # Lazily just support json for now
424
429
  # @since 1.0.0
425
430
  def parse(params, event)
431
+ merge_root = params.delete("@merge_root")
432
+
426
433
  params.each do |field, parser|
427
434
  value = event.get(field)
428
435
 
@@ -434,7 +441,12 @@ module Fluent
434
441
  if (value.start_with?('{') and value.end_with?('}')) \
435
442
  or (value.start_with?('[') and value.end_with?(']'))
436
443
  value = JSON.load(value)
437
- event.set(field, value)
444
+
445
+ if merge_root
446
+ event.update(value)
447
+ else
448
+ event.set(field, value)
449
+ end
438
450
  end
439
451
  end
440
452
  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.3
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Serafini