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
Introduce a config property to disable exemplars for Metrics of counter type #39759
Comments
I'm a bit puzzled here since exemplars for
So you should not have any problems with Because of @Bean
public IgnoreCountersExemplarSampler exemplarSampler(SpanContextSupplier spanContextSupplier) {
return new IgnoreCountersExemplarSampler(new DefaultExemplarSampler(spanContextSupplier));
} or if new IgnoreCountersExemplarSampler(spanContextSupplier); If you want to disable all exemplars, you can create a
Has anyone asked GKE, why they are using a Prometheus version this old? 2.50.1 is the current Prometheus Server version. |
Thanks for your input, @jonatan-ivanov . |
Please forgive me my ignorance, I didn't know that
Yes, I know, please see my answer in the SO question. I just think that
Yes, I know. You mentioned it in the SO answer. But this will disable exemplars for all metrics, right? I prefer to keep them for metrics where they were supported in Prometheus 2.41. A quote from GCP docs:
So, I would like to keep supported stuff in-place. Also, returning
I didn't know that. :(
To be honest, what I really want is to make sure that apps on Spring Boot 3.2+ will continue to be monitored on GCP. I already solved this problem for myself (see the workaround above). Probably not ideally, as you mentioned that my solution will disable exemplars on So, I wanted to create a solution that allows to solve this problem for anyone (not just me, and not only for GCP) without such workarounds. I think the problem of non-functional monitoring is important enough to justify the config property. But, as you mentioned that this solution will not just disable exemplars for Maybe it's not worth to do if it will require too many internal changes in Micrometer or Spring Boot. When these changes will finally be available in the next Spring Boot version, GCP (and I hope most other platforms) will already be upgraded to Prometheus 2.43+.
This question is flying in the air, but I do not know anyone from GKE team to ask such technical question. Maybe it's just a principle: "If it ain’t broke, don’t fix it." :) And thank you for you thoughtful input, @jonatan-ivanov! P.S. As you mentioned that |
I wanted to make sure that we are on the same page and I'm not missing something.
GCP ignoring exemplars on
This complicates things since I feel in order to solve this in Micrometer/Boot, Micrometer also needs to be changed since it should make
If you only use it for GCP which seems to be ignoring exemplars on
This is definitely something we should consider. I think a proper solution for this would be through content negotiation: releasing OpenMetrics 1.1 with the extra exemplars feature that Prometheus already supports, plus making the Prometheus Java Client return the extra exemplars if OpenMetrics 1.1 is requested and do not return them if OpenMetrics 1.0 is asked for. |
I think you are right and content negotiation is the right way to do it. Looking back, I think that when the ability to parse But such solution will probably require many Or, if older Prometheus would just ignore unknown parts of line (e.g. anything after |
There's nothing Spring Boot can here, right? I'm closing this issue. |
exemplar
s for Metrics of counter
type
There is no such content type, Open Metrics 1.1 does not exist (this should change in the future though).
Yeah, I don't know why Prometheus drops the whole scrape response instead of ignoring what is not supported. @mhalbritter I think in this particular case nothing Spring Boot can do here since @xak2000 needs existing exemplars and only wants to ignore the new ones (this also needs a change in Micrometer). Though there might be users in the future who will ask an enable flag for the whole exemplars functionality. |
Spring Boot 3.2 introduced broaden the exemplar support that requires Prometheus 2.43 or later.
This change raised problems for people who use an older version of Prometheus for one reason or another.
The problem is not just some features stoped to work. The metrics stopped to be scrapped completely as Prometheus older than 2.43 just ignores any counters that contain
exemplar
s.While older Prometheus versions are not officically supported by the Prometheus team, sometimes users are out of control of the Prometheus version they use. In such cases, you can't just ask users to update their Prometheus.
E.g. Managed Prometheus instance on GKE still have version 2.41. While they already started to work on the version upgrade, due to very inert nature of GKE updates, the "fix" will not be available in production earlier than 6 months from now. So, any company that wants to use Spring Boot 3.2/Micrometer 1.12 on GKE with the Managed Prometheus instance is forced to implement some workaround or metrics will be completely absent.
I think it's not very tolerant to force users to use older Spring Boot or Micrometer version if it is simple enough to give users a choice.
So, I propose to introduce a config property that will disable adding
exemplar
s to counter metrics, so the older versions of Prometheus will be able to scrape them.Known worarounds are described here. They imply either introducing a new actuator endpoint with
text/plain
content type (that doesn't supportexemplar
s at all, so it "fixes" the problem) or overriding some beans with an implementation, that disablesexemplar
s for all or only counter metrics.An example of implementation of
ExemplarSampler
bean that disablesexemplar
s only forcounter
metrics (they will still be enabled forhistogram
s):I implemented it as a
BeanPostProcessor
as it is a workaround for now, but it could be implemented as part ofspring-boot/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/prometheus/PrometheusMetricsExportAutoConfiguration.java
Lines 92 to 97 in 0bc5e27
Maybe there is a better way to conditionally disable adding of
exemplar
s to the/actuator/prometheus
response. Pinging @jonatan-ivanov as it is he, who suggested to create this feature request in the first place. I think he could have a very useful input on the topic.The text was updated successfully, but these errors were encountered: