Monitoring server statistics
Kafka exposes monitoring statistics using Yammer metrics. Yammer metrics is a protocol that exposes six types of metrics: gauges, counters, meters, histograms, timers, and health checks. This recipe shows how to monitor the metrics exposed by Kafka from the server side. In the following recipes, we cover the producer and consumer related metrics.
Getting ready
For this recipe, we just need a Kafka broker up and running.
To set the JMX port, from the Kafka installation directory start the broker using the following command:
$ JMX_PORT=10101 bin/kafka-server-start.sh config/server.properties
Also, JConsole must be installed, check the installation with the following command:
$ jconsole
How to do it...
- Run JConsole using the following command:
$ jconsole 127.0.0.1:10101
- In the following screenshot, we can see all the different parameters plotted over time:
Figure 9.1: JConsole after executing command: jconsole 127.0.0.1:10101
- Switch to the
MBeans
tab and expand the Kafka server...