Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

New enhancements in the Cryostat 2.2 JMC agent plugin

December 16, 2022
Joshua Matsuoka
Related topics:
ContainersJava
Related products:
Red Hat Enterprise Linux

    The JDK Mission Control (JMC) agent is a powerful tool that allows users to inject custom JDK Flight Recorder (JFR) events into running applications without restarting the Java Virtual Machine. The new release of Cryostat 2.2 now offers a graphical user interface for communicating with the JMC Agent in containerized applications that support it. This article introduces the Cryostat JMC agent plugin and enhancements made in version 2.2.

    Prerequisites

    To start using the JMC agent with Cryostat, you’ll need the JMC agent jar as well as a target to connect it. The JMC Agent can be built from the source or downloaded from Adoptium’s JMC-Overrides page and must be present in the same container as the target application. Once there, the target application must start with the agent:

    -javaagent:/path/to/jmc-agent.jar

    With the Agent present in the same container and the target application started with it, Cryostat can now be used to inject custom JFR events into the target.

    JMC agent integration demo

    For this demonstration, we will run Cryostat with the JMC agent enabled. You can do this by copying the agent into the Cryostat image. Then modify the entry point script to launch Cryostat with the agent:

    -javaagent:/clientlib/agent.jar

    As Cryostat starts, the logs will show the agent running as follows:

    Oct 25, 2022 9:10:40 PM org.openjdk.jmc.agent.Agent printVersion
    
    INFO: JMC BCI agent v1.0.0

    Once we have a target running with the agent, we can open up Cryostat’s web interface and select it from the list. In Figure 1, the events page displays the agent options.

    The Cryostat events page and the probe templates table.
    Figure 1: The Cryostat Events page and the Probe Templates table.

    The Probe Templates tab allows us to upload a template to Cryostat detailing the events we want to inject and where to inject them. For an example template, consider the following:

    <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>

     

    This configuration will inject a custom flight recorder event called a Cryostat agent plugin demo event and have it emitted whenever the retrieveEventProbes method in AgentJMXHelper is called. This means that whenever Cryostat asks the agent for the currently active probes, it will also emit the custom JFR event. More information about this configuration can be found in this article.

    With an XML configuration ready, we can get started with injecting it into a target. Clicking the upload button will give us a dialogue to upload the template, as illustrated in Figure 2:

     

    Shows a custom probe template uploading dialog.
    Figure 2: Uploading a custom probe template.

    Once it is uploaded, we’ll be able to see it in the table in Figure 3:

    Shows the updated Probe Templates table.
    Figure 3: The updated Probe Templates table.

    Once we have a template in the table, we can apply it by clicking on the three dots, then selecting insert probes. We can see the active probes on the Live Configuration tab, as shown in Figure 4:

    Table showing the currently active Agent Configuration.
    Figure 4: The Live Configuration page.

    Check the Event Types table to confirm that they have been injected (Figure 5):

    The updated event types table displaying the custom events.
    Figure 5: The updated Event Types table.

    If we decide we no longer need the probes, we can remove them by selecting the Remove All Probes button. 

    With the probes active, we can start a recording (see this article for how to do this). If we refresh this table a few times to trigger calls to retrieve the event probes, we can check our recording when it finishes and find the custom events have been emitted, as shown in Figure 6:

    The custom events in a recording in JDK Mission Control.
    Figure 6: Viewing the custom events in a recording in JDK Mission Control.

    JMC agent and Cryostat are powerful diagnostic tools

    Cryostat and the JMC agent form a powerful set of tools for diagnosing issues with applications at runtime. The JMC agent offers the capability to inject custom flight recorder events into running JVMs without the need to restart, while Cryostat offers the capability to start and retrieve those flight recordings. These tools work together to greatly improve the monitoring experience. With the release of Cryostat 2.2, it is now easier than ever to take advantage of these tools for a seamless monitoring and troubleshooting experience.

    Related Posts

    • Manage JFR across instances with Cryostat and GraphQL

    • Install Cryostat with the new Helm chart

    • Collect JDK Flight Recorder events at runtime with JMC Agent

    Recent Posts

    • Every layer counts: Defense in depth for AI agents with Red Hat AI

    • Fun in the RUN instruction: Why container builds with distroless images can surprise you

    • Trusted software factory: Building trust in the agentic AI era

    • Build a zero trust AI pipeline with OpenShift and RHEL CVMs

    • Red Hat Hardened Images: Top 5 benefits for software developers

    What’s up next?

    Discover how you can move your legacy Java application into a container and deploy it to Kubernetes in minutes using the Developer Sandbox for Red Hat OpenShift.

    Try Java in the sandbox
    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Chat Support

    Please log in with your Red Hat account to access chat support.