Is there a good reason to have --version go to stderr? I've been trying to patch up some ansible roles to install node_exporter and I spend some time trying to figure out why I couldn't grab the output the other day.
So I wanted to make a ticket and ask.
I can confirm it's stderr (just wondering if this is maybe bug or intentional):
# strace output, see "write(2, ..."
mmap(NULL, 262144, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fc9454a8000
write(2, "node_exporter, version 0.17.0 (b"..., 202node_exporter, version 0.17.0 (branch: HEAD, revision: f6f6194a436b9a63d0439abc585c76b19a206b21)
build user: root@322511e06ced
build date: 20181130-15:51:33
go version: go1.11.2
) = 202
exit_group(0) = ?
+++ exited with 0 +++
uname -aCentOS Linux release 7.6.1810 (Core)
Linux host 3.10.0-957.el7.x86_64 #1 SMP Thu Nov 8 23:39:32 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
node_exporter --versionnode_exporter, version 0.17.0 (branch: HEAD, revision: f6f6194a436b9a63d0439abc585c76b19a206b21)
build user: root@322511e06ced
build date: 20181130-15:51:33
go version: go1.11.2
_none_
no
Version output on stdout.
Version output on stderr.
Looks like it's because kingpin (our flag library) uses stderr for its version output by default:
It's possible to override the usageWriter (https://github.com/prometheus/prometheus/blob/master/vendor/gopkg.in/alecthomas/kingpin.v2/app.go#L144), but then also the other usage messages would be written to stdout...
@juliusv good to know. Don't want to bikeshed, etc. but stdout seems more appropriate. But either way, if this is a _won't fix_, I am ok too.
Ah, seems like this will change upstream in kingpin.v3:
https://github.com/alecthomas/kingpin/issues/90
https://github.com/alecthomas/kingpin/commit/9f68dc0167caf0e2b2765183636f38d4780e9d44
We also log to stderr, which I've always found to be a strange thing.
This is something that we would want to keep consistent across all Prometheus components, so we should probably start this as a conversation on [email protected].
@SuperQ I've shared my "feedback", I agree stdout would be more appropriate and I think it's "expected". Also less to think about when running this in a container, etc..
Most helpful comment
We also log to stderr, which I've always found to be a strange thing.
This is something that we would want to keep consistent across all Prometheus components, so we should probably start this as a conversation on [email protected].