Cannot include Prometheus metrics in spring boot 2 (version 2.0.0.M7)
Solution 1
Did you add micrometer-registry-prometheus
to your dependecies?
Micrometer has a pluggable architecture where you need to define (by plugging dependencies) what monitoring system you'd like to work with. (You can even add multiple, not just one.)
Btw, you should be switching to Spring Boot 2.0.0.RC1
. That's the current one as of this writing.
Solution 2
I had trouble initiating micrometer with Springboot 2. x.
These changes in my project helped me to expose the metrics atactuator/prometheus
endpoint
These are the changes in my application.properties file
management.endpoints.web.exposure.include=*
management.endpoint.metrics.enabled=true
My build.gradle file included
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('io.micrometer:micrometer-registry-prometheus')
Solution 3
Edit: Since I gave this answer a lot has changed. It was valid for 2.0.0.RC1. Please read the documentation https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-metrics.html
If above solution doesn't work for someone try this: I had the same issue with Spring Boot 2.0.0.RC1, spring-boot-starter-web and of course spring-boot-starter-actuator.
My application.properties file read:
management.endpoints.web.expose=prometheus,metrics,info,health
In my pom file I had additionally:
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient</artifactId>
<version>0.2.0</version>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<version>0.12.0.RELEASE</version>
</dependency>
Prometheus metrics under /actuator/prometheus where only shown after I had switched to the newest version of micrometer-registry-prometheus:
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<version>1.0.0-rc.9</version>
</dependency>
makson
Updated on June 23, 2022Comments
-
makson almost 2 years
Cannot include Prometheus metrics in spring boot 2 (version 2.0.0.M7) project.
According micrometer docs added spring-boot-starter-actuator dependency and in application.yaml added management.endpoints.web.expose: prometheus but when calling /actuator/prometheus get
{ "timestamp": 1518159066052, "path": "/actuator/prometheus", "message": "Response status 404 with reason \"No matching handler\"", "status": 404, "error": "Not Found" }
Tell me please why I wasn't getting prometheus metrics?
-
makson over 6 yearsyes, I added
micrometer-registry-prometheus
dependency, but it didn't solve my issue. In documentation foundendpoints.prometheus.id: micrometheus
, but in application.yaml I wasn't getting it. -
mweirauch over 6 years@makson What "web" technology are you using? When I test with
spring-boot-starter-web
it works with2.0.0.M7
and also with2.0.0.RC1
. But when I test withspring-boot-starter-jersey
a 404 is spit out. The actuator endpoints aren't registered. You need to add/register aResourceConfig
Bean to your context in order for theJerseyAutoConfiguration
to kick in. -
makson over 6 yearsI am using
RouterFunctions
andspring-boot-starter-webflux
. After update spring to2.0.0.RC1
all work. Thanks. -
DerMiggel about 6 yearsI think the property
management.endpoints.web.expose
should instead bemanagement.endpoints.web.exposure.include
with Spring Boot 2.0.0.RELEASE, shouldn't it? And in the meantime there has also been a release ofmicrometer-registry-prometheus
, at the time of writing it's1.0.1
. -
Ashley Frieze almost 5 yearsDerMiggel - I think you're right. @cholland can you amend your answer? I had a false-start with it.