【发布时间】:2019-06-21 16:33:09
【问题描述】:
根据弹簧靴执行器的文档
Auto-configuration enables the instrumentation of requests handled by Spring MVC. When management.metrics.web.server.auto-time-requests is true, this instrumentation occurs for all requests. Alternatively, when set to false, you can enable instrumentation by adding @Timed
还有By default, metrics are generated with the name, http.server.requests
当我访问 /metrics 端点时,我得到了
{
"mem": 405105,
"mem.free": 150352,
"processors": 8,
"instance.uptime": 440055,
"uptime": 455888,
"systemload.average": 1.904296875,
"heap.committed": 315392,
"heap.init": 262144,
"heap.used": 164015,
"heap": 4194304,
"nonheap.committed": 92800,
"nonheap.init": 4992,
"nonheap.used": 89714,
"nonheap": 0,
"threads.peak": 64,
"threads.daemon": 43,
"threads.totalStarted": 95,
"threads": 46,
"classes": 12459,
"classes.loaded": 12459,
"classes.unloaded": 0,
"gc.g1_young_generation.count": 12,
"gc.g1_young_generation.time": 127,
"gc.g1_old_generation.count": 0,
"gc.g1_old_generation.time": 0,
"httpsessions.max": -1,
"httpsessions.active": 0,
"datasource.primary.active": 0,
"datasource.primary.usage": 0.0,
"gauge.response.example.users": 2.0,
"counter.status.200.example.users": 5
}
所以 http.server.requests 不存在。 counter.status.200.example 显示了通过我的应用程序的请求,但它们在每个端点上是分开的。我需要整个应用程序的整体。
我尝试禁用management.metrics.web.server.auto-time-requests 并将@Timed 添加到端点,但效果不佳。结果和上面的一样。
有谁知道我如何显示对应用程序提出的总体请求? 提前谢谢你。
*编辑
当我添加
compile('io.micrometer:micrometer-registry-prometheus:latest.release')
我收到以下错误
Parameter 0 of method prometheusEndpointFix in PrometheusEndpointConfiguration required a bean of type 'PrometheusEndpoint' that could not be found.
即使@Bean 在那里..
@Configuration
class PrometheusEndpointConfiguration {
@Bean
public PrometheusEndpoint prometheusEndpoint() {
return new PrometheusEndpoint(CollectorRegistry.defaultRegistry);
}
...
}
【问题讨论】:
-
这看起来很像旧的 Spring Boot 1.x 执行器指标。所以我假设你使用的是 Spring Boot 1.x,对吧?
-
是的,我使用的是 Spring Boot 1.5.2
-
我也尝试过
compile 'io.micrometer:micrometer-spring-legacy:latest.release',它支持 1.5 并且对于 http.server.requests 指标 micrometer.io/docs/ref/spring/1.5 声明相同
标签: java spring-boot spring-mvc prometheus spring-boot-actuator