Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log: implement flag that outputs all log messages as structured JSON #44755

Closed
jordanlewis opened this issue Feb 5, 2020 · 2 comments · Fixed by #58126
Closed

log: implement flag that outputs all log messages as structured JSON #44755

jordanlewis opened this issue Feb 5, 2020 · 2 comments · Fixed by #58126
Assignees
Labels
A-logging In and around the logging infrastructure. A-monitoring C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) O-community Originated from the community

Comments

@jordanlewis
Copy link
Member

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.

@jordanlewis jordanlewis added A-cli A-logging In and around the logging infrastructure. labels Feb 5, 2020
@knz knz added the C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) label Feb 5, 2020
@aaron-crl
Copy link

Related: #28696

Structured log output (especially JSON) would be a huge boon to security monitoring too.

  • Enterprise SIEMS now natively consume JSON.
  • It enables consistent one event per line logging where the contents of the event may include encoded newlines.
  • It is a standard across cloud logging and metric providers and consumers such as CloudTrail and Stackdriver.

@SpokeyWheeler
Copy link

Execution time is currently in a very awkward place with the current format, too! But we are very interested in this FR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-logging In and around the logging infrastructure. A-monitoring C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) O-community Originated from the community
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants