使用Kafka-Connect将消息路由到其他ElasticSearchIndex

时间:2020-03-04 17:32:28

标签: elasticsearch apache-kafka apache-kafka-connect

我有一个kafka主题,在该主题上正在向其发布多种消息(所有消息都是JSON),其标头属性为:-eventType =“ abc”或eventType =“ xyz”或eventType =“ def”等。< / p>

我的要求是根据在kafka中发送的eventType标头字段,将这些消息从Kafka主题发送至不同的ElasticSearch索引。 例如如果eventType =“ abc”,则将数据推送到elasticsearch index =“ abc123” 如果eventType =“ xyz”,则将数据推送到elasticsearch index =“ xyz123”

我计划使用kafka connect进行此操作。我需要帮助,如何使用kafka-connect实现此目标?

我正在使用kafka 1.1.0,并计划使用confluentinc-kafka-connect-elasticsearch--plugin。

这是我的弹性搜索接收器连接配置文件:-

name=elasticsearch-sink
connector.class=io.confluent.connect.elasticsearch.ElasticsearchSinkConnector
tasks.max=1
topics=test-elasticsearch-sink
topic.index.map=test-1:elastic_purchase_index1
key.ignore=true
connection.url=<url>
type.name=purchasev1
key.ignore=true
schema.ignore=true

1 个答案:

答案 0 :(得分:0)

基于eventType标头字段

使用ExtractTopic$Value + RegexRouter将邮件路由到各个索引。

然后在ElasticSearch接收器中使用topics.regex来定义要读取的主题的模式