gpt4 book ai didi

java - java中prometheus的错误( Spring 执行器)

转载 作者:行者123 更新时间:2023-12-03 23:44:44 24 4
gpt4 key购买 nike

我在 Spring Boot 应用程序中启用并配置了带有 Prometheus 端点的 Spring Actuator。但是我收到一个错误,即 Prometheus 要求所有具有相同名称的仪表都具有相同的标签键集。但不幸的是,Spring Actuator 不会为 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$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)
任何的想法?!
当我删除 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标签后,错误就解决了。

关于java - java中prometheus的错误( Spring 执行器),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63575808/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com