Unable to pull JMX data using jolokia from Kafka

3.9k views Asked by At

I have installed Jolokia in centos 7 machine and trying to pull Kafka metrics using Jolokia agent and integrate with Icinga monitoring tool using Nagios plugin check_jmx4perl. Below are the configuration steps I have followed

Step 1: Downloaded jolokia-jvm-1.3.4-agent.jar

Step 2: Copied to /home/usr/

Step 3: Provided permissions by issuing command chmod a+x /home/usr/jolokia-jvm-1.3.4.jar

Step 4: Added to class path by issuing command export KAFKA_OPTS="$KAFKA_OPTS -javaagent:/home/usr/jolokia-jvm-1.3.4-agent.jar=host=*"

Step 5: Started Zookeeper and Kafka in standalone mode and tried to fetch list of topics which works fine by displaying the message

INFO: No access restrictor found, access to all MBean is allowed
Jolokia: Agent started with URL http://0:0:0:0:0:0:0:0:8778/jolokia/

Step 6: Testing jolokia agent by issuing the command j4psh http://localhost:8778

Connection refused

I have also tried by providing IP address but the issue still remains the same. Do I need to make an entry of the host in etc/hosts file?

2

There are 2 answers

1
Nicholas On

Not sure if you are same OP as this question, but:

Perhaps you need to fully qualify the path of the jar. Mine looks like this and works:

export JOLOKIA_HOME=/libs/java/jolokia/1.3.7
export JOLOKIA_JAR=$JOLOKIA_HOME/jolokia-jvm-1.3.7-agent.jar
export KAFKA_OPTS="-javaagent:$JOLOKIA_JAR=port=7778,host=* $KAFKA_OPTS"

When I start Kafka in non-daemon mode, it prints this:

I> No access restrictor found, access to any MBean is allowed
Jolokia: Agent started with URL http://10.8.36.121:7778/jolokia/

Then I point my browser to http://localhost:7778/jolokia/search/: and I get:

{
  "request": {
    "mbean": "*:*",
    "type": "search"
  },
  "value": [
    "kafka.network:name=ResponseQueueTimeMs,request=ListGroups,type=RequestMetrics",
    "kafka.server:delayedOperation=topic,name=PurgatorySize,type=DelayedOperationPurgatory",
    "kafka.server:delayedOperation=Fetch,name=NumDelayedOperations,type=DelayedOperationPurgatory",
    "kafka.network:name=RemoteTimeMs,request=Heartbeat,type=RequestMetrics",
<-- SNIP -->
    "kafka.network:name=LocalTimeMs,request=Offsets,type=RequestMetrics"
  ],
  "timestamp": 1504188793,
  "status": 200
}

j4psh also connects with:

j4psh http://localhost:7778/jolokia
0
Vinayak Mishra On

Add to KAFKA_OPTS:

javaagent:/usr/share/java/kafka/jolokia-jvm-1.6.0-agent.jar -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=localhost -Dcom.sun.management.jmxremote.rmi.port=9999  -Djava.security.auth.login.config=/var/private/sasl_acl/kafka.server.jaas.config