fluentd-docs
fluentd-docs copied to clipboard
How to delete a key and keep it's value, the value is an hash
input: "params": {"key1": "value1"} output: {"key1": "value1"} This is my use case. Thank you.
def filter(tag, time, record)
if record['params']
value = record['params']
record.merge!(value)
record.delete('params')
end
end
I write a filter plugin, some code like this. It can work. But I think the method is complex. Any simple solution?
def filter(tag, time, record)
if params.key?("params")
new_record = record["params"]
new_record
else
record
end
end
The filter method must return the new modified record or original record.
BTW, record_transformer Filter Plugin is suitable for the purpose.