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

@JMX(description = "A example MBean object")
class SampleMBean {
  @JMX(description = "free memory size")
  def freeMemory: Long = {
case class FieldMBean(@JMX a: Int, @JMX b: String)

Nested parameters

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: