Java Monitoring Tooling

Instructions for enabling remote tooling on our JVM

3 minute read

In this section we’re going to configure our container to enable remote tooling.

Remote Monitoring

In previous sections of the workshop, we ran all our tooling without any configuration. In previous versions of Java you would have had to configure things even for local monitoring, this is no longer the case with Java 6+:

Any application that is started on the Java SE 6 platform will support the Attach API, and so will automatically be made available for local monitoring and management when needed.

Since the docker-compose network and containers are ran separate from our host (consider them a different machine), we need to enable remote monitoring and management.


We’ll set the following properties as a JAVA_OPTS environment variable when we start our workshop server container:

  • The JMX remote port to 8082:
  • The RMI registry port also set to 8082:
  • Disabling for both the registry and jmx: and
  • Accept connections not from localhost:
    • Since the machine we are connecting from will not be in the container network, we need to allow non localhost connections.
  • The host name for the RMI server will be set to The default value for this will be the container’s IP address, which we are overriding.

Set these values as an environment property on your workshop container:

    image: workshop-server:latest
      JAVA_OPTS: "

Test Our Setup

Spin up your services again with docker-compose up. Once the services are started, use docker ps to check the open ports on the workshop server. Notice that 8082 is now mapped as well.

$ docker ps
CONTAINER ID   IMAGE                      COMMAND                  CREATED          STATUS          PORTS                              NAMES
44d4a1ebedef   workshop-server:latest     "/bin/sh -c 'java $J…"   39 seconds ago   Up 37 seconds>8080-8082/tcp   java-perf-workshop_server_1

JDK Mission Control

We’ll use JDK Mission Control to create a JMX Connection.

Open JDK Mission Control. Notice that the JVM Browser no longer shows the two services (since they no longer are running on the local host):

Create a new JMX Connection using and 8082 as the host and port:

With our setup, we can connect with other addresses as well:

  • localhost (since we are exposing port 8082 on the container as port 8082 on the local host)
  • Our wifi/ethernet IP address, which you can find under the en0 interface using ifconfig/ipconfig:
    $ ifconfig
      ether 8c:85:90:ba:52:10 
      inet6 fe80::1862:95fe:55e7:284e%en0 prefixlen 64 secured scopeid 0x9 
      inet netmask 0xffffff00 broadcast


  Up Next

In the next section, we'll learn about some Docker tooling.

Docker Tooling
Last modified June 12, 2021: Fixing typos, fix broken link (#51) (5af132a)