简体   繁体   English

在 Cloud Logging 中看不到来自 GKE 的 pod 日志

[英]Can't see pod logs from GKE in Cloud Logging

I have a GKE cluster v1.22 with the Cloud Logging feature enabled.我有一个启用了 Cloud Logging 功能的 GKE 集群 v1.22。 screenshot截屏

But I can't see any application logs in the Logs Explorer.但我在日志资源管理器中看不到任何应用程序日志。

Also, I can't see any logs for fluent-bit pod that Google uses to transfer logs to the Cloud Logging.此外,我看不到 Google 用于将日志传输到 Cloud Logging 的 fluent-bit pod 的任何日志。 screenshot screenshot截图截图

It has a default configmap that was created automatically with cluster creation.它有一个默认配置映射,该配置映射是在创建集群时自动创建的。

API is enabled in GCP. GCP 中启用了 API。

I can't find any related manuals and topics about it.我找不到任何相关的手册和主题。

I will be very pleased if you help me to deal with it.如果您能帮助我处理它,我将非常高兴。

upd:更新:

I found this in fluentbit.log on the node:

[2022/06/08 08:41:45] [error] [parser] cannot parse '0608 08:41:45.986036' after %L
[2022/06/08 08:41:45] [ warn] [parser:glog] invalid time format %m%d %H:%M:%S.%L%z for '0608 08:41:45.986036'
[2022/06/08 08:41:45] [error] [parser] cannot parse '0608 08:41:45.986083' after %L
[2022/06/08 08:41:45] [ warn] [parser:glog] invalid time format %m%d %H:%M:%S.%L%z for '0608 08:41:45.986083'
[2022/06/08 08:41:45] [error] [parser] cannot parse '0608 08:41:45.986949' after %L
[2022/06/08 08:41:45] [ warn] [parser:glog] invalid time format %m%d %H:%M:%S.%L%z for '0608 08:41:45.986949'
[2022/06/08 08:41:45] [error] [parser] cannot parse '0608 08:41:45.987048' after %L
[2022/06/08 08:41:45] [ warn] [parser:glog] invalid time format %m%d %H:%M:%S.%L%z for '0608 08:41:45.987048'

parsers conf is:

[PARSER]
    Name        docker
    Format      json
    Time_Key    time
    Time_Format %Y-%m-%dT%H:%M:%S.%L%z

[PARSER]
    Name        containerd
    Format      regex
    Regex       ^(?<time>.+) (?<stream>stdout|stderr) [^ ]* (?<log>.*)$
    Time_Key    time
    Time_Format %Y-%m-%dT%H:%M:%S.%L%z

[PARSER]
    Name        json
    Format      json

[PARSER]
    Name        syslog
    Format      regex
    Regex       ^\<(?<pri>[0-9]+)\>(?<time>[^ ]* {1,2}[^ ]* [^ ]*) (?<host>[^ ]*) (?<ident>[a-zA-Z0-9_\/\.\-]*)(?:\[(?<pid>[0-9]+)\])?(?:[^\:]*\:)? *(?<message>.*)$
    Time_Key    time
    Time_Format %b %d %H:%M:%S

[PARSER]
    Name        glog
    Format      regex
    Regex       ^(?<severity>\w)(?<time>\d{4} [^\s]*)\s+(?<pid>\d+)\s+(?<source_file>[^ \]]+)\:(?<source_line>\d+)\]\s(?<message>.*)$
    Time_Key    time
    Time_Format %m%d %H:%M:%S.%L%z

[PARSER]
    Name        network-log
    Format      json
    Time_Key    timestamp
    Time_Format %Y-%m-%dT%H:%M:%S.%L%z

Check if your application writes anything to stdout/stderr:检查您的应用程序是否向 stdout/stderr 写入任何内容:
kubectl logs <pod_name>

If it returns nothing then that's why you cannot see any container logs in Logs Explorer for your application.如果它没有返回任何内容,这就是您在日志资源管理器中看不到应用程序的任何容器日志的原因。

If it returns anything then make sure you don't have any logging exclusions potentially filtering out your application logs:如果它返回任何内容,请确保您没有任何日志排除可能会过滤掉您的应用程序日志:
In the console menu find Operations section, then go to Logging->Logs Router在控制台菜单中找到 Operations 部分,然后转到 Logging->Logs Router
Next, on Logs Router Sink named _Default click Dots(More actions)->Edit sink接下来,在名为 _Default 的 Logs Router Sink 上单击 Dots(More actions)->Edit sink
There, scroll down to 'Choose logs to filter out of sink (optional)' and make sure there are not any exclusion filters with expressions like:在那里,向下滚动到“选择日志以从接收器中过滤(可选)”,并确保没有任何带有以下表达式的排除过滤器:
resource.type=("container" OR "k8s_container")
resource.type="k8s_container" AND labels.k8s-pod/app="your_app_name"
nor any other similar matching your application.也没有任何其他类似的匹配您的应用程序。

If you find any, you can disable them (or delete them), wait a minute and check Logs Explorer again.如果发现任何内容,您可以禁用它们(或删除它们),稍等片刻,然后再次检查 Logs Explorer。

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

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