How to query all /actuator/metrics at once?
You don't have an api given by spring boot out of the box, but you can make it very easly if you want to. You need to use the endpoint MetricsEndpoint
which is used by the framework when querying the /metrics
apis.
You need to @Autowire
it in your service and afterwards you can use it get the names of all metrics by using the method listNames()
. Starting from the list of provided names you can query the detail for each metric at a time.
Here you have the reference page.
If you use Prometheus it will expose new /actuator/prometheus
endpoint which will list all the metrics at once. See this tutorial for examples:
# HELP jvm_buffer_memory_used_bytes An estimate of the memory that the Java virtual machine is using for this buffer pool
# TYPE jvm_buffer_memory_used_bytes gauge
jvm_buffer_memory_used_bytes{id="direct",} 81920.0
jvm_buffer_memory_used_bytes{id="mapped",} 0.0
# HELP jvm_threads_live The current number of live threads including both daemon and non-daemon threads
# TYPE jvm_threads_live gauge
jvm_threads_live 23.0
# HELP tomcat_global_received_bytes_total
# TYPE tomcat_global_received_bytes_total counter
tomcat_global_received_bytes_total{name="http-nio-8080",} 0.0
...