我在集群的默认名称空间中进行了GKE部署,将json输出到stdout。由于某些原因,这些行被作为textPayload(粘贴在下面)而不是json负载进行拾取。 Stackdriver正在接收日志,但未解析日志行。有人知道为什么吗?
{
"textPayload": "{\"timestamp\":\"2018-12-29T04:37:55Z\",\"severity\":\"INFO\",\"httpRequest\":{\"requestMethod\":\"GET\",\"requestUrl\":\"/healthz\",\"status\":\"200\",\"userAgent\":\"kube-probe/1.11+\",\"remoteIp\":\"10.28.5.1:45732\",\"latency\":\"0.000052327s\"},\"message\":\"Completed request\",\"context\":{\"data\":{\"httpRequest\":{\"requestMethod\":\"GET\",\"requestUrl\":\"/healthz\",\"status\":\"200\",\"userAgent\":\"kube-probe/1.11+\",\"remoteIp\":\"10.28.5.1:45732\",\"latency\":\"0.000052327s\"}}}}\n",
"insertId": "z8530p0phoyggk6w4",
"resource": {
"type": "k8s_container",
"labels": {
"container_name": "charts",
"namespace_name": "default",
"location": "us-central1",
"project_id": "******",
"cluster_name": "********",
"pod_name": "charts-586d4cb4b6-fmw6m"
}
},
"timestamp": "2018-12-29T04:37:55.920510496Z",
"severity": "INFO",
"logName": "projects/******/logs/stdout",
"receiveTimestamp": "2018-12-29T04:37:58.865021941Z",
"metadata": {
"systemLabels": {
"provider_zone": "us-central1-b",
"top_level_controller_name": "charts",
"node_name": "******",
"container_image": "*******",
"provider_resource_type": "gce_instance",
"top_level_controller_type": "Deployment",
"name": "charts",
"container_image_id": "*******",
"service_name": [
"charts-service"
],
"provider_instance_id": "*********"
},
"userLabels": {
"pod-template-hash": "1428076062",
"tier": "web",
"app": "charts"
}
}
}
我需要更改什么才能正确解析?它是有效的json,由logrus(和格式化程序https://github.com/icco/logrus-stackdriver-formatter/blob/sd-v2/formatter.go)生成。
哦,在本地运行时会生成示例日志行:
{"timestamp":"2018-12-29T05:07:31.257829Z","severity":"INFO","httpRequest":{"requestMethod":"GET","requestUrl":"/healthz","status":"200","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.28 Safari/537.36","remoteIp":"[::1]:55033","latency":"0.000052380s"},"message":"Completed request","context":{"data":{"httpRequest":{"requestMethod":"GET","requestUrl":"/healthz","status":"200","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.28 Safari/537.36","remoteIp":"[::1]:55033","latency":"0.000052380s"}}}}