-
Notifications
You must be signed in to change notification settings - Fork 4.1k
log: implement flag that outputs all log messages as structured JSON #44755
Copy link
Copy link
Closed
Labels
A-loggingIn and around the logging infrastructure.In and around the logging infrastructure.A-monitoringC-enhancementSolution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)O-communityOriginated from the communityOriginated from the community
Description
Our current log format is nicely dense, and our engineers are used to it. According to @piyush-singh, the format can be daunting for users, some of whom have wished that we logged in more of a standard format. There is a lot of information and it isn't self-documenting in each log message.
It's becoming increasingly common for services to log in structured JSON. The CockroachDB server should accept a log format flag that permits our default and also structured JSON. When the log format is set to JSON, we should emit a JSONified payload. For example, instead of
I200205 15:42:44.792844 299 server/status/runtime.go:498 [n1] runtime stats: 177 MiB RSS, 206 goroutines, 68 MiB/50 MiB/116 MiB GO alloc/idle/total, 55 MiB/73 MiB CGO alloc/total, 27.4 CGO/sec, 0.6/0.5 %(u/s)time, 0.0 %gc (0x), 39 KiB/39 KiB (r/w)net
We'd output
{"severity": "info", "timestamp": "20200205 15:42:44.792844", "thread": 299, "line": "server/status/runtime.go:498", "node": 1, "message": "runtime stats: 177 MiB RSS, 206 goroutines, 68 MiB/50 MiB/116 MiB GO alloc/idle/total, 55 MiB/73 MiB CGO alloc/total, 27.4 CGO/sec, 0.6/0.5 %(u/s)time, 0.0 %gc (0x), 39 KiB/39 KiB (r/w)net"}
This should be relatively straightforward, and allow for easy log ingestion into observability systems like Splunk or Datadog.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-loggingIn and around the logging infrastructure.In and around the logging infrastructure.A-monitoringC-enhancementSolution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)O-communityOriginated from the communityOriginated from the community