Friday, October 6, 2017

Monitoring Kafka Broker JMX using Jolokia JVM Agent

Download Jolokia JVM Agent from following location
https://jolokia.org/download.html
wget http://search.maven.org/remotecontent?filepath=org/jolokia/jolokia-jvm/1.3.7/jolokia-jvm-1.3.7-agent.jar

mv jolokia-jvm-1.3.7-agent.jar agent.jar
here is the small shell script to get metrics you are intersted in
#!/bin/sh

url=`java -jar agent.jar start $1 | tail -1`

memory_url="${url}read/kafka.server:type=KafkaRequestHandlerPool,name=RequestHandlerAvgIdlePercent"
used=`wget -q -O - "${memory_url}/MeanRate" | grep MeanRate`
echo $used
java -jar agent.jar --quiet stop $1
we are good to run this and start seeing this messages (19876 is the pid for kafka broker)
./script1.sh 19876 
{"timestamp":1507308779,"status":200,"request":{"mbean":"kafka.server:name=RequestHandlerAvgIdlePercent,type=KafkaRequestHandlerPool","attribute":"MeanRate","type":"read"},"value":0.9999940178320261}

No comments: