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 +4 -4
- data/fluent-plugin-mutate_filter.gemspec +1 -1
- data/lib/fluent/plugin/filter_mutate.rb +20 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0664bad26658d5673c81a8bf2a16a009da087d73587b80e376c05a5197fe8b6e
|
4
|
+
data.tar.gz: 6f7cdc9185ed4978cc003ddea9f98ae7f4e715892b7d7903dcedfa58921931e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94e5be76a90711b400d3027234268e0eddf3f5649c5e5aa7048a3f5a6808a58f0d79b97efd55f69ce4493afe2965ec5bf03f3bafbba26371a90ed43844dae287
|
7
|
+
data.tar.gz: 5175dfb54f04ca6d03cc512e8dda1fd1835b2913b85ff4c49e238aaa10e0b965dec30380c058ab32d1dd9daadef9f0c31e433979281f345e991d75deb82f0263
|
@@ -62,7 +62,7 @@ module Fluent
|
|
62
62
|
end
|
63
63
|
when "parse"
|
64
64
|
data.each do |key, value|
|
65
|
-
if key == "
|
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.
|
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
|
-
|
442
|
-
or (value.start_with?('[') and value.end_with?(']'))
|
443
|
-
value = JSON.load(value)
|
444
|
+
value = event.get(field).strip
|
444
445
|
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
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
|