export bootstrap_server_str="..."
export client_config="/opt/kafka/kafka_2.13-${kafka_version}/config/client-config.properties"
# get all topics
kafka-topics.sh --list \
--bootstrap-server ${bootstrap_server_str} \
--command-config ${client_config} > topics.txt
# manually extract topics to delete to a file to_delete.txt
# delete
xargs -d '\n' -I {} bash -c \
"echo 'deleting {} ...'; kafka-topics.sh --bootstrap-server ${bootstrap_server_str} --command-config ${client_config} --delete --topic {}" \
< to_delete.txt
# verify
# re-run kafka-topics.sh --list
Monitor
On terminal each topics is printed before deleting
CloudWatch
Kafdrop