Search code examples
spring-bootspring-cloudhystrixprometheusmicrometer

Metrics don't show up on the /prometheus endpoint


I have two services, ping and pong where ping sends requests to pong. This metric shows up on the /metrics endpoint for the ping service:

gauge.servo.hystrix.hystrixcommand.http://pong.pongclient#hello().90

but it doesn't appear on the /prometheus endpoint. Other metrics appear on this endpoint, but not the servo metrics with information about Feign/Hystrix http requests.

How do I get those metrics to appear on the /prometheus endpoint?

I have the following dependencies on my build.gradle

compile 'org.springframework.boot:spring-boot-starter-web'
compile 'org.springframework.boot:spring-boot-starter-actuator'
compile 'org.springframework.cloud:spring-cloud-starter-eureka'
compile 'org.springframework.cloud:spring-cloud-starter-hystrix'
compile 'org.springframework.cloud:spring-cloud-starter-feign'
compile 'org.springframework.retry:spring-retry'
compile "io.micrometer:micrometer-core:${micrometerVersion}"
compile "io.micrometer:micrometer-spring-legacy:${micrometerVersion}"
compile "io.micrometer:micrometer-registry-prometheus:${micrometerVersion}"

with the following versions

springCloudVersion = 'Dalston.SR4'
micrometerVersion = '1.0.0-rc.4'

The code can be found here https://github.com/fiunchinho/spring-resiliency


Solution

  • You need to manually add the plugin for Hystrix:

    HystrixPlugins.getInstance().registerMetricsPublisher(new MicrometerMetricsPublisher(Metrics.globalRegistry));
    

    You could add it in a @PostConstruct in a configuration.

    I've created https://github.com/micrometer-metrics/micrometer/issues/237 to address the shortcoming in the future.