:_mod-docs-content-type: CONCEPT

Configures JMX connection options.

Get JMX metrics from Kafka brokers, Kafka Connect, and MirrorMaker 2. by connecting to port 9999.
Use the `jmxOptions` property to configure a password-protected or an unprotected JMX port.
Using password protection prevents unauthorized pods from accessing the port.

You can then obtain metrics about the component.

For example, for each Kafka broker you can obtain bytes-per-second usage data from clients,
or the request rate of the network of the broker.

To enable security for the JMX port, set the `type` parameter in the `authentication` field to `password`.

.Example password-protected JMX configuration for Kafka brokers
[source,yaml,subs=attributes+]
----
apiVersion: {KafkaApiVersion}
kind: Kafka
metadata:
  name: my-cluster
spec:
  kafka:
    # ...
    jmxOptions:
      authentication:
        type: "password"
    # ...
----

You can then deploy a pod into a cluster and obtain JMX metrics using the headless
service by specifying which broker you want to address.

For example, to get JMX metrics from broker _0_ you specify:

[source,shell,subs="+quotes,attributes"]
----
"_CLUSTER-NAME_-kafka-0._CLUSTER-NAME_-kafka-brokers"
----

`_CLUSTER-NAME_-kafka-0` is name of the broker pod, and `_CLUSTER-NAME_-kafka-brokers` is the name of the headless service to return the IPs of the broker pods.

If the JMX port is secured, you can get the username and password by referencing them from the JMX Secret in the
deployment of your pod.

For an unprotected JMX port, use an empty object `{}` to open the JMX port on the headless service.
You deploy a pod and obtain metrics in the same way as for the protected port, but in this case any pod can read from the JMX port.

.Example open port JMX configuration for Kafka brokers
[source,yaml,subs=attributes+]
----
apiVersion: {KafkaApiVersion}
kind: Kafka
metadata:
  name: my-cluster
spec:
  kafka:
    # ...
    jmxOptions: {}
    # ...
----

NOTE: The `jmxOptions` configuration enables direct access to Java Management Extensions (JMX) from Kafka components. 
It is not required for the Prometheus JMX Exporter, which collects and converts JMX metrics to Prometheus metrics without direct JMX access.

[role="_additional-resources"]
.Additional resources

 * For more information on the Kafka component metrics exposed using JMX, see the {kafkaDoc}.
