How to monitor Kafka broker using jmxtrans

apache-kafkajmxjmxtrans

Kafka 0.8.1.1 (kafka_2.8.0-0.8.1.1.tgz)

I am using jmxtrans to do JMX monitoring of a Kafka instance (which is running in docker). Unfortunately, kafka metrics are not being returned.

I have tried a few things to debug this and know that kafka is running correctly (I can produce/consume messages successfully) have concluded that jmxtrans does return JMX metrics (for example, java.lang:type=Memory, attribute=HeapMemoryUsage returns correct data) so the general kafka and JMX capability seems to be working. Also, I can access the metrics when I use jconsole — the metrics seem to be captured with data in all relevant fields.

When I try jmxtrans using the following configuration, unfortunately, I do not get any information back (no data at all in fact). I believe the metrics are supposed to be captured based upon the kafka documentation ("kafka.server:type=BrokerTopicMetrics", attribute="MessagesInPerSec")

The following is the jmxtrans configuration that I used:

{
    "servers" : [ {
        "port" : "9999",
        "host" : "10.0.1.201",
        "queries" : [ {
            "outputWriters" : [ {
                "@class" : "com.googlecode.jmxtrans.model.output.StdOutWriter",
                "settings" : {
                 }
             } ],
             "obj" : "kafka.server:type=BrokerTopicMetrics",
             "attr" : [ "MessagesInPerSec" ]
         } ],
         "numQueryThreads" : 2
     } ]
}

I am not sure why data is not returned. Maybe I setup an invalid jmxtrans configuration or perhaps I am specifying the metric improperly.

Any help is appreciated.

Best Answer

After a lot of experimentation, I have now resolved the question. For completeness, below is how I resolved the problem.

It appears that I specified the "obj" value incorrectly.

The CORRECT obj value (an example) is as follows:

"obj": "\"kafka.server\":type=\"BrokerTopicMetrics\",name \"AllTopicsLogBytesAppendedPerSec\"",
"attr": [ "Count" ]

Note that the "obj" value requires additional quotes. This seems unusual and different than the normal pattern I have seen (no quotes) for other JMX obj values.

JMXTRANS provided valid output after putting the correct (quoted) values in the obj string...

Related Topic