Skip to content

Metric plugins - mackerel-plugin-jvm

mackerel-plugin-jvm retrieves various metrics about the JVM from commands such as jstat, jinfo and jps.

This plugin will not work if PerfDisableSharedMem is specified in the JVM options. For more information, see here for details.

Specification

Run the following jstat command on the application lvmid specified by --javaname or the process ID of the file specified by --pidfile and post the output as a metric. The string after the last dot (.) in the metric name corresponds to the name of each piece of information that can be retrieved with the jstat command.

  • jstat -gc
  • jstat -gccapacity
  • jstat -gcnew
  • jstat -gcold

Monitorable metrics

The XXX in each graph name is set to the application name specified by the --javaname option.

JVM XXX GC events

Metric Display NameMetric NameDiffStackedDescription
Young GC eventcustom.jvm.#.gc_events.YGCNumber of Young GC events
Full GC eventcustom.jvm.#.gc_events.FGCNumber of Full GC events
Concurrent GC eventcustom.jvm.#.gc_events.CGCNumber of Concurrent GC events
  • Concurrent GC event is available in Java 11 or later.

JVM XXX GC time (sec)

Metric Display NameMetric NameDiffStackedDescription
Young GC timecustom.jvm.#.gc_time.YGCTExecution time of Young GC
Full GC timecustom.jvm.#.gc_time.FGCTExecution time of Full GC
Concurrent GC timecustom.jvm.#.gc_time.CGCTExecution time of Concurrent GC
  • Concurrent GC time is available in Java 11 or later.

JVM XXX GC time percentage

Metric Display NameMetric NameDiffStackedDescription
Young GC timecustom.jvm.#.gc_time_percentage.YGCTPercentage of Young GC in GC time per 60 seconds
Full GC timecustom.jvm.#.gc_time_percentage.FGCTPercentage of Full GC in GC time per 60 seconds
Concurrent GC timecustom.jvm.#.gc_time_percentage.CGCTPercentage of Concurrent GC in GC time per 60 seconds
  • Concurrent GC time is available in Java 11 or later.

JVM XXX New Space memory

Metric Display NameMetric NameDiffStackedDescription
New maxcustom.jvm.#.new_space.NGCMXMaximum capacity of New Generation (KB)
New currentcustom.jvm.#.new_space.NGCCurrent capacity of New Generation (KB)
Eden usedcustom.jvm.#.new_space.EUEden space usage (KB)
Survivor0 usedcustom.jvm.#.new_space.S0UCurrent usage of Survivor space 0 (KB)
Survivor1 usedcustom.jvm.#.new_space.S1UCurrent usage of Survivor space 1 (KB)

JVM XXX Old Space memory

Metric Display NameMetric NameDiffStackedDescription
Old maxcustom.jvm.#.old_space.OGCMXMaximum capacity of Old Generation (KB)
Old currentcustom.jvm.#.old_space.OGCCurrent capacity of Old Generation (KB)
Old usedcustom.jvm.#.old_space.OUOld space usage (KB)

JVM XXX Permanent Space

Metric Display NameMetric NameDiffStackedDescription
Perm maxcustom.jvm.#.perm_space.PGCMXMaximum capacity of Permanent Generation (KB)
Perm currentcustom.jvm.#.perm_space.PGCCurrent capacity of Permanent Generation (KB)
Perm usedcustom.jvm.#.perm_space.PUPermanent space usage (KB)
  • Java 8 or later is not supported.

JVM XXX Metaspace

Metric Display NameMetric NameDiffStackedDescription
Metaspace capacity maxcustom.jvm.#.metaspace.MCMXMaximum capacity of metaspace (KB)
Metaspace capacity mincustom.jvm.#.metaspace.MCMNMinimum capacity of metaspace (KB)
Metaspace capacitycustom.jvm.#.metaspace.MCMetaspace capacity (KB)
Metaspace utilizationcustom.jvm.#.metaspace.MUMetaspace usage (KB)
Compressed Class Space Capacitycustom.jvm.#.metaspace.CCSCCompressed class space capacity (KB)
Compressed Class Space Usedcustom.jvm.#.metaspace.CCSUCompressed class space used (KB)

JVM XXX MemorySpace

Metric Display NameMetric NameDiffStackedDescription
GC Old Memory Spacecustom.jvm.#.memorySpace.oldSpaceRateOld generation usage rate
GC New Memory Spacecustom.jvm.#.memorySpace.newSpaceRateNew generation usage rate
CMS Initiating Occupancy Fractioncustom.jvm.#.memorySpace.CMSInitiatingOccupancyFractionThreshold to perform CMS GC
  • GC Old Memory Space is calculated as (Old used / Old current ) * 100.
  • GC New Memory Space is calculated as (Survivor0 used + Survivor1 used + Eden used) / (Survivor0 current + Survivor1 current + Eden current) * 100.
  • CMS Initiating Occupancy Fraction is not posted when the --remote option is specified.
    • If the --remote option is not specified, the following command will be executed when retrieving information.
      • jinfo -flag UseConcMarkSweepGC
      • jinfo -flag CMSInitiatingOccupancyFraction

Configurable options

The options that can be specified for the plug-ins are as follows.

OptionDescriptionRequiredDefault
--hostDeprecated: hostname of jps/jstat
--portDeprecated: Target port of jps/jstat0
--remoteRemote target for jps/jstat. Specified by hostname[:port][/servername].
--jstatpathPath to jstat command/usr/bin/jstat or $JAVA_HOME/bin/jstat
--jinfopathPath to jinfo command/usr/bin/jinfo or $JAVA_HOME/bin/jinfo
--jpspathPath to jps command/usr/bin/jps or $JAVA_HOME/bin/jps
--javanameThe name of the application to be used as the graph name
--pidfilePath to pidfile
--tempfilePath to Temp file
  • If the --remote option is specified, jps and jstat must be executable locally from this plugin.
  • If there is more than one application with the name specified in the --javaname option, only one of the metrics will be posted.
    • To identify one of several applications with duplicate names, specify the pid file of the application to be monitored with the --pidfile option, or adjust the application name to avoid duplication.

Example configuration

toml
[plugin.metrics.jvm-tomcat]
command = [ "mackerel-plugin-jvm", "--javaname", "tomcat", "--jstatpath", "/usr/bin/jstat", "--jpspath", "/usr/bin/jps", "--jinfopath", "/usr/bin/jinfo"]

If you have multiple JVMs running on the same host and wish to monitor each one individually, specify different values for [plugin.metrics.xxxxxx] as follows

toml
[plugin.metrics.jvm-app01]
command = [ "mackerel-plugin-jvm", "--jstatpath", "/usr/bin/jstat", "--jpspath", "/usr/bin/jps", "--jinfopath", "/usr/bin/jinfo", "--javaname", "app01", "--pidfile", "/path/to/app01pidfile" ]

[plugin.metrics.jvm-app02]
command = [ "mackerel-plugin-jvm", "--jstatpath", "/usr/bin/jstat", "--jpspath", "/usr/bin/jps", "--jinfopath", "/usr/bin/jinfo", "--javaname", "app02", "--pidfile", "/path/to/app02pidfile" ]

Troubleshooting

Failed to run exec jinfo. jinfo command timed out. in mackerel-agent log

  • It is thought that a timeout occurred when executing the jinfo command from the plugin, due to temporary host load or other factors.
  • If the output is continuous, please run the jinfo command manually to check the status.
  • It may be possible to avoid this problem by adjusting the timeout value (timeout_seconds) of the monitoring rule. Please refer to Configuration for details.

Repository

https://github.com/mackerelio/mackerel-agent-plugins/tree/master/mackerel-plugin-jvm