Monitoring Docker using JMX

You can monitor Confluent Platform Docker deployments by using Java Management Extensions (JMX).

Configure Environment

To use JMX with Docker containers, you must set the following properties:

Note about hostname:

The JMX client needs to be able to connect to java.rmi.server.hostname. The default for bridged network is the bridged IP so you will only be able to connect from another Docker container. For host network, this is the IP that the hostname on the host resolves to.

The hostname is set to hostname -i in the Docker container. If you have more that one network configured for the container, hostname -i gives you all the IPs, the default is to pick the first IP (or network).

Configure Security

To set security on JMX, you can follow the SSL and authentication sections in this guide:

Configure Kafka and ZooKeeper


JMX Port.
JMX options.
hostname associated with locally created remote objects.

The default setting is as follows:


Launching Kafka and ZooKeeper with JMX Enabled

The steps for launching Kafka and ZooKeeper with JMX enabled are the same as shown in the Confluent Platform Quick Start (Docker), with the only difference being that you set KAFKA_JMX_PORT and KAFKA_JMX_HOSTNAME for both. Here are examples of the Docker run commands for each service:

docker run -d \
  --name=zk-jmx \
  --net=host \
  -e KAFKA_JMX_PORT=39999 \
  -e KAFKA_JMX_HOSTNAME=`docker-machine ip confluent`

docker run -d \
  --name=kafka-jmx \
  --net=host \
  -e KAFKA_ZOOKEEPER_CONNECT=localhost:32181/jmx \
  -e KAFKA_JMX_PORT=49999 \
  -e KAFKA_JMX_HOSTNAME=`docker-machine ip confluent` \

Note: in the KAFKA_JMX_HOSTNAME environment variable example above, it assumes you have a Docker machine named “Confluent”. You should substitute with your Docker machine name where appropriate.