dqwh2717 2017-07-10 22:32
浏览 56
已采纳

在Kubernetes / Google容器引擎(GKE)上使用Stackdriver API进行日志记录

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,

  • 写回答

1条回答 默认 最新

  • dpbv85276 2017-07-13 15:47
    关注

    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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)