-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Description
There are two existing, but stale, issues that bear on this, namely #853 and #1218, but I thought it'd be worth creating something anew with a clear set of proposals.
I help to run NSQ in Google Kubernetes Engine (GKE). NSQ writes its log messages to standard error (stderr) and these log messages are ingested through Google Operations Suite (formerly Stackdriver) for viewing and querying in Google Cloud Logging. The documentation for Google Operations Suite says that
Severities: By default, logs written to the standard output are on the INFO level and logs written to the standard error are on the ERROR level. Structured logs can include a severity field, which defines the log's severity.
This maps to what I see: INFO-level logs emitted by NSQ are miscategorised as ERROR-level logs in Google Cloud Logging.
This could be solved if NSQ were capable of optionally emitting structured logs in JSON. This would allow us to parse, filter, and forward the logs as needed.
I think there are two natural approaches.
- NSQ could lift its minimum version of Go from 1.17 to 1.21; log/slog.JSONHandler could be used to optionally construct the logs.
- NSQ could continue to pin its minimum version of Go at 1.17; a structured logger (e.g., zerolog) could be used to optionally construct the logs.
In both cases, the option could be conditionally enabled by a new configuration flag, -log-json bool, for each component of NSQ.
I've no view on which implementation would be preferable, assuming either is desirable. I'd be happy to work towards either.