Video in progress

Which metrics do you collect for JVMs at the platform level, and which do you alert on?

I alert on symptoms: GC pauses breaking the SLO, steady growth of heap after GC, the share of time going to GC, and OOMs/restarts. The other metrics sit on the dashboard for investigation.

📖 Answer

Many teams set an alert on "heap used > 90%". That is noise: G1 fills the heap on purpose and collection starts after that. An alert like that fires every day and in the end everyone ignores it.

What I alert on:

  • The GC time share: if more than 10-15% of the time in the last 5 minutes went to GC. This is a sign of approaching the "GC overhead limit".
  • Heap after GC (old gen occupancy after collection): monotonic growth over hours. This is the most reliable signal of a leak.
  • The maximum pause: a threshold near the SLO, for example if the p99 target is 300 ms, pauses of 200 ms.
  • Container restarts and the OOMKilled reason.
  • Allocation stall / evacuation failure, as a counter derived from the log.

On the dashboard (no alerts): allocation rate, promotion rate, metaspace, thread count, direct buffer memory, JIT compilation time, safepoint time, CPU throttling.

In Micrometer most of it is ready:

jvm.gc.pause (timer), jvm.gc.memory.allocated, jvm.gc.memory.promoted,
jvm.memory.used{area=heap,id=G1 Old Gen}, jvm.threads.live, jvm.buffer.memory.used

For a more precise "heap after GC" signal, use LastGcInfo in JMX or JFR's jdk.GCHeapSummary event. One thing: names and labels should be the same in all services, otherwise comparison across the fleet doesn't work.