Is there any way to get the Request total time from kafka.network:type=RequestMetrics,name=TotalTimeMs,request={Produce|FetchConsumer|FetchFollower} using the Metrics java API?

Using the below code, I am able to get the producer Metric.

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

But I am not sure how to get the TotalTimeMs metric. Can anybody point how to get the same?

1 Answers

1
cricket_007 On

kafka.network:type=RequestMetrics,name=RequestsPerSec,request={Produce|FetchConsumer|FetchFollower} is available on the broker, not from a client application.

You would have to connect remotely to an exposed JMX port on it, or setup Prometheus or Jolokia, for example, to export that metric over HTTP