I am trying to get all the metrics of kafka producer via producer.metrics() api call.
I am able to fetch few metrics but i am not able to see all the metrics mentioned in https://kafka.apache.org/20/documentation.html for kafka.producer:type=producer-metrics
My attempt :
I am trying to get the metrics for attribute record-send-rate and record-send-total.
But I can only see the record-send-rate values but i am not able to find the record-send-total.
final Map<MetricName, ? extends Metric> metricsDisplayMap = producer.metrics();
for (Map.Entry<MetricName, ? extends Metric> entry : metricMap.entrySet()) {
if (metricsNameFilter.contains(entry.getKey().name()) && entry.getKey().group().equalsIgnoreCase("producer-metrics")) {
System.out.print(entry.getKey().name() + " : " + entry.getValue().value() + " <--> " + entry.getKey().group() + " \n ");
}
(1) I need to print all the metrics of producer like number of records sent, time taken etc
(2)Also, I would like to know that is there any other way to collect the metrics for kafka producers
(3) What is the use of KafkaMetricsReporter and when it is used ?