Kubernetes Fluentd multiline log

9/20/2018

We have a bunch of java container running on a Kubernetes cluster. The logs from these containers follow the common format of date message, stacktrace These logs are separated and sent to Stackdriver as individual parts, even though they're the same log.

How can you configure GKE to include these stacktraces in the log message?

-- aclokay
google-cloud-platform
google-kubernetes-engine
kubernetes

1 Answer

9/25/2018

This is the default behavior, it is working as intended. If you would like to change that, there are a few approaches below on how to customize it:

1 - I found these two fluent plugins (GCP-detect-exceptions and FT-detect-exceptions) from the fluent repo that will answer your question.

2 - You could also use structured logging. To do so, you should also reinstall the logging agent. You could write the "date message" into the logs as a jsonPayload.

3 - Here is another approach that would help you change the fluentd parameters to customize the log output. This approach mentions that you should create a new ConfigMap and then change Daemonset to point to it.

-- Mahmoud Sharif
Source: StackOverflow