-
Notifications
You must be signed in to change notification settings - Fork 41k
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
MeterRegistry: same meter name with different tags is not reflected in /actuator/prometheus
#42830
Comments
Spring Boot itself knows very little about Prometheus and any limitations of its scrape format as it is handled by Micrometer and the underlying Prometheus library. You can observe the behavior that you've described by using Micrometer's PrometheusMeterRegistry meterRegistry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
meterRegistry.counter("test_counter", "tag1", "value1");
meterRegistry.counter("test_counter", "tag1", "valueA", "tag2", "valueB");
System.out.println(meterRegistry.scrape());
meterRegistry.getMeters().forEach((meter) -> System.out.println(meter.getId())); The above will produce the following output:
As you can see, the If you believe that some improvements could be made in this area, please open a Micrometer issue. |
fyi: micrometer-metrics/micrometer#877 meterRegistry.counter("test_counter", "tag1", "value1", "tag2", "none");
meterRegistry.counter("test_counter", "tag1", "valueA", "tag2", "valueB"); Or you can use na, null, etc. to indicate that the value does not exists. |
@jonatan-ivanov @wilkinsona Still, it could make sense to inform the user of spring-boot what happened.
WDYT? |
I don't think such functionality belongs in Boot as the behaviour isn't specific to Boot. As demonstrated above, the behavior is reproducible with only Micrometer. If some logging is to be done anywhere, IMO, it should be done in Micrometer. |
@wilkinsona ok, thx! I'll go there :) |
Sorry for increasing the noise here but what you need might be already done in Micrometer, see: micrometer-metrics/micrometer#5228 |
omg @jonatan-ivanov that's perfect, thank you for that link :) |
Setup
Let's setup a simple spring-boot app:
build.gradle.kts
App.java
application.properties
The problem
When visiting
http://localhost:8080/actuator/metrics/test_counter
, we can seethat
availableTags
fortest_counter
was merged (tag1
andtag2
). That seems a sensible thing to do in our example.But Prometheus scrape endpoint
http://localhost:8080/actuator/prometheus
has only one first counter registered!
Expected behavior
This behavior seems unintuitive since
/actuator/prometheus
returns different data than/actuator/metrics/test_counter.
There is no log (on the debug level) that the second meter was ignored.
We feel that
/actuator/prometheus
should behave the same as/actuator/metrics/test_counter
and include merged tags for each registered meter.If it's a limitation of Prometheus itself, we would expect some kind of feedback for spring boot users—an exception that it's not allowed or a log saying that the meter was overridden/ignored.
The text was updated successfully, but these errors were encountered: