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

The output for version flag is printed on stderr #912

Closed
nkn1111 opened this issue May 18, 2022 · 6 comments · Fixed by #928
Closed

The output for version flag is printed on stderr #912

nkn1111 opened this issue May 18, 2022 · 6 comments · Fixed by #928

Comments

@nkn1111
Copy link

nkn1111 commented May 18, 2022

Was facing an issue with the version check for the exporter. But found a similar issue on node_exporter issues which is already fixed. Linking the same here prometheus/node_exporter#1271

Can we do the same fix here?

Host operating system: Linux 3.10.0-1062.12.1.el7.x86_64 #1 SMP Tue Feb 4 23:02:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

blackbox_exporter version: blackbox_exporter, version 0.20.0 (branch: HEAD, revision: 91372eb)

What is the blackbox.yml module config.

What is the prometheus.yml scrape config.

What logging output did you get from adding &debug=true to the probe URL?

What did you do that produced an error?

Register the version output via ansible and display it using debug.
"cmd": [
"/usr/local/bin/blackbox_exporter",
"--version"
]

What did you expect to see?

"stdout": "blackbox_exporter, version 0.20.0

What did you see instead?

"stderr": "blackbox_exporter, version 0.20.0

@mem
Copy link
Contributor

mem commented May 18, 2022

There's a relatively straightforward "fix" for this:

kingpin.CommandLine.UsageWriter(os.Stdout)

But it's worth nothing that this is NOT what Prometheus (or promtool, etc) does.

Looking thru the discussion in the other issue, it was changed to accommodate this request, even if the specific issue being reported is fixed by:

"cmd": [ "sh", "-c", "/usr/local/bin/blackbox_exporter --version 2>&1" ]
"cmd": [ "sh", "-c", "/usr/local/bin/blackbox_exporter", "--version", "2>&1" ]  // maybe this

(quoting might need to be different, not sure how ansible processes this)

@nkn1111
Copy link
Author

nkn1111 commented May 20, 2022

Thank you. I might have found a workaround for my issue on ansible by adding multiple conditions to check both stdout and stderr. Since the Prometheus and other subsidiaries of Prometheus are showing the version output on stdout, It makes sense to have the same in here as well. Can you consider this improvement in a future release?

@nkn1111 nkn1111 closed this as completed May 20, 2022
@roidelapluie roidelapluie reopened this May 20, 2022
@roidelapluie
Copy link
Member

Yes, are you willing to contribute this change to the project? Thanks!

@roidelapluie
Copy link
Member

But it's worth nothing that this is NOT what Prometheus (or promtool, etc) does.

It was changed in Prometheus: prometheus/prometheus#8542 and per dev summit, we want it everywhere.

@nkn1111
Copy link
Author

nkn1111 commented May 24, 2022

Hey! I missed this update. TBH I don't have prior knowledge in go lang. To save you some time, it's better for someone familiar with the exporter code to raise a PR. TIA.

mem added a commit that referenced this issue Jun 14, 2022
Following the change in
prometheus/prometheus#8542 blackbox_exporter
will send all usage out to stdout, not stderr.

Fixes: #912
Signed-off-by: Marcelo E. Magallon <[email protected]>
@mem mem closed this as completed in #928 Jun 18, 2022
mem added a commit that referenced this issue Jun 18, 2022
Following the change in
prometheus/prometheus#8542 blackbox_exporter
will send all usage out to stdout, not stderr.

Fixes: #912
Signed-off-by: Marcelo E. Magallon <[email protected]>
@nkn1111
Copy link
Author

nkn1111 commented Jun 20, 2022

Thank you so much @mem @roidelapluie

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

Successfully merging a pull request may close this issue.

3 participants