小编典典

执行器/ metrics端点不包含http.server.requests

spring-mvc

根据弹簧靴执行器的文档

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);
  }
...
}

阅读 661

收藏
2020-06-01

共1个答案

小编典典

当通过Spring Boot 1.5 Actuator框架中micrometer-spring-legacy的“旧”
/metrics端点将Micrometer与Spring Boot 1.5一起使用时,将不会被Micrometer 1取代。在Spring Boot
1.5应用程序中,旧的执行器指标实现和Micrometer彼此完全独立。

目前,在这种情况下,我能轻松直观地看到Micrometer收集的指标的唯一方法是使用Micrometers
Prometheus后端,方法是micrometer-registry-prometheus另外包含micrometer-spring- legacy。默认情况下,这将以/prometheusPrometheus博览会格式公开端点并公开指标。

当然,您也可以滚动自己的端点实现,该实现模仿Spring Boot 2
/actuator/metrics端点,该端点查询MeterRegistry并可视化所有包含的指标。但是即使这样,它也仅应用于调试事物,而不是永久读取此端点并将数据持久保存在度量标准存储区中。已针对该确切用例“开发”了Prometheus展示格式。(而且它可读性很强,因此可以用作第一眼的入口点,以防万一您不抓取这些指标。)

2020-06-01