简体   繁体   English

如何通过fluentd将json日志发送到stackdriver

[英]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: 有几件事情要考虑:

  1. You can configure fluentd's log format with this guide. 您可以使用指南配置fluentd的日志格式。

  2. 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

  3. You can directly check the GKE config in a ConfigMap called fluentd-gcp-config-v1.2.5 . 您可以在名为fluentd-gcp-config-v1.2.5ConfigMap直接检查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.

相关问题 如何发送内部Kubernetes日志到Stackdriver - How to Send On Premises Kubernetes Logs to Stackdriver 如何基于流利的严重性过滤日志并将其发送到2个不同的日志系统 - How to filter logs based on severity in fluentd and send it to 2 different logging systems 如何使用fluentd收集pod日志并将其发送到elasticsearch? - How can I collect the pod logs using fluentd and send the logs to elasticsearch? Kubernetes - 在 AWS EKS Fargate 中,如何将日志从一个容器发送到 Splunk 的 FluentD? - Kubernetes - In AWS EKS Fargate How Can I Send Logs From One Container To FluentD For Splunk? 如何在 Stackdriver 日志中检测 GKE 自动升级节点 - How to detect GKE autoupgrading a node in Stackdriver logs 如何在 GKE 上通过 stackdriver 查看容器日志 - How to view container logs via stackdriver on GKE 流利 | 如何删除特定容器的日志 - Fluentd | how to drop logs of specific container 我如何在 Kubernetes 上过滤 fluentD 日志? - How i filter fluentD logs on kubernetes? fluentd + eks:跳过发送运行几秒钟的作业日志 - fluentd + eks: skipping to send logs of jobs running for a few seconds Nginx json 日志在 Elasticsearch (+ Kibana) 中被 Fluentd 错误解析 - Nginx json logs are incorrectly parsed by Fluentd in Elasticsearch (+ Kibana)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM