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

--version to stderr? #1271

Closed
till opened this issue Feb 26, 2019 · 7 comments
Closed

--version to stderr? #1271

till opened this issue Feb 26, 2019 · 7 comments

Comments

@till
Copy link

till commented Feb 26, 2019

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.

@juliusv
Copy link
Member

juliusv commented Feb 26, 2019

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

@till
Copy link
Author

till commented Feb 26, 2019

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

@till
Copy link
Author

till commented Feb 26, 2019

Ah, seems like this will change upstream in kingpin.v3:
alecthomas/kingpin#90
alecthomas/kingpin@9f68dc0

@SuperQ
Copy link
Member

SuperQ commented Feb 26, 2019

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

@till
Copy link
Author

till commented Feb 28, 2019

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

@bmillemathias
Copy link

Hello,
I think this "issue" was fixed as in version 1.2.0 the version is output on stdout

[pid 14307] 06:30:45.240037 write(1, "node_exporter, version 1.2.0 (branch: HEAD, revision: 12968948aec1e2b216a2ecefc45cf3a50671aecb)
  build user:       root@6b17174de526
  build date:       20210715-16:35:54\n  go version:       go1.16.6
  platform:         linux/amd64\n", 233) = 233

@discordianfish
Copy link
Member

@bmillemathias Thanks for letting us know. I'll close the issue then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants