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

« Previous Version 4 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% which is not a concern at all.

See also

Configuring Prometheus Exporters

  • No labels