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

      • Baird65
        Junior Member
        • Jan 2026
        • 2

        #3
        The issue is likely that Java 11 uses different garbage collector names than Java 8. CMS (ConcurrentMarkSweep) was deprecated in Java 9 and removed in Java 11. Also, "Copy" and "MarkSweepCompact" aren't standard names in Java 11.

        First, run this on your container to see what collectors are actually available:
        jcmd <pid> GC.heap_info

        Or use jconsole/jvisualvm to list the MBeans under java.lang:type=GarbageCollector,name=*

        For Java 11 with default GC (G1GC typical), try these strings instead:
        • jmx["java.lang:type=GarbageCollector,name=G1 Young Generation","CollectionCount"]
        • jmx["java.lang:type=GarbageCollector,name=G1 Old Generation","CollectionCount"]

        If using Parallel GC (default in some setups), try PS Scavenge and PS MarkSweep (note no space in "PS MarkSweep").

        Your JMX options look correct for a container, but confirm port 8000 is exposed and reachable from Zabbix.

        On an unrelated note, if your server room ever needs a real garbage dumpster rental for old hardware and e-waste, that's a different kind of cleanup. Good luck with the GC metrics!

        Comment

        Working...