...
- Download the latest Kafka release and extract it - https://kafka.apache.org/quickstart
- Navigate to the bin directory kafka_2.12-2.7.0/bin/ - we will be using kafka-topics.sh and kafka-configs.sh scripts out of the box
- Get list of topics and write to file topics.txt. For example, we want all topics for tenant tenant001
Code Block language bash theme Midnight ./kafka-topics.sh --describe --zookeeper <zookeeper-plaintext-connection-url> --topic "imtc.Default.tenant001.*" | grep Configs | awk '{printf "%s\n", $2}' > topics.txt
2 2. For all topics in the topics.txt file from step 1, alter the topic by adding custom config to set retention time to 1 second or less
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
!/bin/bash -x awk '{ system("./kafka-configs.sh --alter --bootstrap-server <bootstrap-plaintext-connection-url> --entity-type topics --entity-name="$1" --add-config retention.ms=" 1000) }' topics.txt |
...
3. Revert all topics by deleting the custom
...
config from step 2
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
#!/bin/bash -e
awk '{ system("./kafka-configs.sh --bootstrap-server <bootstrap-plaintext-connection-url> --entity-type topics --entity-name="$1" --alter --delete-config retention.ms") }' topics.txt |