I'm trying to use Fluentd as a central logging service for my docker containers setup.
I use Fluent golang client to write logs from the application https://github.com/fluent/fluent-logger-golang
I post log line like this from the application
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 file
<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>
The log appears as below in the file
2020-09-23T00:05:06+00:00 web {"foo":"bar","hoge":"hoge"}
I don't want to see timestamp and the tag added before the log line. How can I remove it?
What you seeing is @type stdout
. Fluentd prints timestamp and tag to stdout for debugging purposes. If you replace this with any other output - @type file
or @type s3
and format json, it will serialize the data into valid json without this prefix. Example: https://docs.fluentd.org/output/file#less-than-format-greater-than-directive