指标不会显示在 /prometheus 端点上
Metrics don't show up on the /prometheus endpoint
我有两个服务,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'
您需要检测和配置 spring 引导服务以使用 prometheus 进行监控,如下所示:
- 您需要在 gradle.build 文件中包含依赖项
- 您需要实施指标端点
- 您需要从 Prometheus JVM 添加标准导出器
您需要手动添加 Hystrix 插件:
HystrixPlugins.getInstance().registerMetricsPublisher(new MicrometerMetricsPublisher(Metrics.globalRegistry));
您可以将其添加到配置的 @PostConstruct
中。
我创建了 https://github.com/micrometer-metrics/micrometer/issues/237 以解决未来的不足。
checketts' 对我不起作用,并在启动时抛出一个 java.lang.IllegalStateException: Another strategy was already registered.
,但是添加 HystrixMetricsBinder bean,它在内部或多或少地做同样的事情,就成功了。
@Configuration
public class MetricsConfig {
@Bean
HystrixMetricsBinder registerHystrixMetricsBinder() {
return new HystrixMetricsBinder();
}
}
取自
我有两个服务,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'
您需要检测和配置 spring 引导服务以使用 prometheus 进行监控,如下所示:
- 您需要在 gradle.build 文件中包含依赖项
- 您需要实施指标端点
- 您需要从 Prometheus JVM 添加标准导出器
您需要手动添加 Hystrix 插件:
HystrixPlugins.getInstance().registerMetricsPublisher(new MicrometerMetricsPublisher(Metrics.globalRegistry));
您可以将其添加到配置的 @PostConstruct
中。
我创建了 https://github.com/micrometer-metrics/micrometer/issues/237 以解决未来的不足。
checketts' java.lang.IllegalStateException: Another strategy was already registered.
,但是添加 HystrixMetricsBinder bean,它在内部或多或少地做同样的事情,就成功了。
@Configuration
public class MetricsConfig {
@Bean
HystrixMetricsBinder registerHystrixMetricsBinder() {
return new HystrixMetricsBinder();
}
}
取自