N
InsightHorizon Digest

How can I see all Kafka topics

Author

John Parsons

Updated on March 25, 2026

Run the command to log on to the Kafka container: kubectl exec -it broker-0 bash -n <suite namespace>Run the command to list the Kafka topics: ./bin/kafka-topics.sh –list –zookeeper itom-di-zk-svc:2181.

How can I see the kafka topics?

  1. Run the command to log on to the Kafka container: kubectl exec -it broker-0 bash -n <suite namespace>
  2. Run the command to list the Kafka topics: ./bin/kafka-topics.sh –list –zookeeper itom-di-zk-svc:2181.

How can I see my kafka topic partitions?

  1. Stream kafka-topics describe output for the given topics of interest.
  2. Extract only the first line for each topic which contains the partition count and replication factor.
  3. Multiply PartitionCount by ReplicationFactor to get total partitions for the topic.
  4. Sum all counts and print total.

How do I list topics in kafka container?

  1. Start Kafka. bin/kafka-server-start.sh config/server.properties. …
  2. List Topics. bin/kafka-topics.sh –list –zookeeper localhost:2181. …
  3. Send Message. bin/kafka-console-producer.sh –broker-list localhost:9092 –topic test. …
  4. Start Consumer.

Where kafka topics are stored?

By default on Linux it is stored in /tmp/kafka-logs . If you will navigate to this folder you will see something like this: recovery-point-offset-checkpoint. replication-offset-checkpoint.

What is bootstrap server in Kafka?

bootstrap. servers is a comma-separated list of host and port pairs that are the addresses of the Kafka brokers in a “bootstrap” Kafka cluster that a Kafka client connects to initially to bootstrap itself. Kafka broker. A Kafka cluster is made up of multiple Kafka Brokers. Each Kafka Broker has a unique ID (number).

How can I tell if Kafka is running UNIX?

I would say that another easy option to check if a Kafka server is running is to create a simple KafkaConsumer pointing to the cluste and try some action, for example, listTopics(). If kafka server is not running, you will get a TimeoutException and then you can use a try-catch sentence.

How do you check Kafka retention period?

  1. 3.1. Basics. First, let’s inspect the default value for retention by executing the grep command from the Apache Kafka directory: $ grep -i ‘log.retention.[hms].*\=’ config/server.properties log.retention.hours=168. …
  2. 3.2. Retention Period for New Topic.

Why Kafka is better than RabbitMQ?

Kafka offers much higher performance than message brokers like RabbitMQ. It uses sequential disk I/O to boost performance, making it a suitable option for implementing queues. It can achieve high throughput (millions of messages per second) with limited resources, a necessity for big data use cases.

Does Kafka need zookeeper?

Yes, Zookeeper is must by design for Kafka. Because Zookeeper has the responsibility a kind of managing Kafka cluster. It has list of all Kafka brokers with it. It notifies Kafka, if any broker goes down, or partition goes down or new broker is up or partition is up.

Article first time published on

How many partitions should a Kafka topic have?

For most implementations you want to follow the rule of thumb of 10 partitions per topic, and 10,000 partitions per Kafka cluster. Going beyond that amount can require additional monitoring and optimization. (You can learn more about Kafka monitoring here.)

Is it possible to delete a Kafka topic?

In the last few versions of Apache’s Kafka, deleting a topic is fairly easy. You just need to set one property in the configuration to ‘true’, and just issue a command to delete a topic. It’ll be deleted in no time.

Why Kafka is so fast?

Compression & Batching of Data: Kafka batches the data into chunks which helps in reducing the network calls and converting most of the random writes to sequential ones. It’s more efficient to compress a batch of data as compared to compressing individual messages.

How do I view Kafka logs?

If you open script kafka-server-start or /usr/bin/zookeeper-server-start , you will see at the bottom that it calls kafka-run-class script. And you will see there that it uses LOG_DIR as the folder for the logs of the service (not to be confused with kafka topics data).

What is leader epoch in Kafka?

In Kafka, a leader epoch refers to the number of leaders previously assigned by the controller. Every time a leader fails, the controller selects the new leader, increments the current “leader epoch” by 1, and shares the leader epoch with all replicas.

How do you start the zookeeper in Kafka?

  1. Download ZooKeeper from here.
  2. Unzip the file. …
  3. The zoo. …
  4. The default listen port is 2181. …
  5. The default data directory is /tmp/data. …
  6. Go to the bin directory.
  7. Start ZooKeeper by executing the command ./zkServer.sh start .
  8. Stop ZooKeeper by stopping the command ./zkServer.sh stop .

Can we have zookeeper and broker in same system?

We have been running zookeeper and kafka broker on the same node in production environment for years without any problems. The cluster is running at very very high qps and IO traffics, so I dare say that our experience suits most scenarios. The advantage is quite simple, which is saving machines.

How do you read a Kafka topic from the beginning?

If you want to process a topic from its beginning, you can simple start a new consumer group (i.e., choose an unused group.id ) and set auto. offset. reset = earliest . Because there are no committed offsets for a new group, auto offset reset will trigger and the topic will be consumed from its beginning.

How do I flush a message from Kafka topic?

To purge the Kafka topic, you need to change the retention time of that topic. The default retention time is 168 hours, i.e. 7 days. So, you have to change the retention time to 1 second, after which the messages from the topic will be deleted.

What is the max message size in Kafka?

Out of the box, the Kafka brokers can handle messages up to 1MB (in practice, a little bit less than 1MB) with the default configuration settings, though Kafka is optimized for small messages of about 1K in size.

What is offset in Kafka?

OFFSET IN KAFKA. The offset is a unique id assigned to the partitions, which contains messages. … In other words, it is a position within a partition for the next message to be sent to a consumer. A simple integer number which is actually used by Kafka to maintain the current position of a consumer.

Is RabbitMQ a FIFO?

Queues in RabbitMQ are FIFO (“first in, first out”). Some queue features, namely priorities and requeueing by consumers, can affect the ordering as observed by consumers.

How does RabbitMQ work?

In actual case, working of RabbitMQ is that producer sends message to “EXCHANGE” and exchange pushes it to multiple queues and workers get message from queues to which it has binded with. Now instead of publishing directly to queue, producer now publish messages to exchange.

Why Kafka is pull based?

Since Kafka is pull-based, it implements aggressive batching of data. Kafka like many pull based systems implements a long poll (SQS, Kafka both do). A long poll keeps a connection open after a request for a period and waits for a response.

What is min insync replicas?

min. insync. replicas is a config on the broker that denotes the minimum number of in-sync replicas required to exist for a broker to allow acks=all requests. That is, all requests with acks=all won’t be processed and receive an error response if the number of in-sync replicas is below the configured minimum amount.

Are Kafka topics persistent?

As we described, Kafka stores a persistent log which can be re-read and kept indefinitely. Kafka is built as a modern distributed system: it’s runs as a cluster, can expand or contract elastically, and replicates data internally for fault-tolerance and high-availability.

How do I get rid of Kafka lag?

  1. Monitor how much lag is getting reduced in unit time (per minute, let’s assume) by each consumer. …
  2. If the rate of lag reduction is still too low, and you’d like to increase it, then add appropriate number of consumers. …
  3. Make sure all your consumers are in the same consumer group.

What is KRaft in Kafka?

Apache Kafka Raft (KRaft) is the consensus protocol that was introduced to remove Apache Kafka’s dependency on ZooKeeper for metadata management.

What is Apache ZooKeeper?

ZooKeeper is an open source Apache project that provides a centralized service for providing configuration information, naming, synchronization and group services over large clusters in distributed systems. The goal is to make these systems easier to manage with improved, more reliable propagation of changes.

Do you need Java for Kafka?

Step 2: Start the Kafka environment NOTE: Your local environment must have Java 8+ installed. Once all services have successfully launched, you will have a basic Kafka environment running and ready to use.

How do you consume multiple topics in Kafka?

In order to consume messages from kafka topic, you need to create a kafka consumer, and subscribe it into the topic. Every kafka consumer is grouped by consumer group name. It allows you to consume the whole topic using multiple physical instances of the application, and process distinct messages on each instance.