prometheus / client_java

Prometheus instrumentation library for JVM applications

Home Page:http://prometheus.github.io/client_java/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Provide a counter of allocated memory

chlunde opened this issue · comments

Micrometer has a metric jvm_gc_memory_allocated_bytes_total. This is very useful because it provides the total number of allocated bytes, which can be used to calculate actionable stable metrics like "average bytes garbage produced per HTTP request"

It seems a bit tricky to get right, you need to listen to GC events for young gen:

https://github.com/micrometer-metrics/micrometer/blob/e122b103fb9a00f4baca0f1ed2f3833161fca31f/micrometer-core/src/main/java/io/micrometer/core/instrument/binder/jvm/JvmGcMetrics.java#L147-L153

This would be the same as jvm_memory_pool_allocated_bytes_total{pool="Eden Space"} - but beware of the pool name and GC implementation.