How to enable remote JMX on Kafka brokers (for JmxTool)?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Apache Kafka is a distributed event streaming platform capable of handling trillions of events a day. While operational, monitoring Kafka's performance and health is crucial. One effective way to monitor Kafka is by enabling Java Management Extensions (JMX), which allows you to monitor, manage, and troubleshoot Kafka brokers remotely. Here we will detail the process of enabling remote JMX on Kafka brokers specifically for use with tools like JmxTool.
Enabling Remote JMX on Kafka Brokers
1. Configure Kafka Brokers to Expose JMX Ports
Kafka brokers do not enable JMX remote access by default; you need to manually enable it. You can do this by editing the Kafka broker's configuration. Locate and modify the server.properties file typically found in the config directory of your Kafka installation.
Add the following lines to enable JMX:
Replace [Your-Hostname-Here] with the broker's hostname or IP address where you want to enable JMX monitoring.
2. Restart Kafka Broker
After updating the configuration file, restart each broker to apply the changes. Use the appropriate command based on your Kafka setup:
3. Testing JMX Connection
To ensure that JMX is enabled and accessible remotely, use the jconsole tool available with the Java Development Kit (JDK):
If the settings are correct, you will see JConsole connect to the Kafka broker, where you can monitor various metrics like memory usage, thread count, and Kafka-specific metrics.
Using JmxTool with Remote JMX
Kafka ships with a tool called kafka.tools.JmxTool. This can be used to view JMX metrics from the command line. Here’s how to use it:
Replace [Your-Hostname-Here] accordingly. This example connects to the JMX server and retrieves metrics related to the number of messages received per second.
Security Considerations
Enabling remote JMX without authentication and SSL/TLS can expose sensitive data and control capabilities over the network. It's highly recommended to secure the JMX connection. For a production environment, consider enabling authentication and SSL as following:
Adjust paths and passwords as necessary.
Summary Table
| Configuration Parameter | Description | Example Values |
JMX_PORT | Port for JMX to listen on | 9999 |
-Dcom.sun.management.jmxremote | Enables remote monitoring | true |
-Dcom.sun.management.jmxremote.authenticate | Enables/disables authentication | false (for no auth), true (for auth) |
-Dcom.sun.management.jmxremote.ssl | Enables/disables SSL security | false (for no SSL), true (for SSL) |
-Djava.rmi.server.hostname | Hostname for JMX/RMI server interactions | IP address or hostname of Kafka broker |
-Dcom.sun.management.jmxremote.rmi.port | RMI registry port for remote JMX | Same as JMX_PORT (e.g., 9999) |
By following the above steps and considerations, you can successfuly set up remote JMX monitoring for Kafka brokers, enhancing visibility into cluster operations and performance.
Related reading
- How to enable stats in RabbitMQ management UI
- How to encode/decode Kafka messages using Avro binary encoder?
- how to enforce schema validation in kafka
- How to ensure task execution order per user using Celery, RabbitMQ and Django?
- How to enable streaming replication in PostgreSQL running in kubernetes pods?
- How to enable/disable buildkit in docker?
- How to export data from Kafka to Prometheus?
- How to expose a headless Kafka service for a StatefulSet externally in Kubernetes

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.