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

Nomad duplicates logs to stdout when enable_syslog is true #15657

Open
rodrigol-chan opened this issue Jan 3, 2023 · 4 comments
Open

Nomad duplicates logs to stdout when enable_syslog is true #15657

rodrigol-chan opened this issue Jan 3, 2023 · 4 comments
Labels
stage/accepted Confirmed, and intend to work on. No timeline committment though. theme/config theme/logging type/bug

Comments

@rodrigol-chan
Copy link

Nomad version

Nomad v1.4.3 (f464aca721d222ae9c1f3df643b3c3aaa20e2da7)

Operating system and Environment details

$ lsb_release  -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.1 LTS
Release:        22.04
Codename:       jammy

Issue

When enable_syslog is true, Nomad logs both to syslog and to stdout.

Reproduction steps

journalctl shows this but log lines aren't always interspersed one by one but rather in blocks. It's easy to check by passing _TRANSPORT.

Expected Result

$ sudo journalctl --lines=5 --unit=nomad.service _TRANSPORT=syslog
Jan 03 16:07:08 nomad-client-camel nomad[11714]:  agent: (runner) starting
Jan 03 16:07:08 nomad-client-camel nomad[11714]:  agent: (clients) disabling vault SSL verification
Jan 03 16:07:08 nomad-client-camel nomad[11714]:  agent: (runner) creating watcher
Jan 03 16:07:08 nomad-client-camel nomad[11714]:  agent: (runner) starting
Jan 03 16:07:08 nomad-client-camel nomad[11714]:  agent: (runner) starting
$ sudo journalctl --lines=5 --unit=nomad.service _TRANSPORT=stdout
$

Actual Result

$ sudo journalctl --lines=5 --unit=nomad.service _TRANSPORT=syslog
Jan 03 16:07:08 nomad-client-camel nomad[11714]:  agent: (runner) starting
Jan 03 16:07:08 nomad-client-camel nomad[11714]:  agent: (clients) disabling vault SSL verification
Jan 03 16:07:08 nomad-client-camel nomad[11714]:  agent: (runner) creating watcher
Jan 03 16:07:08 nomad-client-camel nomad[11714]:  agent: (runner) starting
Jan 03 16:07:08 nomad-client-camel nomad[11714]:  agent: (runner) starting
$ sudo journalctl --lines=5 --unit=nomad.service _TRANSPORT=stdout
Jan 03 16:07:08 nomad-client-camel nomad[11714]:     2023-01-03T16:07:08.567+0100 [INFO]  agent: (runner) starting
Jan 03 16:07:08 nomad-client-camel nomad[11714]:     2023-01-03T16:07:08.567+0100 [WARN]  agent: (clients) disabling vault SSL verification
Jan 03 16:07:08 nomad-client-camel nomad[11714]:     2023-01-03T16:07:08.568+0100 [INFO]  agent: (runner) creating watcher
Jan 03 16:07:08 nomad-client-camel nomad[11714]:     2023-01-03T16:07:08.568+0100 [INFO]  agent: (runner) starting
Jan 03 16:07:08 nomad-client-camel nomad[11714]:     2023-01-03T16:07:08.568+0100 [INFO]  agent: (runner) starting
$

Job file (if appropriate)

Not applicable.

Nomad Server logs (if appropriate)

Not applicable.

Nomad Client logs (if appropriate)

Not applicable.

@tgross tgross added this to Needs Triage in Nomad - Community Issues Triage via automation Jan 3, 2023
@tgross
Copy link
Member

tgross commented Jan 3, 2023

Hi @rodrigol-chan! Thanks for opening this issue. I've verified the behavior as well -- it looked from your logs that it was specifically consul-template logs, but I see this for any logs. It's particularly easy to see if you run nomad in the foreground, as the logs will go to the journal.

I suspect the problem here is just one of design intent. If you're on a host with journald, we're assuming you're not also sending via syslog (or at least, if you are you're not having journald collect the syslog as well). Maybe we need a way to suppress "normal" stdout/stderr output as well. As a workaround in the meantime, your systemd unit could redirect stdout/stderr to /dev/null.

@tgross tgross moved this from Needs Triage to Needs Roadmapping in Nomad - Community Issues Triage Jan 3, 2023
@tgross tgross added theme/config stage/accepted Confirmed, and intend to work on. No timeline committment though. labels Jan 3, 2023
@rodrigol-chan
Copy link
Author

The main advantages about sending logs via syslog even when stdout is captured into the journal is one of log cohesion. Multiline logs sent via syslog are kept multiline, whereas e.g. stack traces are broken on line boundaries and show up as different messages. I'll try the workaround, thanks!

@tgross
Copy link
Member

tgross commented Jan 4, 2023

So really what you're looking for here is the ability to turn off stdout logging while leaving syslog logging on? Arguably this problem gets worse with #15625 b/c you could previously turn the log-level to "OFF" and have enable_syslog = true which will emit "INFO"-level only (and can't be configured until #15625 is merged). We'll probably merge that fix anyways and then visit implementing some kind of syslog-only flag.

@rodrigol-chan
Copy link
Author

Yes, that's exactly right. Thank you for looking into this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage/accepted Confirmed, and intend to work on. No timeline committment though. theme/config theme/logging type/bug
Projects
Status: Needs Roadmapping
Development

No branches or pull requests

2 participants