PPetkov
PPetkov

Reputation: 270

Actuator /metrics endpoint does not include http.server.requests

According to the documentation of the spring boot actuator

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

And
By default, metrics are generated with the name, http.server.requests

When I access the /metrics endpoint I am getting

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

So the http.server.requests is not there. The counter.status.200.example kind of shows the requests that go through my application but they are separated per endpoint. I need an overall for the whole application. I've tried disabling the management.metrics.web.server.auto-time-requests and adding @Timed to the endpoints, but that did not work as well. The result was the same as the one above.

Does anyone know how I can show the overall requests that are made to the application? Thank you in advance.

*EDIT

when I add compile('io.micrometer:micrometer-registry-prometheus:latest.release') I get the following error

Parameter 0 of method prometheusEndpointFix in PrometheusEndpointConfiguration required a bean of type 'PrometheusEndpoint' that could not be found.

Even though the @Bean is there..

@Configuration
class PrometheusEndpointConfiguration {

  @Bean
  public PrometheusEndpoint prometheusEndpoint() {
    return new PrometheusEndpoint(CollectorRegistry.defaultRegistry);
  }
...
}

Upvotes: 3

Views: 5789

Answers (2)

Adam
Adam

Reputation: 3090

One catch with it is when using the actuators and following the guide of spring boot 2.2.6 I noticed the http.server.requests will not be shown in the metrics list, if no requests have happen so far. After making the first REST request, the http metric becomes available.

Upvotes: 5

mweirauch
mweirauch

Reputation: 2248

When using Micrometer with Spring Boot 1.5 via micrometer-spring-legacy the "old" /metrics endpoint from the Spring Boot 1.5 Actuator framework will not get replaced with the Micrometer one. In a Spring Boot 1.5 application, the old actuator metrics implementation and Micrometer live totally independant next to each other.

Currently, the only way I know off for easily visualizing the Micrometer collected metrics in this scenario is using Micrometers Prometheus backend by including micrometer-registry-prometheus additionally to micrometer-spring-legacy. This will - by default - expose the /prometheus endpoint and expose the metrics in the Prometheus exposition format.

Of course, you could also roll your own endpoint implementation which mimics the Spring Boot 2 /actuator/metrics endpoint which queries the MeterRegistry and visualizes all contained metrics. But even then, this should be merely used for debugging things instead of permanently reading this endpoint and persisting that data somewhere in a metrics store. The Prometheus exposition format has been "developed" for that exact usecase. (And it's quite readable, so can serve as a first look entrypoint in case you are not scraping these metrics.)

Upvotes: 2

Related Questions