Kafka Cluster
Producers
Programming
Data Streaming
Apache Kafka

How to list all producers of a Kafka cluster

Codemia Knowledge Hub ·

Kafka has no built-in command or API that lists the producer applications writing to a cluster. Brokers treat incoming data as streams and keep no explicit record of which client sent it, unlike the way they track consumers. Since Kafka 3.0 the Admin API's describeProducers() returns the active idempotent and transactional producer IDs per partition, but not client IDs or hosts. You can still identify producers indirectly, using the four methods below.

What a producer looks like to the broker

A Kafka producer is any application or process that sends messages to Kafka topics. Each message has a key, a value and a timestamp. Producers send data to brokers, and the brokers handle storage and replication across the cluster.

1. Inspect client connections on the brokers

Network tools on a broker host show which clients are connected right now. On Linux, use netstat:

 
     netstat -anp | grep :9092

:9092 is the default Kafka broker port. The output lists the IP addresses connected to the broker.

2. Turn on the broker request log

A broker at the default INFO level does not log client connections, so its normal logs will not show producers. The request logger does: at DEBUG it writes one Completed request line per request to kafka-request.log, with the clientId, the API name (PRODUCE, INIT_PRODUCER_ID), the topic and the client address in the connection field. You can switch it on at runtime without a restart:

bash
1kafka-configs.sh --bootstrap-server localhost:9092 \
2  --entity-type broker-loggers --entity-name 1 \
3  --alter --add-config kafka.request.logger=DEBUG
4
5grep '"requestApiKeyName":"PRODUCE"' /opt/kafka/logs/kafka-request.log

It logs every request, so it grows fast on a busy broker. Set it back to WARN once you have what you need.

3. Query producer metrics over JMX

Give each producer its own client ID. You can then query the JMX (Java Management Extensions) metrics with jConsole or another JMX client to get statistics per producer:

 
     kafka.producer:type=producer-metrics,client-id=client_id

The result contains performance and health metrics for the producer identified by client_id. This MBean lives in each producer's own JVM, not on the broker, so it helps you inspect producers you already know about rather than discover them.

4. Describe active producers with the Admin API

Admin.describeProducers() (Kafka 3.0+) asks the partition leader for its active idempotent and transactional producers. Since Kafka 3.0 producers are idempotent by default, so this covers most modern clients:

java
1     Properties props = new Properties();
2     props.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092");
3     try (Admin admin = Admin.create(props)) {
4         TopicPartition tp = new TopicPartition("your-topic", 0);
5         DescribeProducersResult result = admin.describeProducers(List.of(tp));
6         result.partitionResult(tp).get().activeProducers().forEach(p ->
7             System.out.println(tp + " producerId=" + p.producerId()
8                 + " epoch=" + p.producerEpoch()
9                 + " lastTimestamp=" + p.lastTimestamp()));
10     }

The same data is available from the command line:

bash
kafka-transactions.sh --bootstrap-server localhost:9092 describe-producers --topic your-topic --partition 0

After two console-producer runs against a test topic, it printed:

text
ProducerId	ProducerEpoch	LatestCoordinatorEpoch	LastSequence	LastTimestamp	CurrentTransactionStartOffset	
0         	0            	-1                    	1           	1795889962863	None                         	
1         	0            	-1                    	0           	1795889972165	None                         	

You get producer IDs, not client IDs or hosts, so pair this with the request log (method 2) when you need to know which application a producer ID belongs to.

Comparing the methods

MethodDescriptionProsCons
Examine Client ConnectionsUse networking tools to inspect connections on Kafka broker ports.Quick and straightforwardOnly shows active connections
Broker Request LogEnable kafka.request.logger at DEBUG and read client IDs from PRODUCE requests.Names client ID and addressVery verbose; must be enabled first
Kafka Producer MetricUtilize JMX to fetch metrics about Kafka producers with a specific client ID.Detailed metrics per producerLives in the producer JVM; you must already know the producer
Admin describeProducersAdmin.describeProducers() or kafka-transactions.sh describe-producers per partition.Lists active producer IDs from the brokerIDs only, no client ID or host; idempotent and transactional producers only

In practice, combining describeProducers, the request log and network monitoring gives the most complete picture of which producers talk to your cluster.


Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design