blackbox_exporter icon indicating copy to clipboard operation
blackbox_exporter copied to clipboard

Feature Request: Read http headers from file

Open JoniBecker opened this issue 2 years ago • 7 comments

Hello everyone,

in our current situation, we want to probe an endpoint that requires the http header "X-Api-Key": "someAPIkeyHere" to be set instead of a bearer token passed the usual way. It would be great if http headers could be read from a file (analogously to how bearer tokens and basic auth passwords can). We do not control the way authentication is handled, but during my last google session regarding this problem, this seemed to be a somewhat frequent way of doing it in some proprietary software.

We are operating under a strict GitOps workflow, so we are deploying the blackbox exporter using the community helm chart for the blackbox exporter. We manage SealedSecrets in Git to produce Secrets on Kubernetes that in turn are mounted into the blackbox exporter and then used as secret files for Basic Auth and/or bearer token files. In our idealised dream world the same mechanism would allow us to properly populate http header fields (or key: value pairs for the header).

In any case, thank you for your hard work. Working with the various prometheus components we have in place in our projects has been a real blast!

Edit: Just for clarification, the current "solution" we see in our case is to generate the whole configmap from a SealedSecret, whose corresponding decrypted Secret would replace the secret config which would get mounted as the config yaml for the container. Sadly this way makes it so that changing anything config-related means rebuilding the sealed secret manually and further diminishes the usefulness of GitOps since the actual configuration of the Blackbox exporter would not be reconstructable for someone with Git access only.

JoniBecker avatar Oct 21 '22 10:10 JoniBecker

similar feature for http body is PR'ed in https://github.com/prometheus/blackbox_exporter/pull/987, happy to review the PR for this :)

electron0zero avatar Nov 24 '22 11:11 electron0zero

Thanks for bringing this related issue to my attention. I have limited Go knowledge, but from a quick glance it seems to me like it might be easy enough to implement. Not sure if and when I will find the time, but since we are using the Blackbox Exporter in production maybe I can get a couple of hours off work to throw at this. :)

JoniBecker avatar Nov 24 '22 11:11 JoniBecker

Author of #987 here. I too have need for the feature described here and I'm halfway through writing a proof-of-concept implementation.

My question would be: What should be the file format for the header file described here? My first idea was yaml, but what we actually need is a simple 'key: value' file format to parse into a map[string]string. This, however, would require creating a parser for this file format (similar to what is described here), which seems excessive for this feature. I would value your input on this.

danteu avatar Nov 24 '22 12:11 danteu

Hey, sorry for the delayed response. Sadly, I was unable to get back to this earlier. My suggestion would've been to indeed write a simple parser for files containing key:value pairs, as you did. Hopefully, your work will facilitate the creation of a more general solution as hinted at in #989.

JoniBecker avatar Dec 01 '22 13:12 JoniBecker

@roidelapluie is there any PR or something we can track? because in the PR #989 you have mentioned that you are already working on such a feature

thanks

eloo avatar Dec 13 '22 16:12 eloo

Is this going to be added at some point? We also need this feature

druanoor avatar Apr 25 '23 11:04 druanoor

When this feature will be added?

shabuddinshaik avatar Apr 28 '24 23:04 shabuddinshaik