airframe-jmx enables exposing application information through JMX so that you can check the running state of an application outside JVM. For example, you can use jconsole program to access JMX parameters.

JMX already provides various JVM metrics (e.g., heap memory usage, GC statistics, etc.). DataDog provides a handy way to collect JMX metrics:

For analyzing application behavior for longer ranges (5 minute or more), we recommend using Treasure Data along with DataDog:

JMX -> fluentd -> DataDog   (For real-time monitoring)
               -> Treasure Data -> Presto SQL (Doing metric-driven actions with SQL queries)


Maven Central

libraryDependencies += "org.wvlet.airframe" %% "airframe-jmx" % "(version)"

Usage is simple: Add @JMX annotation to variables or methods you want to see in JMX.

Registering JMX parameters

import wvlet.airframe.jmx._

@JMX(description = "A example MBean object")
class SampleMBean {
  @JMX(description = "free memory size")
  def freeMemory: Long = {

// Register the MBean to make it visible from JMX interface
val mbean = new SampleMBean

Nested parameters

To report nested parameters, add @JMX to parameters as well:

class NestedMBean {
  @JMX(description = "nested stat")
  def stat: Stat = {
    new Stat(Random.nextInt(10), "nested JMX bean")

case class Stat(@JMX count: Int, @JMX state: String)

In this example, stat.count and stat.state will be reported.

Launching JMX Registry

You can launch JMXRegistry (e.g., on port 7199) by setting these JVM parameters:

For convenience, you can start JMXRegistry inside your program:


Using airframe-jmx with Airframe DI

import wvlet.airframe._
import wvlet.airframe.jmx._

case class MyAppStats(
  @JMX(description = "application access count")

@JMX(description = "My application")
trait MyApp { self =>

  bind[JMXAgent].onStart { agent =>
    // Register MyApp to JMX registry when starting the application

  private var accessCount: Long = 0

  @JMX(description = "application stats")
  def stats: MyAppStats = {