如何使用 jmxtrans 监控 Kafka 代理? [英] How to monitor Kafka broker using jmxtrans?
问题描述
卡夫卡 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.
在 obj 字符串中放入正确的(带引号的)值后,JMXTRANS 提供了有效的输出...
JMXTRANS provided valid output after putting the correct (quoted) values in the obj string...
这篇关于如何使用 jmxtrans 监控 Kafka 代理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!