弹簧启动应用程序的普罗米修斯中未显示自定义千分尺指标

问题描述

我有一个 spring boot 应用程序,并且我已经配置了 prometheus 和 micrometer。

<dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-registry-prometheus</artifactId>
            <scope>runtime</scope>
</dependency>
<dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-core</artifactId>
            <version>1.5.5</version>
        </dependency>
<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

在 application.properties 中:

management.endpoints.web.exposure.include=*
management.endpoint.metrics.enabled=true
management.endpoint.prometheus.enabled=true
management.metrics.export.prometheus.enabled=true
management.endpoint.health.show-details=always

代码中:

long elapsedtimeInMilliSeconds = System.currentTimeMillis() - start;
Metrics.timer("mymethodlatency_timer","class",this.getClass().getSimpleName(),"method",new Exception().getStackTrace()[0].getmethodName())
                    .record(elapsedtimeInMilliSeconds,TimeUnit.MILLISECONDS);

Class 不是弹簧组件。它是一个 POJO 类。 当我在本地运行这个应用程序时,我可以在本地配置的 prometheus 仪表板上看到这个指标。但是部署在aws+kubernetes环境下,metrics不显示

遗漏的部分是什么?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)