Add an easy way to define preset labels globally#174
Add an easy way to define preset labels globally#174stefansundin wants to merge 1 commit intoprometheus:masterfrom
Conversation
Signed-off-by: Stefan Sundin <stefan@stefansundin.com>
1 similar comment
This should be done as target labels on the Prometheus side, an application doesn't know how a scraper views it. |
|
To expand on Brian's comment, it's usually advised that metrics exported from an application are label-less unless absolutely necessary. As I'm not sure how familiar you are with Prometheus, it's worth saying that the time series you view in prometheus will have both the labels exported in your application, plus what is applied during the service discovery relabelling that you configure in prometheus. An example But have the following labels once ingested by prometheus: It's often a better idea to have your labels be assigned during the relabelling than use 'default' labels that application itself configures. Adding a feature like this PR would suggest that the latter method is a good idea, when we're keen to discourage that pattern. Let me know if any of this doesn't make sense. |
|
FWIW, this setting would simplify some code I am currently adding to an application. |
|
Hey @genebean, can you help us understand what you're trying to solve so we can develop a use case for this? Right now we want people to be using service discovery relabelling to apply these types of metric label, so unless we find a circumstance that can't be solved with that method, we'll be unable to consider merging this. |
|
I agree with the views of @lawrencejones and @brian-brazil. We are trying to actively discourage this usage, as the preferred approach is to use service discovery relabelling. |
|
I'm closing this PR since the consensus seems to be against doing this. |
Hi again,
With this change, I will be able to do the following:
And easily see the version that my metrics were emitted by. I can now clearly see if behavior changed when the version changed, and the code will be pretty clean too.
I wish that I wouldn't need to set both
:labelsand:preset_labels.. It feels overly verbose. I almost thinkpreset_labels.keysshould be merged intolabelsautomatically, but that would be a breaking change, so I didn't try to include it here.I don't know if there are any philosophical objections to something like this, but I figured that I should throw it out there. Thanks!