GCP 日志记录控制台不显示某些 GKE 日志消息

GCP logging console doesn't display some GKE log messages

我在 GCP 中有 K8S 集群(版本是 1.20.8-gke.900 来自常规更新频道)。 所有集群 pods 从 Docker 容器将日志写入 STDOUTSTDERR

我发现有些日志消息从未出现在 GCP 日志记录控制台中。

例如:

{
  "severity": "INFO",
  "timestamp": "2021-08-18T09:38:34.016614425Z",
  "caller": "dbscan/dbscan.go:82",
  "message": "Query",
  "method": "GET",
  "uri": "/api/v1/test",
  "path": "/api/v1/test",
  "correlation-id": "2021435824-1629279514010580579-448",
  "rowCount": 4,
  "pid": 679135,
  "sql": "SELECT id FROM test WHERE name = ANY(::varchar[])",
  "args": [
    [
      "aaa",
      "bbb",
      "ccc",
      "ddd"
    ]
  ],
  "time": 3282419,
  "logging.googleapis.com/labels": {},
  "logging.googleapis.com/sourceLocation": {
    "file": "/go/pkg/mod/github.com/georgysavva/scany@v0.2.4/dbscan/dbscan.go",
    "line": "82",
    "function": "github.com/georgysavva/scany/dbscan.processRows"
  }
}

但是,我可以通过 kubectl 实用程序在 GKE 控制台中看到上述消息。

此外,我可以在 GCP 日志记录中看到以下日志消息:

{
  "severity": "INFO",
  "timestamp": "2021-08-18T09:41:48.695923055Z",
  "caller": "puddle@v1.1.1/pool.go:470",
  "message": "Dialing PostgreSQL server",
  "host": "0.0.0.0",
  "logging.googleapis.com/labels": {},
  "logging.googleapis.com/sourceLocation": {
    "file": "/go/pkg/mod/github.com/jackc/puddle@v1.1.1/pool.go",
    "line": "470",
    "function": "github.com/jackc/puddle.(*Pool).constructResourceValue"
  }
}

我不明白是什么阻止了此消息显示在 GCP 日志记录控制台中...

我已经尝试重现,一旦我删除了“时间”字段(不是“时间戳”),就可以让 JSON 片段定期记录。我怀疑“时间”字段中值的格式(“时间”:3282419)不匹配导致日志无法在云日志记录中生成。有关信息,请参阅 Time-related fields