quarkus icon indicating copy to clipboard operation
quarkus copied to clipboard

Quarkus JMX monitoring

Open marichka-spin opened this issue 6 months ago • 8 comments

Hello, team I'm new to Quarkus and I'm trying to migrate our small connector application from Spring to Quarkus. But The main issue that I'm stuck with - is it possible to access application MBeans via remote jmx connection. My application has code that registers custom MBean and also I added micrometer dependency to observe monitoring MBeans. I started application via IntelliJ runner with following vm options -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9090 -Dcom.sun.management.jmxremote.rmi.port=9090 -Dcom.sun.management.jmxremote.host=0.0.0.0 -Djava.rmi.server.hostname=0.0.0.0 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.local.only=false If I connect jconsole as to local process I can observe my custom MBean domain and 'meter' domain But if I connect as to remote process neither of domains I don't observe. Could you point me out what I'm doing wrong Also when I tried to run application in production mode (java -jar ....) vm options didn't apply at all.

Image Image

marichka-spin avatar Jun 03 '25 09:06 marichka-spin

/cc @brunobat (micrometer), @ebullient (metrics,micrometer), @jmartisk (metrics)

quarkus-bot[bot] avatar Jun 03 '25 10:06 quarkus-bot[bot]

@marichka-spin are you also setting those jmx properties when you run with java -jar... ?

brunobat avatar Jun 03 '25 11:06 brunobat

@brunobat I'm doing: java -jar ./target/quarkus-app/quarkus-run.jar -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9090 -Dcom.sun.management.jmxremote.rmi.port=9090 -Dcom.sun.management.jmxremote.host=0.0.0.0 -Djava.rmi.server.hostname=0.0.0.0 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.local.only=false

Options seems to not applied at all, jconsole is not connecting to remote process with param 'localhost:9090'

marichka-spin avatar Jun 04 '25 05:06 marichka-spin

The command looks ok, it works for me on Linux and Temurin 21: Image

Can you please add a reproducer project to this issue?

brunobat avatar Jun 04 '25 08:06 brunobat

Hello, @brunobat My set up is MacOS and Azul jdk 17 So I created test project https://github.com/marichka-spin/jmx-with-quarkus What I did java -jar ./target/quarkus-app/quarkus-run.jar -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9090 -Dcom.sun.management.jmxremote.rmi.port=9090 -Dcom.sun.management.jmxremote.host=0.0.0.0 -Djava.rmi.server.hostname=0.0.0.0 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.local.only=false then I run jconsole localhost:9090 I've got - Connection refused

Image

If I connect as local process - everything is ok. But I case with java code:

JMXServiceURL url = new JMXServiceURL(String.format(CONNECTION_STRING_TEMPLATE,"localhost:9090")); JMXConnector jmxc = JMXConnectorFactory.connect(url, new HashMap<>()); MBeanServerConnection mbsc = jmxc.getMBeanServerConnection(); log.info("MBeanServer default domain = " + mbsc.getDefaultDomain()); return mbsc; I also can't connect

marichka-spin avatar Jun 11 '25 07:06 marichka-spin

Hi @brunobat, In one of the previous issues, I found that Quarkus doesn't support JMX but that was an old comment. I was trying to connect jmx for my application (Keycloak 21.1.2.4.6 + Quarkus 2.13.8.Final) but facing a problem. More details over here: Error Details

Wanted to check if its supported now and specifically from which version onwards? Thanks!

rdas22 avatar Jun 11 '25 10:06 rdas22

Hi @brunobat, In one of the previous issues, I found that Quarkus doesn't support JMX but that was an old comment. I was trying to connect jmx for my application (Keycloak 21.1.2.4.6 + Quarkus 2.13.8.Final) but facing a problem. More details over here: Error Details

Wanted to check if its supported now and specifically from which version onwards? Thanks!

That issue is about JMX on native mode. It's not the case here.

brunobat avatar Jun 11 '25 13:06 brunobat

Hello, @brunobat My set up is MacOS and Azul jdk 17 So I created test project https://github.com/marichka-spin/jmx-with-quarkus What I did java -jar ./target/quarkus-app/quarkus-run.jar -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9090 -Dcom.sun.management.jmxremote.rmi.port=9090 -Dcom.sun.management.jmxremote.host=0.0.0.0 -Djava.rmi.server.hostname=0.0.0.0 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.local.only=false then I run jconsole localhost:9090 I've got - Connection refused

Image If I connect as local process - everything is ok. But I case with java code:

JMXServiceURL url = new JMXServiceURL(String.format(CONNECTION_STRING_TEMPLATE,"localhost:9090")); JMXConnector jmxc = JMXConnectorFactory.connect(url, new HashMap<>()); MBeanServerConnection mbsc = jmxc.getMBeanServerConnection(); log.info("MBeanServer default domain = " + mbsc.getDefaultDomain()); return mbsc; I also can't connect

@marichka-spin, sorry, but your command worked for me on Fedora 42 Linux, using Temurin 21. Please try other JDK, operating system or double-check your firewall.

brunobat avatar Jun 11 '25 13:06 brunobat