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:

  1. On your Kafka broker server, 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:

    • Set JMX_PORT to 9999 (or your preferred port).
    • Set KAFKA_JMX_OPTS to enable remote JMX access.

    For example, add these lines to your Kafka systemd service file or startup script:

    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 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.

Were you successful?

More to explore (optional)

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

Kafka JMX Metrics Reference


page 5 of 12