To see all topics via Zookeeper, use bin/kafka-topics.sh --zookeeper localhost:2181 --list. This reflects the old metadata setup where Zookeeper holds cluster info. If you connect through a broker (bootstrap-server), you’ll get a different view—topic details vs. a simple list—so this method remains distinct.

Multiple Choice

Which command lists all Kafka topics using Zookeeper?

Listing topics through the Kafka topics tool using Zookeeper relies on the older setup where Zookeeper holds the cluster metadata. To simply see all topics, you connect to Zookeeper (with the host and port, such as localhost:2181) and request a list. The command that does this uses the Zookeeper connection and the --list option, which asks Zookeeper for the names of all topics and returns them. Using a bootstrap-server instead connects directly to Kafka brokers and would list topics via the broker metadata, not through Zookeeper, so it doesn’t meet the requirement here. The --describe option would show detailed information about topics rather than a simple list, and --delete would remove topics rather than list them.

Kafka is often described as a distributed, commit-log system that basically powers real-time data streaming. But to really understand how it works under the hood, you’ve got to peek at how topics are stored and discovered. A lot of the history behind Kafka’s topic metadata sits with Zookeeper, the service that once acted as the brain of the cluster. If you’re exploring Kafka from a CCDAK lens or you’re just curious about the mechanics, here’s a practical guide to listing topics via Zookeeper, plus a little context to help you navigate the shift toward broker-based metadata.

A quick walk through the old-school way: why Zookeeper matters for topic discovery

Think of Zookeeper as the centralized ruler of the Kafka kingdom in older setups. It holds the cluster’s metadata, including the list of topics, partitions, and the leaders for each partition. When you run a command that asks Zookeeper to tell you what topics exist, you’re essentially asking: “Hey Zookeeper, what names did you register for me?” The answer is a plain list of topic names, which is often enough for quick checks or for scripts that still operate in legacy configurations.

To see this in practice, you’d use a command that explicitly points to Zookeeper and then asks for a simple listing. It’s straightforward, almost soothing in its simplicity: you provide the Zookeeper host and port (for example, localhost:2181) and request the list. The result is a clean roster of topics that exist in the cluster at that moment.

The exact command and what it does

If you’re looking for the specific syntax that corresponds to listing topics through Zookeeper, here’s the essence:

  • Command: bin/kafka-topics.sh --zookeeper localhost:2181 --list

  • What it does: Connects to Zookeeper, asks for the catalog of topic names, and prints them.

This approach is rooted in the older Kafka architecture where Zookeeper was the source of truth for the cluster’s metadata. It’s a bit like checking a master register at the town hall to see what residents exist. It doesn’t rely on the broker log or the broker’s own view of the world; it goes straight to the metadata store that’s kept centralized by Zookeeper.

Why not use the bootstrap-server option for this purpose?

You might wonder, wait a second — if I want to see topics, why not connect to a broker directly and fetch what’s known there? In practice, using the bootstrap-server endpoint (bin/kafka-topics.sh --bootstrap-server localhost:9092 --list) changes the game. That command queries the brokers for their view of topics, i.e., the broker metadata. It’s a different data source, and it reflects the cluster’s current state from the broker’s perspective rather than the Zookeeper-stored metadata.

That distinction matters in certain scenarios. If you’re in a legacy environment or you’re troubleshooting issues tied to Zookeeper’s state, you’ll want to query Zookeeper directly. If you’re just trying to understand what topics exist from the broker’s vantage point—especially in a modern, Kafka-as-a-service setup or in environments where the metadata has already migrated to the broker—then listing via --bootstrap-server makes more sense.

A gentle nudge toward the present: the move away from Zookeeper

Here’s the thing: newer Kafka versions have been migrating away from Zookeeper as the single source of truth. The goal is to have broker metadata be the one source you query, which simplifies operations and reduces the coupling between the cluster’s components. The shift has been gradual but meaningful. Many installations today run without needing to poke at Zookeeper for daily operations, relying instead on the brokers to report topics, partitions, and configurations via the Kafka Admin API.

That doesn’t mean Zookeeper is utterly dead. It still exists in many clusters, often as part of a legacy setup or during transitional phases. If you come across old scripts or admin tools that hinge on Zookeeper, it’s perfectly natural to keep using them—just know what you’re tapping into and why. It’s a bit of a historical tour, really, like pulling up an old map during a road trip to understand how the roads used to look.

Descriptive vs. list: what you get from the different commands

Let’s say you’re curious about topics, but you’re not just after a name parade. You might be tempted to reach for a more descriptive command that reveals details about each topic. Here’s how the behavior differs, in a friendly, uncomplicated way:

  • --list with Zookeeper: You get a simple list of topic names. It’s fast, it’s clean, and it tells you which topics exist without sprinkling in extra data.

  • --describe with Zookeeper or with bootstrap-server: You’ll see more—like the number of partitions, replication factors, and perhaps the leaders for each partition. It’s useful when you’re trying to understand how a topic is distributed across the cluster, but it’s not the same as a quick inventory.

  • --delete: As you’d expect, this drops a topic. It’s a powerful operation, with real consequences, so most people treat it with care. It’s not a listing feature; it’s a management action.

If your goal is a neat, quick snapshot of “what names exist right now,” the --list option with the Zookeeper flag wins for that particular purpose. It’s a reminder of how the system used to operate and how certain admin tasks still cling to those older patterns in some environments.

A practical mindset for administrators and learners

As you navigate Kafka, keep a few guiding principles in mind. First, know where your cluster’s metadata lives. If you’re in a setup that still uses Zookeeper as the metadata store, you’ll interact with it directly or indirectly to understand the state of the cluster. If you’re in a newer or restructured environment, broker-based metadata might be your default source of truth, accessible via the Admin API or broker endpoints.

Second, remember what you’re hoping to discover. A plain list of topic names is a different kind of knowledge than a detailed description of each topic’s partitions and replication. Decide which you need and choose the command accordingly. It’s a small decision, but it changes what you see and how you interpret it.

Third, keep an eye on maintenance patterns. Zookeeper and Kafka have evolved, and with that evolution comes a natural cadence of updates, migrations, and sometimes deprecation. If you’re curious about best practices, you’ll probably hear a lot about migrating metadata storage away from Zookeeper, reducing operational complexity, and stepping toward a more streamlined, broker-centered management model. Even if you don’t act on it today, understanding the trajectory helps you plan for the future and stay flexible.

A few related topics worth exploring (just a gentle detour)

  • Admin API vs. command-line tools: The Kafka ecosystem isn’t built only on shell commands. The Admin API gives you programmatic control to create, list, describe, and delete topics, among other things. It’s a great way to integrate Kafka management into applications or automation scripts while avoiding some of the quirks of shell-based interactions.

  • Topic naming and organization: In real-world deployments, topics aren’t just random strings. Teams adopt naming conventions to reflect data domains, environments (dev, test, prod), and data producers. A consistent scheme makes discovery easier, especially when you’re juggling dozens or hundreds of topics.

  • Observability and metrics: Beyond listing and describing topics, practitioners track metrics like topic throughput, partition distribution, replication status, and ISR (in-sync replica) health. Observability helps you spot imbalance early and troubleshoot slow paths in your data pipelines.

  • The evolution of Kafka in cloud-native contexts: Managed services and cloud-native deployments often abstract away the lower-level operations. You might not need to run --zookeeper at all in some setups, and you’ll rely on cloud-provided dashboards and APIs to keep tabs on topics and their health. It’s a different flavor, but the core concepts—topics, partitions, replication, and leaders—stay relevant.

A light, memorable analogy

If you’ve ever organized a big group chat, you know how topics function in Kafka. Topics are the rooms where messages live. In older setups, Zookeeper was like the building manager who kept a master list of all rooms and who owns them. You could call the manager and ask, “Hey, what rooms exist?” and you’d get a straightforward list. In newer setups, the doors and rooms register with the buildings themselves—the brokers—so you can ask the building directly, “What rooms do we have?” and get the information without pinging the manager. Both approaches work, but one tends to be simpler when you’re operating in a modern, streamlined environment.

Putting it into practice: a concise recap

  • If you want a plain list of topic names and you’re operating in a setup that still relies on Zookeeper for metadata: bin/kafka-topics.sh --zookeeper localhost:2181 --list.

  • If you’re exploring topics from the broker’s perspective or you’re in a more modern Kafka deployment: bin/kafka-topics.sh --bootstrap-server localhost:9092 --list (and switch to descriptive or management commands as needed).

  • Remember the broader trend: many clusters are gradually shifting away from Zookeeper as the metadata source, which changes how you approach day-to-day management—but the foundational ideas about topics, partitions, and replication remain the heartbeat of Kafka.

A final thought to tuck away

As you grow comfortable with Kafka, you’ll notice how the tooling mirrors the architecture’s evolution. The older Zookeeper-centered commands connect you to a certain era of the system, while broker-based commands reflect today’s leaner, more streamlined operational model. Both perspectives are valuable. They give you a fuller sense of what’s possible, what’s changing, and how to adapt with confidence.

If you’re curious to dig deeper, try contrasting a few real-world scenarios: list topics with and without Zookeeper, compare the outputs, and observe how the presence or absence of Zookeeper metadata affects what you see. It’s a small exercise, but it shines a light on the subtle, often overlooked layers that keep real-time data moving smoothly from producers to consumers. And who knows? You might notice patterns that help you design cleaner, more resilient data pipelines for whatever projects come next.