Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions lib/fluent/plugin/filter_record_modifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ class RecordModifierFilter < Filter
In more detail, please refer this section:
https://github.com/repeatedly/fluent-plugin-record-modifier#char_encoding.
DESC

config_param :replace_keys, :bool, default: true,
desc: <<-DESC
Whether to replace a key or not if already in the record.
DESC

config_param :remove_keys, :string, default: nil,
desc: <<-DESC
The logs include needless record keys in some cases.
Expand All @@ -26,7 +32,7 @@ class RecordModifierFilter < Filter
This option is exclusive with `remove_keys`.
DESC

BUILTIN_CONFIGURATIONS = %W(type @type log_level @log_level id @id char_encoding remove_keys whitelist_keys)
BUILTIN_CONFIGURATIONS = %W(type @type log_level @log_level id @id char_encoding replace_keys remove_keys whitelist_keys)

def configure(conf)
super
Expand Down Expand Up @@ -89,7 +95,9 @@ def filter_stream(tag, es)

es.each { |time, record|
@map.each_pair { |k, v|
record[k] = v.expand(tag, time, record, tag_parts)
if @replace_keys || !record.has_key?(k)
record[k] = v.expand(tag, time, record, tag_parts)
end
}

if @remove_keys
Expand Down