Remotely Recording a JFR Log from a Container (Without Using the Command Line)

Java Flight Recorder (JFR) is the go-to technology for recording and viewing JVM and system metrics.

JFR records JFR logs which reveal much about the running application, the health of the JVM and the stability of the system. JFR logs are easily obtained by simply going into the command line / terminal and entering a few commands.

But what if you don’t have access to the command line or terminal directly on the system where the JVM is running, like when the JVM is running in a container?

Don’t worry. In this quick guide, you can learn how to do just that with a little configuration using JVM’s JMX connector and Azul Mission Control.

Setting up JMX on your JVM

Before you can access your JVM outside of the command line / terminal, you must set up your JVM to be discoverable and accessible over remote connections. You can accomplish this simply by enabling the JVM’s JMX connector.

Configure your Java application with the following VM parameters: enables JMX/JMXRMI connectivity.[IP/Hostname]: Sets the address for JMX connection. Use an external IP address or host name of the computer or container where the Java program is running.[port]: Sets the TCP port for JMX connection.
-Djava.rmi.server.hostname=[IP/Hostname]: Sets the address for JMXRMI connection. Use the same IP/hostname you used for JMX connection.[port]: Sets the TCP port for JMXRMI connection. Use the same TCP port you used for JMX connection. If you are connecting to the JVM from a different machine, you have to unbind ports from localhost.
Additionally, you may want to enable JMX authentication/SSL using:


For example:

Connecting to a Remote JVM Using Azul Mission Control

If you don’t have Azul Mission Control yet, head over to the Azul Mission Control download page.

In Azul Mission Control, go to the JVM Browser and click the Add JVM Connection button to create a new custom JVM connection.

Specify the host name/IP address of the remote system and the JMX port number.

If JMX authentication is enabled, enter User and Password.

Click Test Connection to make sure your remote JVM is reachable and click Finish.

Your remote JVM now appears in the JVM Browser.

Depending on your network and container setup, port forwarding may need to be set up. Contact your network’s administrator if you need help with port forwarding.

Recording a JFR from your Remote JVM

Now that you’re connected to your JVM remotely, it’s time to make a JFR recording.

In Azul Mission Control, go to the JDK Browser, right-click your remote JVM connection and select Start Flight Recording…

Select your preferred options and time intervals (either a fixed time recording or continuous recording based on the JFR log’s size and/or age), and click Finish.

Your remote JFR recording has begun. You’re almost there!

Check the progress of the recording by expanding the remote JVM connection in the JVM Browser.

Once your recording has finished, your JFR log opens automatically in Azul Mission Control.

You can now check the Outline tab to take a deeper look into your JVM’s performance portfolio.

The post Remotely Recording a JFR Log from a Container (Without Using the Command Line) appeared first on foojay.