![](/img/trans.png)
[英]How to classify docker container logs by container name using Fluent-bit?
[英]How to change the timestamp to UTC for the logs that a fluent-bit docker container receives via stdin?
我的 Fluent Bit Docker 容器正在向通过 STDIN 接收的日志添加带有本地时间的时间戳; 否则通过 rsyslog 或 journald 接收的所有日志似乎都具有 UTC 时间格式。
我有一个基本的 EFK 堆栈,我在其中运行 Fluent Bit 容器作为远程收集器,它将所有日志转发到 FluentD 中央收集器,后者将所有内容推送到 Elasticsearch。
我在 Fluent Bit 配置文件中添加了一个过滤器,我尝试了多种方法来修改时间戳,但无济于事。 看来是我多虑了; 修改时间戳应该容易得多。
这些是我尝试使用fluent-bit.conf过滤器修改时间戳的所有方法
[FILTER]
Name record_modifier
Match_Regex ^(?!log.*).*$ ## only match the input received via stdin
Tag log.stdout ## tag to mark input received via stdin
Add sourcetype timestamp ## tried to add timestamp from lua script
Parser docker ## tried to use docker parser for timestamp
Time_key utc ## tried to add timestamp as a key
script test.lua ## sample lua script from fluentbit docs
call cb_print ## call a function from within lua script
使所有时间戳统一为 UTC 的事实上的方法是什么? 任何帮助或建议表示赞赏。
它的工作方式是 docker 解析器提取 'log' 的内容并尊重 docker 定义的时间戳。
一种快速解决方法是修改您的 parsers.conf 并确保 docker 解析器不解析时间戳,这样 Fluent Bit 将为您分配 UTC 中的当前时间。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.