Fluentd配置:插入(Inject)和存储(Storage)配置项
我们已经了解了Fluentd配置文件中常见的三个配置项:Parse、Buffer和Format。今天继续学习Inject和Storage配置项。
Inject配置项 作用 向事件record中插入字段。有点类似今天第一篇文章中的filter_record_transformer插件,不过inject目前只能向record中插入几个固定的字段,功能较弱。 用法 在<match>或<filter>中配置<inject>。只对那些支持向record中插值的插件有效。 <match>
@type file
# parameters for output plugin
<inject>
# inject section parameters
</inject>
</match>
示例 # Record example
tag: test
time: 1547575563.952259
record: {"message":"hello"}
上边是原始事件,做如下<inject>配置: # Configuration example
<inject>
time_key fluentd_time
time_type string
time_format %Y-%m-%dT%H:%M:%S.%NZ
tag_key fluentd_tag
</inject>
事件record被修改为:
{"message":"hello","fluentd_tag":"test","fluentd_time":"2019-01-15T18:06:03.952259000Z"}上述配置中,time_key指定插入到record中time字段的名称为“fluentd_time”,其值和原事件的time相同,但使用的格式是time_format指定的字符串;tag_key指定插入到record中tag字段的名称为“fluentd_tag”,其值就是原事件的tag。
Storage配置项 作用 storage用于在某些插件中指定如何存储插件的内部状态,比如保存到内存、文件还是MongoDB、Redis中。 用法 在<source>、<match>或<filter>中配置<storage>。只对那些支持存储特性的插件有效。 示例 <source>
@type windows_eventlog
# parameters for input plugin
<storage>
@type local
</storage>
</source>
windows_eventlog会将自己用到的某些信息保存到本地json文件中。
至此,我们基本上将Fluentd配置文件中常见的一些配置项都介绍完了。这些配置项都是被上层配置项引用,并且只对特定的插件才生效。
接下来,我们会介绍一些Fluentd部署方面的知识。欢迎继续关注,非常期待您的转发分享!
赞 (0)