I enabled and configured Spring Actuator with Prometheus endpoint in my spring boot application. But I receive an error, that Prometheus requires that all meters with the same name have the same set of tag keys. But unfortunately Spring Actuator won't do that for jvm_gc_pause_seconds
.
I'm using:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.1.RELEASE</version>
</parent>
with
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
....
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-core</artifactId>
<version>1.5.1</version>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<version>1.5.1</version>
</dependency>
This is my error message:
java.lang.IllegalArgumentException: Prometheus requires that all meters with the same name have the same set of tag keys. There is already an existing meter named 'jvm_gc_pause_seconds' │
│ at io.micrometer.prometheus.PrometheusMeterRegistry.lambda$applyToCollector$17(PrometheusMeterRegistry.java:429) │
│ at java.base/java.util.concurrent.ConcurrentHashMap.compute(Unknown Source) │
│ at io.micrometer.prometheus.PrometheusMeterRegistry.applyToCollector(PrometheusMeterRegistry.java:413) │
│ at io.micrometer.prometheus.PrometheusMeterRegistry.newTimer(PrometheusMeterRegistry.java:196) │
│ at io.micrometer.core.instrument.MeterRegistry.lambda$timer$2(MeterRegistry.java:308) │
│ at io.micrometer.core.instrument.MeterRegistry.getOrCreateMeter(MeterRegistry.java:612) │
│ at io.micrometer.core.instrument.MeterRegistry.registerMeterIfNecessary(MeterRegistry.java:566) │
│ at io.micrometer.core.instrument.MeterRegistry.timer(MeterRegistry.java:306) │
│ at io.micrometer.core.instrument.Timer$Builder.register(Timer.java:539) │
│ at io.micrometer.core.instrument.binder.jvm.JvmGcMetrics.lambda$bindTo$1(JvmGcMetrics.java:151) │
│ at java.management/sun.management.NotificationEmitterSupport.sendNotification(Unknown Source) │
│ at jdk.management/com.sun.management.internal.GarbageCollectorExtImpl.createGCNotification(Unknown Source)
Any idea?!
I don't have this error when I remove the Prometheus endpoint configuration (micrometer-registry-prometheus
dependency).
Introducing Prometheus It is a time-series database, which stores a sequence of data points, across time. Prometheus… carrying the torch. It's generally used to store metrics and performance data from your applications. And this allows you to perform time-series analysis of metrics.
To enable Spring Boot actuator endpoints to your Spring Boot application, we need to add the Spring Boot Starter actuator dependency in our build configuration file. Maven users can add the below dependency in your pom. xml file. Gradle users can add the below dependency in your build.
Spring Boot Actuator is a sub-project of the Spring Boot Framework. It uses HTTP endpoints to expose operational information about any running application. The main benefit of using this library is that we get health and monitoring metrics from production-ready applications.
I solved my problem by updating micrometer-registry-prometheus
from 1.5.1 to 1.5.4
With this update the error message was more speakable:
Prometheus requires that all meters with the same name have the same set of tag keys. There is already an existing meter named 'jvm_gc_pause_seconds' containing tag keys [username, endpoint]. The meter you are attempting to register has keys [username, endpoint, service].
So I found the problem. I added a common tag to all metrics. After removing the common tag, the error was solved.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With