How to replace a key value string with specific string in fluentd

Viewed 2235

I am new to the fluentd, I want to use record_modifier to replace the string, when specific string occurs in the key value.

Example

1)input :

{"message":"how are you"}

output :

{"message":"who are you"}

when input key value having "how", i want to replace that string with "who"

2)input :

{"message":"he is a bad boy"}

output :

{"message":"he is a good boy"}

when input key value having "bad", i want to replace that string with "good"

@type record_modifier #auto_typecast true enter code here key message expression ????? replace ?????

Thanks in Advance.

1 Answers

you can use gsub in a record_transformer

<filter yourTag>
  @type record_transformer
  enable_ruby
  <record>
    log ${record["log"].gsub('how', 'who')}   
  </record>
</filter>
Related