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_json prepends logs with whitespace #9489

Closed
gmichalec-pandora opened this issue Dec 1, 2020 · 3 comments
Closed

log_json prepends logs with whitespace #9489

gmichalec-pandora opened this issue Dec 1, 2020 · 3 comments
Labels
stage/accepted Confirmed, and intend to work on. No timeline committment though. theme/logging type/bug
Milestone

Comments

@gmichalec-pandora
Copy link

gmichalec-pandora commented Dec 1, 2020

Nomad version

Nomad v0.12.5+ent

Operating system and Environment details

Debian Buster

Issue

When enabling log_json = true in the server or client configs, it looks like the log output has a number of spaces at the beginning.

$ sudo journalctl -r -u nomad
-- Logs begin at Mon 2020-11-30 18:15:04 PST, end at Tue 2020-12-01 15:05:08 PST. --
Dec 01 15:05:02 dc6-docker3 nomad[28947]:     {"@level":"debug","@message":"request complete","@module":"http","@timestamp":"2020-12-01T15:05:02.049190-08:00","duration":14194187,"method":"GET","path":"/v1/node/df64379a-2fa8-811c-5656-bdf6268428e7/allocations"}
Dec 01 15:05:02 dc6-docker3 nomad[28947]:     {"@level":"debug","@message":"request complete","@module":"http","@timestamp":"2020-12-01T15:05:02.030335-08:00","duration":787602,"method":"GET","path":"/v1/agent/self"}
Dec 01 15:05:01 dc6-docker3 nomad[28947]:     {"@level":"debug","@message":"request complete","@module":"http","@timestamp":"2020-12-01T15:05:01.876159-08:00","duration":679382,"method":"GET","path":"/v1/node/df64379a-2fa8-811c-5656-bdf6268428e7"}
Dec 01 15:05:01 dc6-docker3 nomad[28947]:     {"@level":"debug","@message":"request complete","@module":"http","@timestamp":"2020-12-01T15:05:01.864813-08:00","duration":599042,"method":"GET","path":"/v1/agent/self"}

This requires extra config on our log ingester (logstash) in order to parse the JSON, as it assumes a JSON log begins with "{". Not a huge issue, but I can't think of a reason why one would ever want extra whitespace in a JSON-formatted log

@tgross
Copy link
Member

tgross commented Dec 2, 2020

Hi @gmichalec-pandora! Thanks for reporting this. It looks like a bug somewhere in the setup of the logger in command.go. We'll take a look, but if you're up for submitting a PR for a fix I'd be happy to review as well.

@tgross tgross added type/bug theme/logging stage/accepted Confirmed, and intend to work on. No timeline committment though. labels Dec 2, 2020
@tgross tgross added this to the 1.0.3 milestone Jan 26, 2021
@tgross
Copy link
Member

tgross commented Jan 26, 2021

Closed by #9795 and this will ship in the next standard patch release.

@tgross tgross closed this as completed Jan 26, 2021
@github-actions
Copy link

I'm going to lock this issue because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
stage/accepted Confirmed, and intend to work on. No timeline committment though. theme/logging type/bug
Projects
None yet
Development

No branches or pull requests

2 participants