如何在fluentd的输出路径中使用tag?

How to use tag in the output path of fluentd?

我正在尝试使用 fluentd 复制一堆日志文件。所有日志文件都需要写入同一个目标目录。

      @type tail
      @id container-input
      format none
      path "/var/log/containers/plugin*.log"
# This path would match multiple files that I want to log
      pos_file "/var/log/plugin.log.pos"
      refresh_interval 5
      rotate_wait 5
      read_from_head "true"
      tag plugin.*
    </source>
    <filter plugin.**>
      @type record_transformer
      <record>
        filename ${tag_suffix[-2]}
      </record>
    </filter>
    <match plugin**>
      @type file
      path /destlogs/plugin.log
    </match>

我想要的是在输出路径中的某处使用文件名,例如

path /destlogs/plugin-${filename}.log

然而,当我使用这样的配置时,fluentd 不会选择文件名标签作为变量,而只是按原样创建路径。

如何在输出路径中使用标签作为变量?

这里的问题是版本。 v0.12 似乎不支持匹配部分中的标签,而 v1.0 支持。我正在使用流利的图像 fluent/fluentd-kubernetes-daemonset:elasticsearch 我意识到它使用的是较旧的 fluentd 版本。更新为 fluent/fluentd-kubernetes-daemonset:v1-debian-elasticsearch 解决了问题。