java 中的普罗米修斯错误(spring 执行器)
Error from promtheus in java (spring acuator)
我在我的 spring 启动应用程序中启用并配置了 Spring 执行器和 Prometheus 端点。但是我收到一个错误,Prometheus 要求所有具有相同名称的仪表都具有相同的标签键集。但不幸的是 Spring 执行器不会为 jvm_gc_pause_seconds
执行此操作。
我正在使用:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.1.RELEASE</version>
</parent>
和
<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>
这是我的错误信息:
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(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(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(JvmGcMetrics.java:151) │
│ at java.management/sun.management.NotificationEmitterSupport.sendNotification(Unknown Source) │
│ at jdk.management/com.sun.management.internal.GarbageCollectorExtImpl.createGCNotification(Unknown Source)
有什么想法吗?!
当我删除 Prometheus 端点配置(micrometer-registry-prometheus
依赖项)时,我没有出现此错误。
我通过将 micrometer-registry-prometheus
从 1.5.1 更新到 1.5.4
解决了我的问题
有了这个更新,错误消息更容易说出来:
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].
所以我发现了问题。我为所有指标添加了一个通用标签。去掉common标签后,错误解决
我在我的 spring 启动应用程序中启用并配置了 Spring 执行器和 Prometheus 端点。但是我收到一个错误,Prometheus 要求所有具有相同名称的仪表都具有相同的标签键集。但不幸的是 Spring 执行器不会为 jvm_gc_pause_seconds
执行此操作。
我正在使用:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.1.RELEASE</version>
</parent>
和
<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>
这是我的错误信息:
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(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(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(JvmGcMetrics.java:151) │
│ at java.management/sun.management.NotificationEmitterSupport.sendNotification(Unknown Source) │
│ at jdk.management/com.sun.management.internal.GarbageCollectorExtImpl.createGCNotification(Unknown Source)
有什么想法吗?!
当我删除 Prometheus 端点配置(micrometer-registry-prometheus
依赖项)时,我没有出现此错误。
我通过将 micrometer-registry-prometheus
从 1.5.1 更新到 1.5.4
有了这个更新,错误消息更容易说出来:
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].
所以我发现了问题。我为所有指标添加了一个通用标签。去掉common标签后,错误解决