今天了解的这款插件叫做:record_transformer。
看到名字,你想到了什么?
变形金刚?没错,变形金刚的英文原名就是Transformers。
那么,record_transformer的作用就是用来修改日志记录的。
这个插件可以多途径改变收到的日志事件,是用来对事件进行增删改操作的首选。
record_transformer包含在Fluentd内核之中。
【示例配置】
<filter foo.bar>
@type record_transformer
<record>
hostname "#{Socket.gethostname}"
tag ${tag}
</record>
</filter>
这个配置片段演示了如何向日志中插入两个字段:hostname和tag。
如此配置之后,
{"message":"hello world!"}
这条日志会变成
{"message":"hello world!", "hostname":"db001.internal.example.com", "tag":"foo.bar"}
再看一个配置: