<style>
  input.search-bar {
    box-sizing: border-box;
    margin-bottom: 30px;
    font-size: 22px;
    padding: 20px;
    padding-left: 60px;
    border: 0;
    border-radius: 4px;
    box-shadow: none;
    flex: 1;
    width: 100%;
    color: #3B454F;
    line-height: 27.5px;
    background: #F1FAFF 20px 24px no-repeat url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAGqSURBVHgBrZRBTsJQEIZnHi6AkNiVeYRNDZC4xBMIN9AT0BuIJxBPwBHEExhPQDmB7NFYFiRNcNEFCZu2z5n2EUnpKwSd5KXT8vN15vWfh5AJy7KtSuXMiWNlI8I5AC7osev7Hy4cEbh7I2XrUQgYKAXWvlR5SkU93/c8OAYoZfsZUTn6dkpQNxEg2nS5ISBfgzDE3mo1nxUCuTJqb0griGO4y7Yn5ZUtRDiil9wydLMJL4PAC3KJLK7XW4qXlE0HCoI0k1TXGpo0AiDq6nzq+5/jAh5QhU9JWwj3RiBi3NFiFw7EzlZY7IZcoFLCghOiXIZ8INsBkgrVQTDv9zY32YeAaatCYN/Uxm+EfZ1MTQqh94WXVa2WRiZho9HusLU4p27GRqCu7oE9qBQ69Xrzi2zR3Qq4avYpjeK7fkT+i1wTEHcrIFO/6onIFycv5Y9hHkOxTZbL+UypUo/+9kIrK+RR7MXx2XX6G9LBUZpIadvGCrPBrbI1slXwl0aMJmkn+5UagUVRBD0JWAQ9GWiCluAPsV5/B7XaxRudo3ys2TTGC/iP0EfggPMf4IXM0qeAeMAAAAAASUVORK5CYII=);
    background-clip: padding-box;
    }
 </style>

 <script>
 function filterList() {
     // Get input value and convert to lowercase
     var input = document.getElementById("search-bar").value.toLowerCase();

     // Get all of the sections.
     var sections = document.getElementsByTagName("section")

     // Loop through the sections and check for h3s, which is the section type that contains the config values.
     for (var i = 0; i < sections.length; i++) {
     var section = sections[i];
     var h3Entries = section.getElementsByTagName("h3")
     // There is only 1 h3 in a section that contains a config value.
     if (h3Entries.length == 1) {
             // Now, check if the term matches the search input, and if so display the section. Otherwise, hide it.
         var h3text = h3Entries[0].textContent.toLowerCase();
         if (h3text.indexOf(input) > -1)
         section.style.display ="";
         else
         section.style.display = "none";
     }
     }
     }
   window.addEventListener('load', filterList);
 </script>

<a id="configure-jmx"></a>

# Client JMX metrics

Kafka applications expose some internal Java Management Extensions (JMX) metrics,
and many users run JMX exporters to feed the metrics into their monitoring
systems. You can retrieve JMX metrics for your client applications and the
services you manage by starting your Kafka client applications with
the `JMX_PORT` environment variable configured. You cannot use JMX metrics
for the Confluent-managed services.



This topic describes how to configure Java Management Extensions (JMX) to monitor Kafka and Confluent Cloud components.
JMX is the standard method for exposing internal metrics from Java applications.

## JMX environment variables

You can use the following JVM environment variables to configure JMX monitoring when you start Kafka or use
Java system properties to enable remote JMX programmatically.

- `JMX_PORT`: The port that JMX listens on for incoming connections.
- `JMX_HOSTNAME`: The hostname associated with locally created remote objects.
- `KAFKA_JMX_OPTS`: JMX options. Use this variable to override default JMX options, such as authentication.

  The default options are set as follows:

  `-Djava.rmi.server.hostname=127.0.0.1 -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false`
  - `server.hostname`: Specifies the host a JMX client connects to. The default is `localhost` (`127.0.0.1`).
  - `jmxremote=true`: Enables the JMX remote agent and enables the connector to listen through a specific port.
  - `jmxremote.authenticate=false`: Indicates that authentication is off by default.
  - `jmxremote.ssl=false`: Indicates that TLS/SSL is off by default.

  For example, to start Kafka and specify a JMX port, use the following command:

```none
JMX_PORT=2020 ./bin/kafka-server-start ./etc/kafka/server.properties
```

For details on JMX configuration, see [Monitoring and Management using JMX technology](https://docs.oracle.com/javase/8/docs/technotes/guides/management/agent.html).

## View MBeans with JConsole

To see JMX monitoring in action, you can use [JConsole](https://docs.oracle.com/javase/8/docs/technotes/guides/management/jconsole.html),
a utility provided with Java.

1. Start JConsole using the `jconsole` command.
2. Connect to the Kafka process:
   - If Kafka is running locally, select it from **Local Process**.
   - If Kafka is running remotely (such as in Docker), select **Remote Process**, enter the hostname and port, and click **Connect**.
3. Enter a valid username and password, or accept an **Insecure connection** if authentication is not configured.
4. Select the **MBeans** tab and expand the folders to see JMX events and attributes.

#### NOTE
You will only see MBeans for features enabled on your nodes. If you don’t see an expected MBean for a feature or component,
verify the feature is enabled and you’re viewing the correct process.

You can also view JMX metrics with console tools such as Jmxterm or export JMX metrics to other monitoring tools such as Prometheus.
For a demo on how to use popular monitoring tools with Confluent products, see
[JMX Monitoring Stacks on GitHub](https://github.com/confluentinc/jmx-monitoring-stacks).

## Configure security

By default, password authentication and TLS/SSL are disabled for JMX in Kafka. However, in a production environment,
enable authentication and TLS/SSL to prevent unauthorized users from accessing your brokers.

To enable security for JMX, override the default JMX settings to enable authentication and SSL.

For details on how to secure JMX, refer to the TLS/SSL and authentication sections in
[Monitoring and Management Using JMX Technology](https://docs.oracle.com/javase/8/docs/technotes/guides/management/agent.html).

## Related content

- [Producer Metrics](producer-metrics.md#producer-metrics)
- [Consumer Metrics](consumer-metrics.md#consumer-metrics)
- [Monitoring and management using JMX technology](https://docs.oracle.com/javase/8/docs/technotes/guides/management/agent.html)
- [JMX monitoring stacks on GitHub](https://github.com/confluentinc/jmx-monitoring-stacks)
