[英]Logging using Stackdriver API on Kubernetes / Google Container Engine (GKE)
I have a go application that leverages Google Cloud Logging API. 我有一个利用Google Cloud Logging API的go应用程序。
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 相关代码与他们的文档中的该示例相同: 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). 在检查它是否适用于minikube(我的有效负载出现在日志查看器的“ Global
类别中)之后,我将应用程序部署到了Google容器引擎(GKE)上。
Once deployed there, I can no longer see the logs the app sends through the logging API. 一旦部署到那里,我将不再看到应用程序通过日志记录API发送的日志。 The logs written to std appears in the GKE container
category, but no trace of the entries I send using the API. 写入std的日志显示在GKE container
类别中,但没有跟踪使用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. 我的集群启用了Stackdriver Logging API /仅写,默认服务帐户是Editor(甚至与Owner一起尝试过),我也尝试了具有日志记录器甚至所有者访问权限的专用服务帐户(使用env GOOGLE_APPLICATION_CREDENTIALS
),我无法查看日志,并且客户端库未报告任何错误。
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 使用gcloud CLI,我可以看到这些日志的资源类型为gce_instance
,因此出现在GCE VM Instance
类别中
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
笔记type
为gce_instance
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.