I followed the documentation here (https://docs.spring.io/spring-boot/docs/2.0.0.RC1/reference/htmlsingle/#production-ready-endpoints-enabling-endpoints) and made sure application.yml file has the below
management:
metrics:
export:
prometheus:
enabled: true
endpoints:
web:
expose:
health, info, httptrace, metrics, threaddump, mappings, prometheus
As per the documentation (https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/actuator-api/html/#prometheus) the following doesn't work.
curl 'http://localhost:8080/actuator/prometheus' -i
I get 404 Handler mapping not found exception. Can someone please let me know how to enable prometheus endpoint for scraping purposes and what URL endpoint I need to use to test it out?
o.s.w.r.r.m.a.RequestMappingHandlerMapping[276] - Did not find handler method for [/actuator/prometheus]
All other endpoints health, info, httptrace, threaddump, mappings are working perfectly fine.
A bit late - but just for the record - I can verify that this works now in 2.0.0.RELEASE.
Dependencies (gradle):
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('io.micrometer:micrometer-registry-prometheus')
application.yaml (reference)
management:
endpoints:
web:
exposure:
include: health,info,prometheus
I also tested with RC1 - the prometheus endpoint does not show up for some reason - just as @ROCKY explained.
There's some things you could check:
Have you added the necessary MeterRegistry
implementation so that the Prometheus "subsystem" of the Micrometer
instrumentation library is present? (The Micrometer library is powering the Actuator implementation as of Spring Boot 2.0)
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
Without a specific MeterRegistry
implementation you just end up with the regular /actuator/metrics
endpoint powered by the SimpleMeterRegistry
implementation.
Have you actually placed the mentioned properties in a application.[yml,yaml]
file instead of application.properties
? (I just stumbled upon the same with a fresh demo project generated with Spring Initializr.)
spring boot does not expose prometheus endpoint by default even if you have >micrometer-registry-prometheus
in you classpath.
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
you need to explicit tell spring boot to expose prometheus endpoint by below property.
management.endpoints.web.exposure.include=health,info,metrics,prometheus
I experienced the same problem and managed to fix it by adding "include" tag into the configuration:
management: metrics: export: prometheus: enabled: true endpoints: web: exposure: include: prometheus,info,metrics,threaddump
Had the same problem when I upgraded my application from 1.5 to 2.1.3. Was able to fix it by following this Spring Boot 2.0 Prometheus Backward Compatibility
You need micrometer-registry-prometheus
in your dependency list and add below to your SpringBootApplication class
@Bean
public CollectorRegistry collectorRegistry() {
return CollectorRegistry.defaultRegistry;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With