# Setting up jmx monitoring for Apache Kafka

**URL:** https://forum.confluent.io/t/setting-up-jmx-monitoring-for-apache-kafka/10593
**Category:** Architecture and Design
**Created:** [30 April 2024 17:17 UTC](https://forum.confluent.io/t/setting-up-jmx-monitoring-for-apache-kafka/10593 "2024-04-30T17:17:14Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![shardservant](https://avatars.discourse-cdn.com/v4/letter/s/f0a364/32.png) [@shardservant](https://forum.confluent.io/u/shardservant)
#### Post date: [30 April 2024 17:17 UTC](https://forum.confluent.io/t/setting-up-jmx-monitoring-for-apache-kafka/10593/1 "2024-04-30T17:17:14Z")

</div>

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=" -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=9000 -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.password.file=/home/kafka/jmx11\_remote/jmxremote.password -Dcom.sun.management.jmxremote.access.file=/home/kafka/jmx11\_remote/jmxremote.access"  
fi

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?

---

<div class="post-metadata">

### Author: ![shardservant](https://avatars.discourse-cdn.com/v4/letter/s/f0a364/32.png) [@shardservant](https://forum.confluent.io/u/shardservant)
#### Post date: [1 May 2024 14:07 UTC](https://forum.confluent.io/t/setting-up-jmx-monitoring-for-apache-kafka/10593/2 "2024-05-01T14:07:46Z")

</div>

Figured it out

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

Environment=“JMX\_PORT=900%i”

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