如何使用jmxtrans监视Kafka经纪人? [英] How to monitor Kafka broker using jmxtrans?

查看:90
本文介绍了如何使用jmxtrans监视Kafka经纪人?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Kafka 0.8.1.1(kafka_2.8.0-0.8.1.1.tgz)

Kafka 0.8.1.1 (kafka_2.8.0-0.8.1.1.tgz)

我正在使用jmxtrans对Kafka实例(在docker中运行)执行JMX监视.不幸的是,kafka指标未返回.

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

我已经尝试了一些方法来调试此问题,并且知道kafka运行正常(我可以成功生成/使用消息),得出的结论是jmxtrans确实返回了JMX指标(例如,java.lang:type = Memory,attribute = HeapMemoryUsage返回正确的数据),因此常规的kafka和JMX功能似乎正在运行.另外,当我使用jconsole时,我可以访问这些指标-这些指标似乎已被所有相关字段中的数据捕获.

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.

不幸的是,当我使用以下配置尝试jmxtrans时,我没有得到任何信息(实际上根本没有数据).我认为应该根据kafka文档("kafka.server:type = BrokerTopicMetrics",attribute ="MessagesInPerSec")来捕获指标

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")

以下是我使用的jmxtrans配置:

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
     } ]
}

我不确定为什么不返回数据.也许我设置了无效的jmxtrans配置,或者我未正确指定指标.

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

感谢您的帮助.

推荐答案

经过大量实验,我现在解决了这个问题.为了完整起见,以下是我解决问题的方法.

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

似乎我没有正确指定"obj"值.

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

CORRECT obj值(示例)如下:

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

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

请注意,"obj"值需要附加引号.这似乎很不寻常,与我在其他JMX obj值中看到的普通模式(没有引号)不同.

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将正确的(带引号的)值放入obj字符串后提供了有效的输出...

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

这篇关于如何使用jmxtrans监视Kafka经纪人?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆