fluentd - 如何在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
,我意识到它使用的是旧的流利版本。更新它以
fluent/fluentd-kubernetes-daemonset:v1-debian-elasticsearch
解决问题。
推荐阅读
- jquery - 更新线程函数中的隐藏字段值,并从客户端 JQuery 中获取隐藏字段值
- javascript - 使用 .sort 对数字数组进行排序,但我不知道为什么会这样
- c# - 为什么 PropertyInfo[] 没有填充?
- c# - 无法加载文件或程序集“Microsoft.ML.Data,版本=1.0.0.0,文化=中性,PublicKeyToken=cc7b13ffcd2ddd51”
- javascript - 尝试在不刷新页面的情况下设置添加表单
- android - Android Room DAO - 我们应该在生命周期感知/不感知观察者的情况下使用 LiveData
- python-2.7 - 如何修复 UnicodeEncodeError:在 Pyspark 中将 Dataframe Row 转换为字符串
- matrix - 求系统的传递矩阵
- python - Python Selenium 上传按钮
- oauth - 如何区分 JWT 访问令牌和用作授权标头的刷新令牌