Daily Hack #day83 - Retrieving Filtered Metrics from SpringBoot actuator
Cloud Tuned
1 min read
To retrieve metrics matching specific names, make a GET
request to /actuator/prometheus
with the includedNames
query parameter, as shown in the following curl-based example:
$ curl 'http://localhost:8080/actuator/prometheus?includedNames=jvm_memory_used_bytes%2Cjvm_memory_committed_bytes' -i -X GET
The response is going to look like the following:
HTTP/1.1 200 OK
Content-Type: text/plain;version=0.0.4;charset=utf-8
Content-Length: 1107
# HELP jvm_memory_used_bytes The amount of used memory
# TYPE jvm_memory_used_bytes gauge
jvm_memory_used_bytes{area="heap",id="PS Survivor Space",} 1.5579608E7
jvm_memory_used_bytes{area="heap",id="PS Old Gen",} 1.37476168E8
jvm_memory_used_bytes{area="heap",id="PS Eden Space",} 5975424.0
jvm_memory_used_bytes{area="nonheap",id="Metaspace",} 1.5167932E8
jvm_memory_used_bytes{area="nonheap",id="Code Cache",} 4.8512128E7
jvm_memory_used_bytes{area="nonheap",id="Compressed Class Space",} 2.1838624E7
# HELP jvm_memory_committed_bytes The amount of memory in bytes that is committed for the Java virtual machine to use
# TYPE jvm_memory_committed_bytes gauge
jvm_memory_committed_bytes{area="heap",id="PS Survivor Space",} 2.7262976E7
jvm_memory_committed_bytes{area="heap",id="PS Old Gen",} 2.88882688E8
jvm_memory_committed_bytes{area="heap",id="PS Eden Space",} 3.03038464E8
jvm_memory_committed_bytes{area="nonheap",id="Metaspace",} 1.6515072E8
jvm_memory_committed_bytes{area="nonheap",id="Code Cache",} 4.9741824E7
jvm_memory_committed_bytes{area="nonheap",id="Compressed Class Space",} 2.4379392E7
This is just one example on how to retrieve and filter metrics from SpringBoot actuator, you can adjust the query to your needs.
0
Subscribe to my newsletter
Read articles from Cloud Tuned directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by