Skip to end of banner
Go to start of banner

_Prometheus Exporters - Examples

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

You can use the following examples:

Measuring Java garbage collection with Prometheus

GarbageCollector statistics is one of the of metrics that the Java/JVM client library exposes.

If you invoke DefaultExports.initialize(); the Java client will expose a number of out of the box JVM metrics: 

  • memory pools
  • memory allocations
  • buffer pools
  • threads
  • JVM version
  • loaded classes
  • garbage collection

The GarbageCollector statistics comes from GarbageCollectorMXBean, and is exposed as the jvm_gc_collection_seconds summary.
In particular, jvm_gc_collection_seconds_count is responsible for the number of GCs, and jvm_gc_collection_seconds_sum  deals with for how long they were taken.

These are counters, so we can take a rate:

We can see that PS Scavenge is happening once every 2 seconds or so, and PS MarkSweek is rare. You can have a question  which of those are the young generation and which the old/tenured, but this is not something the JVM exposes so you have to know this in your setup given the name.

A GC every 2 seconds sounds excessive, and you can check how long it takes:

They are only taking about 1.5ms on average, which is acceptable. The single PS MarkSweek takes 45ms, but they are rare.

Finally, using rate(jvm_gc_collection_seconds_sum[1m]) you can see what proportion of time each type of GC is taking up, which per the previous numbers is under 0.1% so not a concern at all.

See also

_Prometheus Exporters - Configuring Prometheus Exporters

  • No labels