Configure Kafka JMX exporter
Kafka exposes operational metrics through Java Management Extensions (JMX), which requires enabling JMX remote access on your Kafka brokers. JMX provides comprehensive visibility into broker performance, topic statistics, partition health, and other critical operational data that Grafana Alloy can collect and send to Grafana Cloud.
To configure JMX settings in the Kafka server properties, you’ll need to set the JMX port and authentication options based on your security requirements. The configuration typically involves setting environment variables that the Kafka broker reads during startup to enable JMX remote access.
To configure Kafka JMX exporter, complete the following steps:
On your Kafka broker server, locate the Kafka configuration directory (typically
/opt/kafka/configor/etc/kafka).Edit the
server.propertiesfile or create akafka-run-class.shoverride.Add or update the following JMX environment variables in your Kafka startup script or systemd service file:
- Set
JMX_PORTto 9999 (or your preferred port). - Set
KAFKA_JMX_OPTSto enable remote JMX access.
For example, add these lines to your Kafka systemd service file or startup script:
export JMX_PORT=9999 export KAFKA_JMX_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=9999"- Set
If running multiple brokers, ensure each broker uses a unique JMX port or IP binding.
Restart the Kafka broker service to apply the JMX configuration changes.
Verify the JMX port is accessible using a tool like telnet or nc:
telnet localhost 9999.
The JMX port responds to connection attempts, and you can access JMX metrics from the Kafka broker. Repeat these steps for all brokers in your cluster.
In the next milestone, you configure Grafana Alloy to collect metrics from your Kafka brokers.
Troubleshooting options
Please tell us what didn't work:
At this point in your journey, you can explore the following paths:
