java中普罗米修斯的错误(弹簧执行器)
Posted
技术标签:
【中文标题】java中普罗米修斯的错误(弹簧执行器)【英文标题】:Error from promtheus in java (spring acuator) 【发布时间】:2020-12-13 23:10:29 【问题描述】:我在我的 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
依赖项)时,我没有出现此错误。
【问题讨论】:
【参考方案1】:我通过将 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].
所以我发现了问题。我为所有指标添加了一个通用标签。去掉通用标签后,错误解决。
【讨论】:
以上是关于java中普罗米修斯的错误(弹簧执行器)的主要内容,如果未能解决你的问题,请参考以下文章
普罗米修斯中的警报管理器给出退出代码错误并忽略普罗米修斯中警报管理器的分配
我在 strconv.ParseFloat 中收到错误:解析“2\r”:无效语法普罗米修斯