Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot 2.0.0.M6: Show all metrics with one request

With Spring Boot 2.0.0.M6 and the new actuator metrics endpoint, when I request

GET /application/metrics

the only the names of the metrics are shown

{
  "names" : [ "data.source.active.connections", "jvm.buffer.memory.used", "jvm.memory.used", "jvm.buffer.count", "logback.events", "process.uptime", "jvm.memory.committed", "data.source.max.connections", "http.server.requests", "system.load.average.1m", "jvm.buffer.total.capacity", "jvm.memory.max", "process.start.time", "cpu", "data.source.min.connections" ]
}

Clearly I can access a specific metric using GET /application/metrics/jvm.memory.used

But is there a way to see all metrics with one request?

like image 946
Jochen Christ Avatar asked Nov 10 '17 09:11

Jochen Christ


People also ask

What are the metrics in Spring Boot 2?

Spring Boot 2 autoconfigures quite a few metrics for you, including: Uptime: report a gauge for uptime and a fixed gauge representing the application’s absolute start time Many of these metrics existed in a form in Spring Boot 1, but have been enriched with greater detail and tags in Spring Boot 2. Which monitoring systems does Micrometer support?

What is Spring Boot micrometer?

Think of it like SLF4J, but for metrics! Micrometer is the metrics collection facility included in Spring Boot 2’s Actuator. It has also been backported to Spring Boot 1.5, 1.4, and 1.3 with the addition of another dependency. Micrometer adds richer meter primitives to the counters and gauges that existed in Spring Boot 1.

How do I check the availability of a Spring Boot application?

“Application” refers to the logical group of Spring Boot microservices rather than any specific application. Click on console-availability to see everything about your application at a glance. You can look at information for either module: client or service. Click Jump To to navigate to a particular set of graphs.

How to add a timer to custom methods in Spring Boot?

This will allow Micrometer to add a timer to custom methods. Register the bean to your @SpringBootApplication or @Configuration class: Then, find the method that you want to time, and add the @Timed annotation to it. Use the value attribute to give the metric a name.


1 Answers

That's how the metrics endpoint behaves in the Spring Boot 2.0.0M* releases. There are only two read operations defined in the endpoint class:

  • ListNamesResponse listNames()
    • Resolves to GET /application/metrics
  • MetricResponse metric(@Selector String requiredMetricName, @Nullable List<String> tag)
    • Resolves to GET /application/metrics/jvm.memory.used

Metrics support has changed quite dramatically in 2.x (now backed by Micrometer) and the Spring Boot 2.x upgrade guide is lacking any details on metrics at the moment but it's a work in progress, so presumably more details will arive as Spring Boot 2.0 gets closer to a GA release.

I suspect the move from hierarchical metrics to dimensional metrics resulted in the maintainers deeming the 1.x (hierarchical) metrics display to be no longer viable/suitable.

like image 75
glytching Avatar answered Oct 25 '22 11:10

glytching