Node_exporter: --version to stderr?

Created on 26 Feb 2019  路  5Comments  路  Source: prometheus/node_exporter

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 +++

Host operating system: output of uname -a

CentOS 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 version: output of node_exporter --version

node_exporter, version 0.17.0 (branch: HEAD, revision: f6f6194a436b9a63d0439abc585c76b19a206b21)
  build user:       root@322511e06ced
  build date:       20181130-15:51:33
  go version:       go1.11.2

node_exporter command line flags

_none_

Are you running node_exporter in Docker?

no

What did you expect to see?

Version output on stdout.

What did you see instead?

Version output on stderr.

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].

All 5 comments

Looks like it's because kingpin (our flag library) uses stderr for its version output by default:

https://github.com/prometheus/prometheus/blob/master/vendor/gopkg.in/alecthomas/kingpin.v2/app.go#L255:23

https://github.com/prometheus/prometheus/blob/master/vendor/gopkg.in/alecthomas/kingpin.v2/app.go#L55

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.

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..

Was this page helpful?
0 / 5 - 0 ratings