Chapter 3. JMC agent plug-in
You can use the JDK Mission Control (JMC) agent plug-in to add the JMC agent implementation to Cryostat. You can then use the JMC agent to add custom JFR events into a running target JVM application. This operation does not require you to restart your JVM application.
3.1. Adding custom events by using the JMC agent plug-in Copy linkLink copied to clipboard!
Cryostat can work in combination with the JDK Mission Control (JMC) agent to provide you with more information when you need to diagnose issues with your running JVM application. When you start a target JVM application, Cryostat automatically detects if the application is running with the JMC agent plug-in. In this situation, the JMC agent’s JAR file must be in the same Red Hat OpenShift container as the target JVM application. Otherwise, Cryostat cannot use the JMC agent functionality on the application.
A probe template describes a set of objects that Cryostat can process, so that Cryostat can complete a sequence of JMC agent operations on the target JVM application. By using Cryostat in combination with the JMC agent, you can add these types of custom JDK Flight Recorder (JFR) events to Cryostat and then insert them into a running JVM application. You can also remove these probe templates at a later stage, if required.
You can add probe templates to Cryostat in either of two ways:
- By using the Instrumentation view in the Cryostat web console to upload probe templates
- By using the Cryostat Operator to preconfigure your Cryostat instance with probe template files stored in ConfigMaps
The rest of this section describes how to upload probe templates by using the Instrumentation view in the Cryostat web console. For more information about using the Cryostat Operator to preconfigure your Cryostat instance with probe templates stored in ConfigMaps, see "Configuring probe templates" in CryostatUsingCryostatOperatorName.
For RHEL, the JMC package is provided by the CodeReady Linux Builder (CRB), also known as Builder, repository. To install JMC on RHEL, you must enable the CRB repository on RHEL. CRB packages are built with the Source Red Hat Package Manager (SRPM) as productized RHEL packages, so CRB packages regularly receive updates. For more information, see "Downloading and installing JDK Mission Control (JMC)" in Using JDK Flight Recorder with Red Hat build of OpenJDK.
Red Hat build of OpenJDK 21 no longer provides a distribution of JMC. If you are using Red Hat build of OpenJDK 21 or later, you can use an external instance of JMC, such as Adoptium’s Eclipse Mission Control. For more information about the removal of JMC, see the Red Hat knowledge base article "Where is JDK Mission Control (JMC) in JDK 21?".
Prerequisites
-
Downloaded and installed the
jmcpackage. - Downloaded the Adoptium Agent JAR file. See adoptium/jmc-build (GitHub).
-
Started your Java application with the
--add-opens=java.base/jdk.internal.misc=ALL-UNNAMEDflag. For example,./<your_application> --add-opens=java.base/jdk.internal.misc=ALL-UNNAMED. Started the JMC agent for your Java application.
Consider the following information:
- If you are using Red Hat build of OpenJDK 17 or earlier, see Starting the JDK Mission Control (JMC) Agent in Using JDK Flight Recorder with Red Hat build of OpenJDK.
- Red Hat build of OpenJDK 21 no longer provides a distribution of JMC. If you are using Red Hat build of OpenJDK 21 or later, you can use an external instance of JMC, such as Adoptium’s Eclipse Mission Control.
Procedure
In the Cryostat web console, select Flight Recorder > Capture > Instrumentation from the navigation menu. If the JMC agent was successfully added to your Cryostat instance, the Probe Templates tab opens in the Instrumentation view.
Figure 3.1. The Probe Templates tab in the Instrumentation view
NoteAn Authentication Required dialog box might open on your web console. If prompted, enter your Username and Password in the Authentication Required dialog box, and click Save to provide your JMX credentials to the target JVM.
Use your preferred text editor to create an XML configuration file. Populate the file with JFR event information, such as which events Cryostat must perform on the application.
The following example shows a custom probe template XML file that contains JFR event information. When this file is uploaded to Cryostat, Cryostat can add a custom JFR event, called
Cryostat Agent Plugin Demo Event, to an application. Cryostat starts the JFR event when theretrieveEventProbesmethod of the JMC agent is called.<jfragent> <!-- Global configuration options --> <config> <classprefix>__JFREvent</classprefix> <allowtostring>true</allowtostring>\ <allowconverter>true</allowconverter> </config> <events> <event id="cryostat.demo.jfr.event9"> <label>Cryostat Agent Plugin Demo Event</label> <description>Event for the agent plugin demo</description> <path>io/cryostat/demo/events</path> <stacktrace>true</stacktrace> <class>io.cryostat.core.agent.AgentJMXHelper</class> <method> <name>retrieveEventProbes</name> <descriptor>()Ljava/lang/String;</descriptor> </method> <location>WRAP</location> </event> </events> </jfragent>Click the Upload button to add a custom event template to Cryostat. A Create Custom Probe Template window opens in your Cryostat web console.
Figure 3.2. The Create Custom Probe Template window in the Cryostat web console
TipIf you want to remove the uploaded file from this Template XML field, click the Clear button.
- Click the Browse button to locate your XML file.
- After you upload the file, click Submit. Your custom probe template file opens in the Probe Templates table.
- Click the overflow menu icon that is next to your probe template.
- Click Insert Probes. The probes display in the table under the Probe Templates tab and the table under the Live Configuration tab.
- Optional: Click the Live Configuration tab, where you can view information, such as Name, Class, and so on, for each active probe.
- Optional: From the Live Configuration tab, you can click Remove All Probes to delete probes that are listed in the table.
Verification
- In the Cryostat web console, select Flight Recorder > Capture > Events from the navigation menu. Then click the Event Types tab.
-
Check that the named JFR event from your XML configuration is listed in the table. For the example used in this procedure,
Cryostat Agent Plugin Demo Eventdisplays in the table.
3.2. Downloading custom probe templates Copy linkLink copied to clipboard!
From Cryostat 4.2 onward, you can also use Cryostat to download the XML file for a selected probe template to your local system.
Prerequisites
- You have uploaded one or more probe templates.
Procedure
- From the Cryostat web console navigation menu, select Flight Recorder > Capture > Instrumentation.
- In the Probe Templates table, click the overflow icon next to the probe template you want to download.
-
From the overflow menu, select Download. The
.xmlfile for the selected probe template is then downloaded to your local system.
Revised on 2026-06-02 16:44:52 UTC