-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
*: Structured logging in JSON #1460
Comments
I haven't tried, but we should be able to add an implementation that uses slog guarded by build tags to 1.21+ and backwards compatible with 1.20. That would allow for an flag to enable json logging. We want to maintain compatibility with the last two go versions so that means 1.20+ for now, so that does constrain us somewhat but i'd love to see a PR for |
I'd be up for trying to introduce the feature; it may take a little while to find the time to finish it. Before I embark, which do you think matches the goal of NSQ closest, given that we can't just lift the minimum version of Go to 1.21? I'm inclined towards 4; it seems the least error-prone.
|
When we publish new official binaries, we do so with the latest stable release of Go. The only situation where any of this backwards compat matters is if someone is building their own binaries (my intuition is this is rare) or using As such, my recommendation would be (2), the "forward looking" approach with the least overhead that will benefit the most users. |
Lovely—thanks for the clear guidance. I'll try to have a solid stab at (2) soon. |
(Apologies for bumping, but I wanted to say that I've not forgotten about this at all—I've just been very busy.) |
@adamroyjones are you still working on this? If not, I'm happy to pick this one up |
@jclasley: I've not even started! I'm stretched, but not as I'd like. Please feel free to run with things. |
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
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.
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.
The text was updated successfully, but these errors were encountered: