Kafka JMX metrics in console

2019-03-29 00:23发布

A Kafka cluster can be monitored in granular detail via the JMX metrics it exposes. Usually an external GUI or application like jconsole needs to be hooked up to a broker's exposed JMX_PORT in order to view these metrics.

Is there a way that I can view a broker's JMX metrics in an SSH session, via STDOUT? Is there a native Kafka command that I can run to view these metrics?

3条回答
Animai°情兽
2楼-- · 2019-03-29 01:11

Download the jar located here:

https://sourceforge.net/projects/cyclops-group/files/jmxterm/1.0-alpha-4/

On the machine, then run:

wget https://sourceforge.net/projects/cyclops-group/files/jmxterm/1.0-alpha-4/ -o jmx.jar

java -jar jmx.jar

>open localhost:$jmx_port

Help will give you what you need after that :)

Save this jar somewhere useful, I use it nearly every day.

查看更多
何必那么认真
3楼-- · 2019-03-29 01:14

Kafka does have a tool for this.

Assuming you have enabled JMX on your broker on the default port of 9999, you can simply run this example command to print out jmx metrics for BrokerTopics via STDOUT

/usr/bin/kafka-run-class kafka.tools.JmxTool --object-name kafka.server:type=BrokerTopicMetrics,name=MessagesInPerSec

查看更多
登录 后发表回答