prometheus / client_golang

Prometheus instrumentation library for Go applications
https://pkg.go.dev/github.com/prometheus/client_golang
Apache License 2.0
5.34k stars 1.17k forks source link

Handle query parameter of a scrape #267

Open beorn7 opened 7 years ago

beorn7 commented 7 years ago

A prerequisite to #135, this is about the story how to handle scrape query parameter in general.

This should help to implement the blackbox exporter in a cleaner way, cf. https://prometheus.io/docs/instrumenting/writing_exporters/#deployment : “Note that it is only currently possible to write this type of exporter with the Python and Java client libraries (the blackbox exporter which is written in Go is doing the text format by hand, don’t do this).”

It could also help for the mesos exporter use case, see https://github.com/mesosphere/mesos_exporter/pull/22

brian-brazil commented 7 years ago

I strongly believe that cases like the blackbox exporter should be handled by a custom registry, (which wasn't possible in Go at the time that was written). Letting users pass arbitrary blobs down to collectors will only cause problems.

Letting users wrap endpoints for auth is an orthogonal problem.

beorn7 commented 7 years ago

But the blackbox exporter parses query params, and there is no clean way of doing that right now with the client library as is.

brian-brazil commented 7 years ago

There isn't and I don't think there should be. It's too use case specific.

beorn7 commented 7 years ago

I'll leave this open to vet later.

beorn7 commented 3 years ago

Update to current state of the art: Blackbox exporter is solving this with a new custom registry per scrape, see https://github.com/prometheus/blackbox_exporter/blob/master/main.go#L127 .

Also, see discussion starting here about passing a context down to collectors. Those could be used to pass down anything (for better or worse), including query parameters. I kind of like how contexts allow those things without any implication they should be used in the regular case (like an explicit function arguments for query parameters would do).

beorn7 commented 3 years ago

I mostly assigned this to myself as a “default” because I used to be the maintainer of this repo. Therefore, I'm un-assigning this from myself no. New maintainers @bwplotka & @kakkoyun, please deal with this as you see fit.