Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

New enhancements in the Cryostat 2.2 JMC agent plugin

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

Share:

    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

    • Alternatives to creating bootc images from scratch

    • How to update OpenStack Services on OpenShift

    • How to integrate vLLM inference into your macOS and iOS apps

    • How Insights events enhance system life cycle management

    • Meet the Red Hat Node.js team at PowerUP 2025

    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

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    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

    Red Hat legal and privacy links

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

    Report a website issue