Ad Widget

Collapse

JMX Garbage Collection monitoring on Docker Container

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • nlsteffens
    Junior Member
    • Dec 2022
    • 4

    #1

    JMX Garbage Collection monitoring on Docker Container

    Hello,

    I have a Docker Container running Java 11 and I'm attempting to get Garbage Collection metrics via JMX. I'm able to get other metrics from the container like Heap Memory but unfortunately Garbage Collection isn't working and I get a message saying 'Object or Attribute not found' in my Zabbix items.

    The Garbage Collection metrics are working on non-dockerised containers running springboot and tomcat on Java 8.

    I'm running Zabbix version 4.0.11 and the Docker container is running on a server running CentOS 7.7

    These are the garbage collection strings that Zabbix is using. Perhaps the strings should be different for Java 11?

    jmx["java.lang:type=GarbageCollector,name=ConcurrentMa rkSweep","CollectionCount"]
    jmx["java.lang:type=GarbageCollector,name=Copy","Colle ctionTime"]
    jmx["java.lang:type=GarbageCollector,name=Copy","Colle ctionCount"]
    jmx["java.lang:type=GarbageCollector,name=MarkSwee pCom pact","CollectionTime"]
    jmx["java.lang:type=GarbageCollector,name=MarkSwee pCom pact","CollectionCount"]
    jmx["java.lang:type=GarbageCollector,name=ParNew","Col lectionTime"]
    jmx["java.lang:type=GarbageCollector,name=ParNew","Col lectionCount"]
    jmx["java.lang:type=GarbageCollector,name=PS MarkSweep","CollectionTime"]
    jmx["java.lang:type=GarbageCollector,name=PS MarkSweep","CollectionCount"]
    jmx["java.lang:type=GarbageCollector,name=PS Scavenge","CollectionTime"]
    jmx["java.lang:type=GarbageCollector,name=PS Scavenge","CollectionCount"]

    This is the JDK_JAVA_OPTIONS string I'm using in the cotainer. The hostname has been replaced by a dummy IP address:

    JDK_JAVA_OPTIONS=-Xlog:gc*,safepoint:file=/app/logs/gc.log:time,level,tags:filecount=10,filesize=10M -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8000 -Dcom.sun.management.jmxremote.rmi.port=8000 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.rmi.server.hostname=10.10.10.10

    Any help would be appreciated.

    Regards,
    Nick




















    Attached Files
  • Answer selected by nlsteffens at 28-03-2023, 08:20.
    nlsteffens
    Junior Member
    • Dec 2022
    • 4

    As of Java 7 update 4, the garbage collector used is G1. This means the strings used to get the garbage collection metrics have changed. Use the strings below to gather the metrics in Zabbix.

    G1 Old Generation:
    jmx["java.lang:type=GarbageCollector,name=G1 Old Generation",CollectionCount]
    jmx["java.lang:type=GarbageCollector,name=G1 Old Generation",CollectionTime]

    G1 Young Generation:
    jmx["java.lang:type=GarbageCollector,name=G1 Young Generation",CollectionCount]
    jmx["java.lang:type=GarbageCollector,name=G1 Young Generation",CollectionTime]

    A list of the G1 collection metrics can be found in the template here: https://wiki.liutyi.info/display/DEV...oring+template

    Comment

    • nlsteffens
      Junior Member
      • Dec 2022
      • 4

      #2
      As of Java 7 update 4, the garbage collector used is G1. This means the strings used to get the garbage collection metrics have changed. Use the strings below to gather the metrics in Zabbix.

      G1 Old Generation:
      jmx["java.lang:type=GarbageCollector,name=G1 Old Generation",CollectionCount]
      jmx["java.lang:type=GarbageCollector,name=G1 Old Generation",CollectionTime]

      G1 Young Generation:
      jmx["java.lang:type=GarbageCollector,name=G1 Young Generation",CollectionCount]
      jmx["java.lang:type=GarbageCollector,name=G1 Young Generation",CollectionTime]

      A list of the G1 collection metrics can be found in the template here: https://wiki.liutyi.info/display/DEV...oring+template

      Comment

      • Margarett74
        Junior Member
        • May 2026
        • 1

        #3
        Hi Nick,

        The issue is almost certainly due to the garbage collector names changing between Java 8 and Java 11. In Java 11, the CMS collectors (ConcurrentMarkSweep, ParNew, Copy) have been removed or deprecated. The default GC in Java 11 is G1GC, so you need to use these names instead:
        • G1 Young Generation for CollectionCount/CollectionTime
        • G1 Old Generation for CollectionCount/CollectionTime

        If you're using the parallel collector, the names are PS Scavenge and PS MarkSweep (you already have those). Also verify that your Zabbix Java gateway can list all available MBeans using jconsole or jcmd inside the container to confirm the exact GC bean names.

        Your JMX options look correct. One more thing: on Java 11, you may need to add -Dcom.sun.management.jmxremote.local.only=false and ensure the RMI server hostname is reachable from your Zabbix server.

        On a completely unrelated note, if anyone in Middle Tennessee needs a reliable roll-off bin for a home cleanout, construction debris, or yard waste, check out garbage dumpster rental for affordable, driveway-friendly service with no hidden fees.

        Hope that helps you track down those GC metrics.

        Thanks

        Comment

        Working...