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?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…