Spring Boot Actuator PoolingHttpClientConnectionManager 指标

Jef*_*ton 5 spring-boot spring-boot-actuator prometheus

我们使用 Spring Boot 2 与 Actuator 和 Prometheus 来显示 Grafana 仪表板。我想添加 Apache Http Client PoolingHttpClientConnectionManager 指标来报告连接池统计信息。我看到它已添加到 micrometer-core:1.3.0 ( https://github.com/micrometer-metrics/micrometer/pull/1223 )。但是,我在 /actuator/metrics 或 /actuator/prometheus 端点中没有看到任何相关指标。我尝试更新 pom.xml 中的依赖项:

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.6.RELEASE</version>
        <relativePath/>
        <!-- lookup parent from repository -->
    </parent>
...
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-core</artifactId>
            <version>1.4.2</version>
        </dependency>
        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-registry-prometheus</artifactId>
            <version>1.4.2</version>
        </dependency>
Run Code Online (Sandbox Code Playgroud)

应用程序.yml

# Spring Actuator Configuration
management:
  endpoint:
    health:
      show-details: always

  endpoints:
    web:
      exposure:
        include: "*"
  metrics:
    enable:
      all: true
Run Code Online (Sandbox Code Playgroud)

/执行器/指标

{
"names": [
"jvm.buffer.memory.used",
"jvm.threads.states",
"tomcat.servlet.error",
"process.uptime",
"jvm.memory.used",
"system.load.average.1m",
"tomcat.servlet.request.max",
"tomcat.cache.hit",
"tomcat.global.request.max",
"tomcat.global.error",
"tomcat.cache.access",
"logback.events",
"jvm.memory.committed",
"tomcat.sessions.active.current",
"jvm.buffer.total.capacity",
"jvm.gc.pause",
"jvm.memory.max",
"system.cpu.usage",
"jvm.threads.live",
"jvm.classes.unloaded",
"tomcat.global.sent",
"jvm.classes.loaded",
"jvm.threads.peak",
"tomcat.threads.config.max",
"tomcat.sessions.rejected",
"tomcat.sessions.alive.max",
"jvm.gc.memory.promoted",
"jvm.buffer.count",
"jvm.gc.memory.allocated",
"tomcat.global.received",
"tomcat.sessions.expired",
"tomcat.sessions.created",
"jvm.gc.max.data.size",
"system.cpu.count",
"tomcat.threads.busy",
"process.start.time",
"jvm.threads.daemon",
"process.files.max",
"tomcat.threads.current",
"tomcat.sessions.active.max",
"tomcat.global.request",
"process.files.open",
"jvm.gc.live.data.size",
"tomcat.servlet.request",
"process.cpu.usage"
]
}
Run Code Online (Sandbox Code Playgroud)

弹簧致动器是否需要支持更改,或者我是否缺少配置某些内容?任何帮助或建议表示赞赏。

小智 0

io.micrometer.core.instrument.binder.httpcomponents @Incubating(since = "1.4.0") 
public class MicrometerHttpClientInterceptor
extends Object
Provides HttpRequestInterceptor and HttpResponseInterceptor for configuring with an org.apache.http.nio.client.HttpAsyncClient. Usage example:
 
     MicrometerHttpClientInterceptor interceptor = new MicrometerHttpClientInterceptor(registry,
             request -> request.getRequestLine().getUri(),
             Tags.empty(),
             true);

     CloseableHttpAsyncClient httpAsyncClient = HttpAsyncClients.custom()
             .addInterceptorFirst(interceptor.getRequestInterceptor())
             .addInterceptorLast(interceptor.getResponseInterceptor())
             .build();
 
Run Code Online (Sandbox Code Playgroud)

自:1.4.0