0

I've have kafka producer running same code from 3 different linux servers sending messages to same kafka cluster topic. Below is the sample code -

    KafkaProducer<?, byte[]> producer = new KafkaProducer<?, byte[]>(props);
    Map<MetricName, ? extends Metric> metrics =  producer.metrics();
    System.out.println(metrics.keySet());

The sample of the MetricName produced by the above code -

MetricName [name=request-rate, group=producer-node-metrics, description=The number of requests sent per second, tags={client-id=ImpLog, node-id=node--3}],

MetricName [name=request-rate, group=producer-node-metrics, description=The number of requests sent per second, tags={client-id=ImpLog, node-id=node--2}],

MetricName [name=request-rate, group=producer-node-metrics, description=The number of requests sent per second, tags={client-id=ImpLog, node-id=node--1}],

MetricName [name=request-total, group=producer-node-metrics, description=The total number of requests sent, tags={client-id=ImpLog, node-id=node--1}],

So my question is what is node-id=node--3 tag of the kafka producer MetricName. Is it identifies the kafka producer instance uniquely? If so, can I get it from the KafkaProducer instance? Because I don't want to report metrics belongs to that different server from a specific server

Community
  • 1
  • 1
user51
  • 8,843
  • 21
  • 79
  • 158
  • `node-` + `-1` is the first node in your bootstrap servers, -3 is the third. You should be using clientId to uniquely identify clients. For example, add the hostname or ip to the clientid – OneCricketeer Dec 02 '19 at 04:18
  • @cricket_007 for bootstrap server `server01.kafka.qa.myorg.com:9092,server02.kafka.qa.myorg.com:9092,server03.kafka.qa.myorg.com:9092` node--1 always represents `server01.kafka.qa.myorg.com:9092` correct? – user51 Dec 02 '19 at 05:32
  • I think it might be the last one (negative indexing), but should always refer to the same across clients using the same string – OneCricketeer Dec 02 '19 at 05:51

0 Answers0