如何重新标记由fluentd管理的docker stdout中的字段(带有rewrite_flag_filter)?

时间:2019-01-15 23:36:42

标签: docker logging splunk fluentd

如何重命名/标记显示在splunk中的字段,这些字段是从docker stdout通过fluentd转发的。我正在学习的过程中流利而又流利,对所有这些都是新的。

当前,正在使用rewrite_tag_filter规则更新fluent.conf文件,以在“ container_name”字段中查找带有不同标签的模式。尝试在正常部分附近添加并更新为特定的@INPUT和@OUTPUT。但是我的fluent.conf更新都没有显示在splunk界面中。

这是我已添加到fluent.conf文件中的不同尝试。

第一次尝试测试容器的“重新命名”以进行s1test

<match container_name>
 @type rewrite_tag_filter

 <rule>
   key container_name
   pattern (.+)
   tag s1test
 </rule>
</match>

第二次尝试

<match docker.*>
 @type rewrite_tag_filter
 rewriterule1 container_name ^\/s1_(.)$ s1.$1
</match>

第三次尝试,在看到流利的日志并显示rewriterule1使用已过时的错误后,需要改为使用。此外,由于我想的是添加的,因为这些是来自docker的标准输出,因此这将使其能够“识别”模式匹配和重命名的日志。

<label @INPUT>
  <match container_name>
    @type rewrite_tag_filter
    <rule>
      key container_name
      pattern ^\/s1_(.*)$
      tag service.test
    </rule>
    @label @OUTPUT
  </match>
</label>

<label @OUTPUT>
  <match service.test>
    @type stdout
  </match>
</label>

当前,computer_name字段显示的变量以  /s1_api.1。并以看似随机的字符串结尾。

目标是简化输出,以便字段“ container_name”的命名约定仅显示服务本身,理想情况下仅显示容器上运行的单个服务,例如(api,fluentd,db等)。 。

流畅的日志显示了这一点

2019-01-14 22:17:20 +0000 [info]: adding match 
pattern="container_name" type="rewrite_tag_filter"
2019-01-14 22:17:20 +0000 [warn]: rewrite_tag_filter: [DEPRECATED] 
Use <rule> section instead of rewriterule1
2019-01-14 22:17:20 +0000 [info]: adding rewrite_tag_filter rule: 
rewriterule1 ["container_name", /^\/test_(.)$/, "", "s1.$1"]

0 个答案:

没有答案