Kafka Producer Metrics

跟風遠走 提交于 2019-12-22 01:30:37

问题


I am running a Kafka producer in a local machine using my Intellij IDE & the producer will be producing a million records. While doing so, I want to capture the producer metrics in the below way:

I am aware about JMX port for kafka & I did try setting the Kafka JMX port to 9999. But I am not sure if we can get the metrics using JConsole or JVisualVM in the above way that I am expecting.

Can any one suggest any idea as to how can this be achieved?


回答1:


In addition of JMX, the official Kafka clients also expose their metrics via the Java API, see the metrics() method to retrieve them all.

For example, to print all the metrics' names and values:

for (Entry<MetricName, ? extends Metric> entry : producer.metrics().entrySet()) {
    System.out.println(entry.getKey().name() + " : " + entry.getValue().metricValue());
}

Out of all the metrics, you are probably interested in outgoing-byte-rate, request-total and request-rate.



来源:https://stackoverflow.com/questions/56016032/kafka-producer-metrics

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!