Cannot include Prometheus metrics in spring boot 2 (version 2.0.0.M7)

心不动则不痛 提交于 2019-12-05 18:51:10

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.

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>

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')
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!