Jestino Sam
Jestino Sam

Reputation: 602

Kafka Network Metrics using Metric API

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?

Upvotes: 1

Views: 300

Answers (1)

OneCricketeer
OneCricketeer

Reputation: 191671

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

Upvotes: 1

Related Questions