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.
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:
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...
As I could've found out in
./bin/jmxtrans.sh
, by default the stdout/log file is/dev/null
.That's why it's important to set the env var to something you can use to see the output:
I'm using the following
kafka.json
configuration file:When you start jmxtrans it will query the broker with JMX on
localhost:10101
aboutCount
attribute fortestowo
topic. It will print the result out to the fileLOG_FILE
every 60 secs (you can change it usingSECONDS_BETWEEN_RUNS
env var), e.g.You may want to use other writers of jmxtrans so the output is not intermingled, e.g.
And the last but not least, to set the JMX port to a known value use
JMX_PORT
env var when starting a Kafka broker using./bin/kafka-server-start.sh
, i.e.