我正在尝试使用Fluentd作为我的docker容器设置的中央日志服务。
我使用Fluent golang客户端从应用程序https://github.com/fluent/fluent-logger-golang编写日志
我在应用程序中发布了如下日志行
logger, _ := fluent.New(fluent.Config{FluentPort: 24224, FluentHost: "fluentd"})
defer logger.Close()
tag := "web"
var data = map[string]string{
"foo": "bar",
"hoge": "hoge",
}
error := logger.Post(tag, data)Fluentd conf文件
<source>
@type forward
@id app_logs
@label @mainstream
port 24224
</source>
<label @mainstream>
<match **>
@type file
@id app_logs
path /fluentd/log/app.log
append true
</match>
</label>文件中的日志如下所示
2020-09-23T00:05:06+00:00 web {"foo":"bar","hoge":"hoge"}我不想看到时间戳和添加在日志行之前的标记。怎样才能删除它?
发布于 2020-09-23 15:39:34
您看到的是@type stdout。Fluentd将时间戳和标记打印到stdout以进行调试。如果您将其替换为任何其他输出- @type file或@type s3并格式化json,它将把数据序列化为不带此前缀的有效json。示例:https://docs.fluentd.org/output/file#less-than-format-greater-than-directive
https://stackoverflow.com/questions/64019294
复制相似问题