Connect to the Kafka instance


Note: The following steps require use of commands in a terminal. These commands will work in macOS and Linux. Windows users can use Windows Subsystem for Linux (WSL) to obtain a Linux-compatible environment on their system.


You’ll be using kcat, a command-line tool, to connect to your Kafka instance. The kcat command-line interface (CLI) allows you to produce or consume messages, and list metadata for the Kafka cluster without having to write custom code. Download and install kcat using the appropriate option for your system, following the kcat installation guide.

To connect to your Kafka instance using kcat, you will need a client ID, client secret, and bootstrap server URL. You already have the client ID and secret. Obtain the bootstrap server URL as follows:

  1. Navigate to the Kafka Instances page.
  2. Click on the Options icon (three dots) on the right-hand side of your listed Kafka instance, and select Connection.
  3. Copy the Bootstrap Server URL field (Figure 13).
    Figure 13: The bootstrap server URL is available on the Connection details panel Kafka Instances screen.
  4. Store the bootstrap URL in the same location as your client ID and client secret.
  5. Run the following kcat command to list metadata for your Kafka instance. Replace the variables with the correct values. For instance, $BOOTSTRAP_URL should be replaced with the bootstrap server URL you copied from the dashboard:
$ kcat -b $BOOTSTRAP_SERVER -X security.protocol=SASL_SSL -X 
sasl.mechanisms=PLAIN -X sasl.username="$CLIENT_ID" -X 
sasl.password="$CLIENT_SECRET" -L

If you see text output similar to the following sample, you’ve successfully completed this learning path:

Metadata for all topics (from broker -1: sasl_ssl://
 3 brokers:
  broker 0 at
  broker 2 at
  broker 1 at (controller)
 0 topics: