简体   繁体   English

GKE & Stackdriver & Spring - 日志未分组/相关

[英]GKE & Stackdriver & Spring - logs not grouped/correlated

This question is gonna be a hard one to ask as there are multiple technologies involved.这个问题很难问,因为涉及多种技术。 Feel free to ask for more info as I may unintentionally leave out an important piece of the puzzle.随意询问更多信息,因为我可能无意中遗漏了一个重要的难题。 :) :)

I have:我有:

I can confirm every single piece of the setup working correctly.我可以确认每个设置都正常工作。 When I access my public IP address, I'm shown my Spring Boot application and in Logs Explorer I see logs in the expected format (JSON, not default plaintext).当我访问我的公共 IP 地址时,我看到了我的 Spring 启动应用程序,并且在日志资源管理器中我看到了预期格式的日志(JSON,而不是默认的纯文本)。

However, what I am missing is seeing request information in my container logs.但是,我缺少的是在我的容器日志中查看请求信息。 This is what my logs look like:这是我的日志的样子:

在此处输入图像描述

The first log message you see is from Cloud HTTP Load Balancer.您看到的第一条日志消息来自 Cloud HTTP 负载均衡器。 The second one is from Kubernetes Container.第二个来自 Kubernetes 容器。 As you can see, the first one is containing httpRequest and the data within it.如您所见,第一个包含httpRequest和其中的数据。 Although the trace ID of the first message is matching the second one, there is no httpRequest info being shown for container logs.尽管第一条消息的跟踪 ID 与第二条消息匹配,但没有为容器日志显示httpRequest信息。

According to what I read, the request information should be propagated down the line and I should be able to see it in my container logs alone.根据我阅读的内容,请求信息应该被传播到该行,并且我应该能够仅在我的容器日志中看到它。

Please advise.请指教。 Thank you!谢谢!

If you log your information or whatever to stdout then info would be visible in Logging.如果您将您的信息或任何内容记录到标准输出,则信息将在 Logging 中可见。 Log everything u need from the container and then explore in Logging Dashboard.从容器中记录您需要的所有内容,然后在 Logging Dashboard 中进行探索。

I would also suggest if the setup is somewhat production like, have another project dedicated specifically for logging purposes and you can use log sinks in order to stream your logs to another project.我还建议如果设置有点像生产,有另一个专门用于日志记录的项目,您可以使用日志接收器以便将您的日志 stream 到另一个项目。

You can also save money with this approach, if you set the retention periods properly.如果您正确设置保留期,您还可以通过这种方法节省资金。 (below you might see the results of the optimization) (下面你可能会看到优化的结果)

在此处输入图像描述

One more note don't forget about Debug property in Docker.yaml file.还有一点不要忘记 Docker.yaml 文件中的 Debug 属性。

Hope that somewhat helps.希望有所帮助。

And also would suggest looking @并且还建议看@

<dependency>
   <groupId>org.springframework.cloud</groupId>
   <artifactId>spring-cloud-gcp-starter-logging</artifactId>
   <version>1.2.1.RELEASE</version>
</dependency>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM