I'm trying to configure Logstash with Kafka output. Basically I want to put data in different Kafka topics based on a field.
So in example below, I have a field name in the data. All documents should be posted to the topic per name.
E.g. if name is test1, topic should be topic_test1, for test2 it should be topic_test2 etc...
output {
kafka {
id => "topic-kafka"
bootstrap_servers => "kafka.test.be:9092"
topic_id => "topic_%{name}"
codec => json
}
}
I tried to use the sprintf format like above, but that doesn't work.
[2022-07-29T11:51:52,502][ERROR][org.apache.kafka.clients.Metadata][topic-kafka] [Producer clientId=producer-1] Metadata response reported invalid topics [topic_%{name}]
I'm using logstash version v7.16.2
Any ideas how we can configure this?
Thanks!