我有两个服务,ping
和 pong
,其中 ping
向 pong
发送请求。此指标显示在 ping
服务的 /metrics
端点上:
gauge.servo.hystrix.hystrixcommand.http://pong.pongclient#hello().90
但它不会出现在 /prometheus
端点上。其他指标显示在此端点上,但不包含有关 Feign/Hystrix http 请求信息的伺服指标。
如何让这些指标显示在 /prometheus
端点上?
我的 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}"
具有以下版本
springCloudVersion = 'Dalston.SR4'
micrometerVersion = '1.0.0-rc.4'
最佳答案
您需要手动添加Hystrix的插件:
HystrixPlugins.getInstance().registerMetricsPublisher(new MicrometerMetricsPublisher(Metrics.globalRegistry));
您可以将其添加到配置中的 @PostConstruct
中。
我创建了https://github.com/micrometer-metrics/micrometer/issues/237以弥补今后的不足。
关于spring-boot - 指标未显示在/prometheus 端点上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47379978/