在Kubernetes / Google容器引擎(GKE)上使用Stackdriver API进行日志记录 [英] Logging using Stackdriver API on Kubernetes / Google Container Engine (GKE)

查看:260
本文介绍了在Kubernetes / Google容器引擎(GKE)上使用Stackdriver API进行日志记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可以利用Google Cloud Logging API的应用程序。



相关代码与其文档中的示例相同: https://github.com/GoogleCloudPlatform/golang-samples/blob/master/logging /logging_quickstart/main.go



检查后,它与minikube一起工作(我的负载出现在 Global 我的日志查看器的类别),我在Google容器引擎(GKE)上部署应用程序。

部署完成后,我无法再看到应用程序通过日志API发送的日志。
写入std的日志显示在 GKE容器类别中,但没有使用API​​发送的条目的跟踪。



我的集群具有Stackdriver日志记录API启用/只写,默认服务帐户是编辑器(甚至用于所有者),我也尝试过一个专门的服务帐户(使用env GOOGLE_APPLICATION_CREDENTIALS )与日志编写器甚至所有者的访问权限,我看不到日志,并没有从客户端库中报告错误。



可能是什么问题原因或哪里可以开始调试这样的问题?



谢谢,

解决方案



使用gcloud CLI,我可以看到这些日志的资源类型为 gce_instance ,因此出现在 GCE VM实例类别中



弄清楚:

  $ gcloud beta记录日志列表
projects /< PROJECT> / logs /< LOG_NAME>
...

然后

  $ gcloud beta logging read projects /< PROJECT> / logs /< LOG_NAME> 
---
insertId:...
jsonPayload:
...
logName:...
receiveTimestamp:...
资源:
标签:
instance_id:...
project_id:...
区域:...
类型:gce_instance
时间戳:。 ..

注意类型存在 gce_instance


I have a go application that leverages Google Cloud Logging API.

The relevant code is the same as this sample from their documentation: https://github.com/GoogleCloudPlatform/golang-samples/blob/master/logging/logging_quickstart/main.go

After checking it works with minikube (my payload appears in the Global category of my logs viewer), I deploy the app on Google Container Engine (GKE).

Once deployed there, I can no longer see the logs the app sends through the logging API. The logs written to std appears in the GKE container category, but no trace of the entries I send using the API.

My cluster has Stackdriver logging API enabled / write only, the default service account is Editor (even tried with Owner), I also tried with a dedicated service account (using the env GOOGLE_APPLICATION_CREDENTIALS) with log writer or even owner access, I can’t see the logs and no error are reported from the client library.

What could be the cause or where could I start debugging such issue?

Thank you,

解决方案

So turns out the log were there but not where I'd expect them.

Using the gcloud CLI I could see those logs got the resource type gce_instance and therefore appears in the GCE VM Instance category

To figure this out:

  $ gcloud beta logging logs list
  projects/<PROJECT>/logs/<LOG_NAME>
  ...

then

$ gcloud beta logging read projects/<PROJECT>/logs/<LOG_NAME>
---
insertId: ...
jsonPayload:
   ...
logName: ...
receiveTimestamp: ...
resource:
  labels:
    instance_id: ...
    project_id: ...
    zone: ...
  type: gce_instance
timestamp: ...

Note type being gce_instance

这篇关于在Kubernetes / Google容器引擎(GKE)上使用Stackdriver API进行日志记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆