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?
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()
GET /application/metrics
MetricResponse metric(@Selector String requiredMetricName, @Nullable List<String> tag)
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.
Spring boot 2 has removed this functionality by default, but if this is requirement of your application then this custom implementation will serve your purpose: https://github.com/csankhala/spring-metrics-grabber
Add dependency in you application from local repository
compile("org.springframework.boot:spring-metrics-grabber:1.0.0-SNAPSHOT");
compile("org.springframework.boot:spring-boot-starter-actuator");
Add MetricxEndpoint.class to @SpringBootApplication scan path
import org.springframework.metricx.controller.MetricxEndpoint;
@SpringBootApplication(scanBasePackageClasses = { MetricxEndpoint.class, YourSpringBootApplication.class })
public class YourSpringBootApplication {
public static void main(String[] args) {
new SpringApplication(YourSpringBootApplication.class).run(args);
}
}
All Metrics will be published on '/metricx' endpoint with name and value both
Pattern search is also supported eg '/metricx/jvm.*'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.