There will be times when you need your Zookeeper connection string such as using various kafka utilities. This string will be a list of hostnames and ports that the application will use to connect to Zookeeper and gather required data.
It is strongly reccomended you do not modify or reuse the provided Zookeeper servers in any way. The connection provided is for applications to gather data about the cluster. Modifying the contents of Zookeeper directly can cause cluster failure and data loss.
Open the Amazon MSK console at https://console.aws.amazon.com/msk/
Click on the name of the cluster you want the details for
Use the CLI to describe the cluster with the ARN gathered in the previous step - this will output the
cd ~/kafka/bin aws kafka describe-cluster --cluster-arn $CLUSTER_ARN --output json | jq ".ClusterInfo.ZookeeperConnectString" z-3.mskcluster.xyz.c6.kafka.us-east-1.amazonaws.com:2181,z-1.mskcluster.xyz.c6.kafka.us-east-1.amazonaws.com:2181,z-2.mskcluster.xyz.c6.kafka.us-east-1.amazonaws.com:2181"
If you’re working on the command line, and to save yourself some work, put your ZooKeeper connection string into an envrionment variable:
export MYZK=$(aws kafka describe-cluster --cluster-arn $CLUSTER_ARN --output json | jq ".ClusterInfo.ZookeeperConnectString" | tr -d \")
Then you can refer to the variable in later commands:
$ bin/kafka-topcs.sh --zookeeper $MYZK --list