如何在Logstash配置中动态添加更多Kafka主题



是否有任何选项可以添加到logstash kafka输入多个kafka主题?我正在寻找动态解决方案,因为我的主题数量正在发生变化。

我的logstash配置看起来像:

input {
kafka {
bootstrap_servers => "localhost:9092"
topics => ["company0","company1","company2","company3","company4"]
}
} 
output {
elasticsearch {
hosts => ["localhost:9200"]
index => "indextry"
workers => 1
}
}

在这个解决方案中,我使用了5个卡夫卡主题,但在另一种情况下,我想使用20个主题。

有什么动态解决方案可以在这里添加卡夫卡主题吗?

Logstash kafka输入支持使用topics_pattern配置。
kafka {
bootstrap_servers => "localhost:9092"
topics_pattern => ["company.*"]
}

此配置将使用以"company"开头的每个主题。

最新更新