[英]How to send json logs through fluentd to stackdriver
I have docker containers writing logs in json format. 我有Docker容器以json格式编写日志。 When they run on GKE, the logs are shown in StackDriver fine, but when I run the same containers on some VM with kubernetes (not GKE) and use fluentd to route the logs to StackDriver, the log messages arrive escaped and under "log" key.
当它们在GKE上运行时,日志会很好地显示在StackDriver中,但是当我在具有kubernetes(不是GKE)的某些VM上运行相同的容器并使用fluentd将日志路由到StackDriver时,日志消息就转义了并且在“ log”下键。
Example: {"stream":"stdout","log":"{\\"time\\":\\"2019-07-25T09:55:18.2393210Z\\", .... 示例:{“ stream”:“ stdout”,“ log”:“ {\\” time \\“:\\” 2019-07-25T09:55:18.2393210Z \\“,....
How can I configure fluentd to get the logs in the same format as on GKE (without "log": and unescaped)? 如何配置fluentd以与GKE上相同的格式获取日志(不带“ log”:并且不转义)?
There are few things to consider: 有几件事情要考虑:
You can configure fluentd's log format with this guide. 您可以使用本指南配置fluentd的日志格式。
You can try some reverse engineering. 您可以尝试一些逆向工程。 Fluentd config used by GKE can by studied at following path on fluend Pod:
/etc/google-fluentd/config.d/containers.input.conf
可以在fluend Pod上的以下路径中研究GKE使用的Fluentd配置:
/etc/google-fluentd/config.d/containers.input.conf
You can directly check the GKE config in a ConfigMap
called fluentd-gcp-config-v1.2.5
. 您可以在名为
fluentd-gcp-config-v1.2.5
的ConfigMap
直接检查GKE配置。 There is some useful information regarding how to config fluentd as non-managed. 关于如何将流利配置为非托管,有一些有用的信息。 More details here .
更多细节在这里 。
Please let me know if that helped. 请让我知道是否有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.