Is there any reference detailed documentation of spring boot 2 metrics.
I mean
{
"names": [
"jvm.memory.max",
"http.server.requests",
"process.files.max",
"jvm.gc.memory.promoted",
"tomcat.cache.hit",
"rabbitmq.channels",
"system.load.average.1m",
"tomcat.cache.access",
"jvm.memory.used",
"jvm.gc.max.data.size",
"jdbc.connections.max",
"jdbc.connections.min",
"jvm.gc.pause",
"jvm.memory.committed",
"system.cpu.count",
"logback.events",
"rabbitmq.connections",
"tomcat.global.sent",
"jvm.buffer.memory.used",
"tomcat.sessions.created",
"jvm.threads.daemon",
"system.cpu.usage",
"jvm.gc.memory.allocated",
"tomcat.global.request.max",
"hikaricp.connections.idle",
"hikaricp.connections.pending",
"tomcat.global.request",
"rabbitmq.rejected",
"tomcat.sessions.expired",
"hikaricp.connections",
"jvm.threads.live",
"jvm.threads.peak",
"tomcat.global.received",
"hikaricp.connections.active",
"hikaricp.connections.creation",
"process.uptime",
"tomcat.sessions.rejected",
"process.cpu.usage",
"tomcat.threads.config.max",
"jvm.classes.loaded",
"hikaricp.connections.max",
"hikaricp.connections.min",
"rabbitmq.consumed",
"jvm.classes.unloaded",
"tomcat.global.error",
"tomcat.sessions.active.current",
"tomcat.sessions.alive.max",
"jvm.gc.live.data.size",
"tomcat.servlet.request.max",
"hikaricp.connections.usage",
"tomcat.threads.current",
"tomcat.servlet.request",
"hikaricp.connections.timeout",
"process.files.open",
"jvm.buffer.count",
"jvm.buffer.total.capacity",
"tomcat.sessions.active.max",
"hikaricp.connections.acquire",
"tomcat.threads.busy",
"rabbitmq.published",
"process.start.time",
"tomcat.servlet.error",
"rabbitmq.acknowledged"
]
}
Which metrics should I use for memory / gc / cpu usage. Also what does the values represent.
Also in spring boot 1.5.x, i can simply get used heap, committed heap, gc count etc. How can i get those values?
Also is there a way I can get all metrics at one call. I mean to get all metrics i need to call many hits rite now in boot 2.
Still learning how to use Spring's new dimensional implementation myself, but I think I can help you out with some of your question. As you found, the metrics are much richer in Spring Boot 2 than Spring Boot 1.5.
There's a good blog post on Spring's site that goes into detail what the new metric engine gives you and why they though the change was needed: Micrometer: Spring Boot 2's new application metrics collector
A. Which metrics should I use for memory / gc / cpu usage. Also what does the values represent.
When you navigate to your application's actuator/metric
endpoint you can view your suitable metrics.
jvm.memory.max
jvm.memory.used
jvm.gc.memory.promoted
jvm.memory.committed
jvm.buffer.memory.used
jvm.gc.memory.allocated
jvm.gc.memory.allocated
jvm.gc.memory.promoted
system.cpu.usage
system.cpu.count
process.cpu.usage
B. Also in spring boot 1.5.x, i can simply get used heap, committed heap, gc count etc. How can i get those values?
As you mentioned, you'll have to view your metrics by dimension.
For example, in Spring Boot <2, in order to view the heap.committed:120000
, you'd have to just make a GET request on /actuator/metrics
.
In Spring Boot 2, to return the metric for TOTAL committed memory (heap and nonheap) you'll make a GET request on /actuator/metrics/jvm.memory.committed
.
You'll get a response similar to:
{
"name": "jvm.memory.committed",
"measurements": [
{
"statistic": "VALUE",
"value": 240000
}
],
"availableTags": [
{
"tag": "area",
"values": [
"heap",
"nonheap"
]
},
{
"tag": "id",
"values": [
"Compressed Class Space",
"PS Survivor Space",
"PS Old Gen",
"Metaspace",
"PS Eden Space",
"Code Cache"
]
}
]
}
To only view the committed heap value, make a GET request using the heap tag: /acutator/metrics/jvm.memory.committted?tag=area:heap
. You should see something similar to:
{
"name": "jvm.memory.committed",
"measurements": [
{
"statistic": "VALUE",
"value": 120000
}
],
"availableTags": [
{
"tag": "id",
"values": [
"PS Eden Space",
"PS Survivor Space",
"PS Old Gen"
]
}
]
}
Spring Boot's Metrics Reference Docs are a great resource and how I learned about the tag syntax (it's the last section).
See this question: Take a look at how previous versions mapped to the old metrics in Spring Boot's SystemPublicMetrics.java class if you'd like to ensure that these metrics are mapping correctly to your application's previous metrics.
Also is there a way I can get all metrics at one call. I mean to get all metrics i need to call many hits rite now in boot 2.
I don't think there is at this time through the metrics endpoint out of the box. Of interest to you may be Micrometer's HierarchicalNameMapper.java
class. Per, Micrometer's Docs:
Dimensionality. Whether the system supports metric names to be enriched with tag key/value pairs. If a system is not dimensional, it is hierarchical, which means it only supports a flat metric name. When publishing metrics to hierarchical systems, Micrometer flattens the set of tag/key value pairs and adds them to the name.
So, if you publish your data to a hierarchical system (such as JMX) your metrics will be flattened. You could also implement your own flattening mapper if you're exporting to another system.