3
votes

We are using Spring Boot 2 with Actuator and Prometheus to display a Grafana dashboard. I would like to add Apache Http Client PoolingHttpClientConnectionManager metrics to report on connection pool stats. I see that this was added to micrometer-core:1.3.0 (https://github.com/micrometer-metrics/micrometer/pull/1223). However I do not see any related metrics in /actuator/metrics or /actuator/prometheus endpoints. I have tried updating dependency in 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>

application.yml

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

  endpoints:
    web:
      exposure:
        include: "*"
  metrics:
    enable:
      all: true

/actuator/metrics

{
"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"
]
}

Are supporting changes needed in spring actuator or am I missing something for configuration? Any help or advice is appreciated.

1
Hi @jeff-norton : did you manage to get it working with github.com/micrometer-metrics/micrometer/blob/master/… ?Laurent Perez

1 Answers

0
votes
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();
 

Since: 1.4.0