Setting up jmx monitoring for Apache Kafka

I was looking to setup jmx monitoring for Apache Kafka.

Seems straightforward. Edit the server start and add something like what is below.

if [ “x$KAFKA_JMX_OPTS” = “x” ]; then
export KAFKA_JMX_OPTS=""

The issue I have is if I have a systemd file kafka@.service that calls the common server start file for multiple brokers, I will have port collision.

Is there a better way of doing this?

Figured it out

Defining the env variable in the systemd file sets the port as a variable.


Adding the call to the jmx file as an argiment in EXTRA_ARGS then loads the remainder of the jmx parameters.