0

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 ?

LearnerForLife
  • 147
  • 1
  • 12
  • I don't think `record-send-total` is the name of the **group**. See https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/clients/producer/internals/SenderMetricsRegistry.java#L98 – mazaneicha Jul 30 '19 at 14:18
  • @mazaneicha - it was a typo, group name was supposed to be producer-metrics . After filtering, i am not able to see record-send-rate – LearnerForLife Jul 30 '19 at 14:23

1 Answers1

0

From what I see in Kafka documentation, record-send-total metric exists and should be accessible.

Those documented metrics are meant to be accessed via JMX though. Did you try to access them using JMX client tool ? This should answer your second question maybe.

Here is some documentation on how to monitor your Kafka JMX metrics :

https://access.redhat.com/documentation/en-us/red_hat_amq/7.3/html/using_amq_streams_on_red_hat_enterprise_linux_rhel/monitoring-str

Yannick

Yannick
  • 1,240
  • 2
  • 13
  • 25