Wildcard with alter config command

Is it possible to use a wildcard when adding a config?
So I am trying to increase the retention time for multiple topics. Topics are like abc-1 to abc-99.
I tried to use abc-1* but it throws an error.

Is there anyway to update multiple topics at once?

hi @robbyd

I think the best way to achieve might be a small shell script
something like

for a in $(kafka-topics --bootstrap-server localhost:9092 --list | grep '^a')
do 
#debug echo $a
kafka-configs --bootstrap-server localhost:9092 --alter  --entity-name $a --entity-type topics --add-config retention.ms=5000
done

output shoud be something like

Completed updating config for topic a1.
Completed updating config for topic a2.
Completed updating config for topic a3.

hth,
michael

Great. Thank you. That works.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.