jmxtrans和Kafka不工作

q5lcpyga  于 2021-06-08  发布在  Kafka
关注(0)|答案(1)|浏览(314)

我正在尝试将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指标不可用吗?
谢谢。

bt1cpqcv

bt1cpqcv1#

一些版本的kafka引用了jmx元素(您可以看到jconsole中的属性带有引号)。对于Kafka的未来版本来说,这种情况已经/正在发生变化。查看this post(如何使用jmxtrans监视kafka代理?)了解详细信息,但是如果您使用带引号的字符串,它应该可以工作(参见下面的示例:)

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

请注意,“obj”值需要附加引号。当我尝试这样做时,jmxtrans在将正确的(引用的)值放入obj字符串后提供了有效的输出。。。

相关问题