gpt4 book ai didi

java - 执行器/指标端点不包括http.server.requests

转载 作者:行者123 更新时间:2023-11-30 05:48:34 25 4
gpt4 key购买 nike

根据spring boot执行器的文档

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 2.2.6 的指南时我注意到,如果到目前为止没有发生任何请求,http.server.requests 将不会显示在指标列表中。发出第一个 REST 请求后,http 指标变得可用。

关于java - 执行器/指标端点不包括http.server.requests,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54405957/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com