prom-client icon indicating copy to clipboard operation
prom-client copied to clipboard

Service discovery is the responsibility of Prometheus

Open brian-brazil opened this issue 8 years ago • 9 comments

https://github.com/siimon/prom-client#default-labels-segmented-by-registry indicates that this library has functionality to allow setting target labels. This is an anti-pattern in Prometheus as that's the role of service discovery/relabelling, and a client library should not facilitate this anti-pattern. This functionality should be removed.

brian-brazil avatar Mar 26 '18 08:03 brian-brazil

It came from #83 (feature request) and #137 (PR), cc @goofballLogic @nwest1 thoughts?

SimenB avatar Mar 26 '18 09:03 SimenB

Thanks for the mention -

Bottom-line, this simplified the code necessary to emit metrics. If it was removed, it would mean more complexity and repetition in our own code, and no (easy) ability to label default metrics in a way we would expect.

Due to timelines/prioritization this was a feature we found useful - especially when not having access to modify prometheus config.

Would a note about the recommended approach be sufficient here without a full removal?

nwest1 avatar Mar 26 '18 17:03 nwest1

Would a note about the recommended approach be sufficient here without a full removal?

This is such a common misunderstanding of the Prometheus architecture that it should be removed. You should switch to relabelling for this.

brian-brazil avatar Mar 26 '18 18:03 brian-brazil

I would like to point out that there is a legitimate use case for using prom-client's default labels feature:

When using node cluster node, it can be used to apply a "worker" label with the worker id. This cannot be done outside of prom-client using regular prometheus relabeling.

All of the official prometheus client libraries are for languages that are multi-threaded (rather than multi-process), so they don't need this feature.

benny-medflyt avatar Jan 14 '19 14:01 benny-medflyt

The Python client's multi-process mode handles this internally. Instrumentation shouldn't have to care how exposition is done.

brian-brazil avatar Jan 14 '19 14:01 brian-brazil

The Python client's multi-process mode handles this internally. Instrumentation shouldn't have to care how exposition is done.

I would be happy if prom-client would also handle this internally and automatically :+1:

benny-medflyt avatar Jan 14 '19 14:01 benny-medflyt

Is there support for the multi-target pattern in this library? It doesn't seem like there's any way to pass parameters into exporters with this client, and that can be a blocker for certain setups

forresthopkinsa avatar Sep 01 '21 06:09 forresthopkinsa