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 your monitoring tool can collect and forward to Grafana Cloud.

To configure JMX settings, you’ll 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.

On your Kafka broker server, complete the following steps:

  1. Locate the Kafka configuration directory (typically /opt/kafka/config or /etc/kafka).

  2. Edit the server.properties file or create a kafka-run-class.sh override.

  3. Add or update the following JMX environment variables in your Kafka startup script or systemd service file:

    Bash
    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"
  4. If running multiple brokers, ensure each broker uses a unique JMX port or IP binding.

  5. Restart the Kafka broker service to apply the JMX configuration changes.

  6. Verify the JMX port is accessible: 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 learn about the advantages of using Grafana Alloy for Kafka metrics collection.


More to explore (optional)

At this point in your journey, you can explore the following paths:


Troubleshooting

Explore the following troubleshooting topics if you need help:

Were you successful?


page 3 of 12