![](/img/trans.png)
[英]My containerized Node/React application works on Kubernetes locally, need help getting it to run on GCP GKE
[英]GCP structured logging, works locally but not on kubernetes
我正在尝试通过我的服务在 GCP 上创建结构化日志记录。 当我在本地运行它时,我设法以正确的格式获取 JsonPayload,如下所示:
jsonPayload: {
exception: {
Message: ""
StackTrace: ""
TargetSite: ""
Type: "value_error"
}
logging.googleapis.com/labels: {2}
logging.googleapis.com/spanId: "94ecf8a83efd7f34"
logging.googleapis.com/trace: "dc4696d790ab643b058f87dbeebf19a3"
message: "Bad Request"
severity: "ERROR"
time: "2022-10-05T14:38:52.965749Z"
但是当我在 Kube.netes 上运行该服务时,我只会在日志记录中得到以下信息:
jsonPayload: {
exception: {
Message: ""
StackTrace: ""
TargetSite: ""
Type: "value_error"
}
message: "Bad Request"
当我在 GCP kube.netes 上运行服务时,为什么 GCP 从日志记录 JsonPayload 中删除 logging.googleapis.com/labels、logging.googleapis.com/spanId、logging.googleapis.com/trace、severity?
这可能是按预期工作(WAI),但您的问题尚不清楚。
Google结构化日志记录尝试将日志条目解析为 JSON 并提取特定字段,包括logging.googleapis.com/labels
。
但是 (,) 当它这样做时,其中一些字段(包括logging.googleapis.com/labels
)从jsonPayload
字段重新定位到另一个LogEntry
字段。
看:
因此,您不应在 Cloud Logging 的jsonPayload
中查找这些值,而应在例如labels
、 spanId
和trace
中查找:
PROJECT=...
# Filter by entries that contain `jsonPayload`
gcloud logging read "jsonPayload:*" \
--project=${PROJECT} \
--format="value(jsonPayload,labels,spanId,trace)"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.