我正在尝试将Kafka指标(版本0.8.2)发送到我的grafana服务器。不幸的是,我只能获得java.lang指标,但没有kafka指标。现在连接jmxtrans和jconsoel是个问题,我可以看到Kafka的MBean。
配置jmxtrans:
{
"servers" : [ {
"port" : "9393",
"host" : "localhost",
"queries" : [ {
"obj" : "kafka.network:type=RequestMetrics,name=LocalTimeMs,request=ConsumerMetadata",
"attr" : [ "Count" ],
"outputWriters" : [ {
"@class" : "com.googlecode.jmxtrans.model.output.GraphiteWriter",
"settings" : {
"port" : 2003,
"host" : "localhost"
}
} ]
}, {
"obj" : "kafka.network:type=RequestMetrics,name=RequestQueueTimeMs,request=FetchConsumer",
"attr" : [ "Count" ],
"outputWriters" : [ {
"@class" : "com.googlecode.jmxtrans.model.output.GraphiteWriter",
"settings" : {
"port" : 2003,
"host" : "localhost"
}
} ]
}, {
"obj" : "kafka.network:type=RequestMetrics,name=TotalTimeMs,request=OffsetFetch",
"attr" : [ "Count" ],
"outputWriters" : [ {
"@class" : "com.googlecode.jmxtrans.model.output.GraphiteWriter",
"settings" : {
"port" : 2003,
"host" : "localhost"
}
} ]
}, {
"obj" : "kafka.network:type=RequestMetrics,name=TotalTimeMs,request=Offsets",
"attr" : [ "Count" ],
"outputWriters" : [ {
"@class" : "com.googlecode.jmxtrans.model.output.GraphiteWriter",
"settings" : {
"port" : 2003,
"host" : "localhost"
}
} ]
}
],
"numQueryThreads" : 2
} ]
}
jmxtrans日志:
15:52:11.564 [ServerScheduler_Worker-10] DEBUG org.quartz.core.JobRunShell - Calling execute on job ServerJob.localhost:9393-1443714611563-0428747962
15:52:11.564 [ServerScheduler_Worker-10] DEBUG c.googlecode.jmxtrans.jobs.ServerJob - +++++ Started server job: Server [host=localhost, port=9393, url=null, cronExpression=null, numQueryThreads=2]
15:52:11.569 [ServerScheduler_Worker-10] DEBUG com.googlecode.jmxtrans.jmx.JmxUtils - ----- Creating 4 query threads
15:52:11.638 [pool-60-thread-2] DEBUG c.g.jmxtrans.jmx.JmxQueryProcessor - Executing queryName [kafka.network:name=RequestQueueTimeMs,request=FetchConsumer,type=RequestMetrics] from query [Query [obj=kafka.network:type=RequestMetrics,name=RequestQueueTimeMs,request=FetchConsumer, useObjDomainAsKey:false, resultAlias=null, attr=[Count]]]
15:52:11.638 [pool-60-thread-2] DEBUG c.g.jmxtrans.jmx.JmxQueryProcessor - Finished running outputWriters for query: Query [obj=kafka.network:type=RequestMetrics,name=RequestQueueTimeMs,request=FetchConsumer, useObjDomainAsKey:false, resultAlias=null, attr=[Count]]
15:52:11.640 [pool-60-thread-2] DEBUG c.g.jmxtrans.jmx.JmxQueryProcessor - Executing queryName [kafka.network:name=TotalTimeMs,request=OffsetFetch,type=RequestMetrics] from query [Query [obj=kafka.network:type=RequestMetrics,name=TotalTimeMs,request=OffsetFetch, useObjDomainAsKey:false, resultAlias=null, attr=[Count]]]
15:52:11.640 [pool-60-thread-2] DEBUG c.g.jmxtrans.jmx.JmxQueryProcessor - Finished running outputWriters for query: Query [obj=kafka.network:type=RequestMetrics,name=TotalTimeMs,request=OffsetFetch, useObjDomainAsKey:false, resultAlias=null, attr=[Count]]
15:52:11.641 [pool-60-thread-2] DEBUG c.g.jmxtrans.jmx.JmxQueryProcessor - Executing queryName [kafka.network:name=TotalTimeMs,request=Offsets,type=RequestMetrics] from query [Query [obj=kafka.network:type=RequestMetrics,name=TotalTimeMs,request=Offsets, useObjDomainAsKey:false, resultAlias=null, attr=[Count]]]
15:52:11.641 [pool-60-thread-2] DEBUG c.g.jmxtrans.jmx.JmxQueryProcessor - Finished running outputWriters for query: Query [obj=kafka.network:type=RequestMetrics,name=TotalTimeMs,request=Offsets, useObjDomainAsKey:false, resultAlias=null, attr=[Count]]
15:52:11.642 [pool-60-thread-1] DEBUG c.g.jmxtrans.jmx.JmxQueryProcessor - Executing queryName [kafka.network:name=LocalTimeMs,request=ConsumerMetadata,type=RequestMetrics] from query [Query [obj=kafka.network:type=RequestMetrics,name=LocalTimeMs,request=ConsumerMetadata, useObjDomainAsKey:false, resultAlias=null, attr=[Count]]]
15:52:11.642 [pool-60-thread-1] DEBUG c.g.jmxtrans.jmx.JmxQueryProcessor - Finished running outputWriters for query: Query [obj=kafka.network:type=RequestMetrics,name=LocalTimeMs,request=ConsumerMetadata, useObjDomainAsKey:false, resultAlias=null, attr=[Count]]
15:52:11.643 [ServerScheduler_Worker-10] DEBUG c.googlecode.jmxtrans.jobs.ServerJob - +++++ Finished server job: Server [host=localhost, port=9393, url=null, cronExpression=null, numQueryThreads=2]
对我来说,看起来jmxtrans可以毫无问题地连接并尝试获取数据,但是根本没有从kafka指标获得任何数据。
Kafka的JMX选项:
-Djava.net.preferIPv4Stack=true -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=9393 -Djava.rmi.server.hostname=example.com -Dcom.sun.management.jmxremote.rmi.port=9011
知道为什么Kafka指标不可用?
感谢。
答案 0 :(得分:1)
某些版本的Kafka引用了JMX元素(您可以在jconsole中看到属性有引号)。这已经/正在改变未来版本的Kafka。查看此帖子(How to monitor Kafka broker using jmxtrans?)了解详细信息,但如果您使用带引号的字符串,则应该有效(请参阅下面的示例:)
"obj": "\"kafka.server\":type=\"BrokerTopicMetrics\",name \"AllTopicsLogBytesAppendedPerSec\"", "attr": [ "Count" ]
请注意" obj"值需要额外的报价。当我尝试这个时,JMXTRANS在obj字符串中输入正确的(引用的)值后提供了有效的输出...