Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
357 views
in Technique[技术] by (71.8m points)

amazon web services - Custom micrometer metrics not showing up in prometheus for a spring boot application

I have a spring boot application, and I have configured prometheus and 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>

In 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

In code:

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

Class is not a spring component. Its a POJO class. When I run this application locally, I can see this metrics at prometheus dashboard configured locally. But when it is deployed in aws+kubernetes environment, metrics doesn't show up.

What can be the missing part?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...