执行器/指标端点不包括 http.server.requests
Actuator /metrics endpoint does not include http.server.requests
根据 spring 引导执行器的文档
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);
}
...
}
当通过 micrometer-spring-legacy
将 Micrometer 与 Spring Boot 1.5 一起使用时,来自 Spring Boot 1.5 Actuator 框架的 "old" /metrics
端点将不会被替换为千分尺之一。在 Spring Boot 1.5 应用程序中,旧的执行器指标实现和 Micrometer 彼此完全独立。
目前,我知道在这种情况下轻松可视化 Micrometer 收集的指标的唯一方法是使用 Micrometers Prometheus 后端,将 micrometer-registry-prometheus
添加到 micrometer-spring-legacy
。这将 - 默认情况下 - 公开 /prometheus
端点并以 Prometheus 说明格式公开指标。
当然,您也可以推出自己的端点实现,它模仿 Spring Boot 2 /actuator/metrics
端点,查询 MeterRegistry
并可视化所有包含的指标。但即便如此,这也应该仅用于调试,而不是永久读取此端点并将该数据持久保存在指标存储中的某个位置。对于那个确切的用例,Prometheus 说明格式是 "developed"。 (而且它的可读性很强,因此可以作为第一眼看到的入口点,以防您不抓取这些指标。)
一个问题是在使用执行器并遵循 spring boot 2.2.6 的指南时,我注意到 http.server.requests 不会显示在指标列表中,如果到目前为止没有请求发生。发出第一个 REST 请求后,http 指标可用。
根据 spring 引导执行器的文档
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);
}
...
}
当通过 micrometer-spring-legacy
将 Micrometer 与 Spring Boot 1.5 一起使用时,来自 Spring Boot 1.5 Actuator 框架的 "old" /metrics
端点将不会被替换为千分尺之一。在 Spring Boot 1.5 应用程序中,旧的执行器指标实现和 Micrometer 彼此完全独立。
目前,我知道在这种情况下轻松可视化 Micrometer 收集的指标的唯一方法是使用 Micrometers Prometheus 后端,将 micrometer-registry-prometheus
添加到 micrometer-spring-legacy
。这将 - 默认情况下 - 公开 /prometheus
端点并以 Prometheus 说明格式公开指标。
当然,您也可以推出自己的端点实现,它模仿 Spring Boot 2 /actuator/metrics
端点,查询 MeterRegistry
并可视化所有包含的指标。但即便如此,这也应该仅用于调试,而不是永久读取此端点并将该数据持久保存在指标存储中的某个位置。对于那个确切的用例,Prometheus 说明格式是 "developed"。 (而且它的可读性很强,因此可以作为第一眼看到的入口点,以防您不抓取这些指标。)
一个问题是在使用执行器并遵循 spring boot 2.2.6 的指南时,我注意到 http.server.requests 不会显示在指标列表中,如果到目前为止没有请求发生。发出第一个 REST 请求后,http 指标可用。