简体   繁体   English

使用 Kafka-Connect 将消息路由到不同的 ElasticSearchIndex

[英]Route message to different ElasticSearchIndex using Kafka-Connect

I have a kafka topic on which multiple types of messages (all are JSON) are being published to it with header property as :- eventType = "abc" or eventType = "xyz" or eventType = "def" etc.我有一个 kafka 主题,正在向其发布多种类型的消息(都是 JSON),其标头属性为:- eventType = "abc" 或 eventType = "xyz" 或 eventType = "def" 等。

My requirement is to send these messages from Kafka topic to different elasticSearch index based on eventType header field being sent in kafka.我的要求是根据 kafka 中发送的 eventType 标头字段将这些消息从 Kafka 主题发送到不同的 elasticSearch 索引。 eg if eventType = "abc", push data to elasticsearch index = "abc123" if eventType = "xyz", push data to elasticsearch index = "xyz123" eg if eventType = "abc", push data to elasticsearch index = "abc123" if eventType = "xyz", push data to elasticsearch index = "xyz123"

I am planning to use kafka connect for this operation.我计划使用 kafka connect 进行此操作。 I need help how can i achieve this using kafka-connect ?我需要帮助如何使用 kafka-connect 实现这一目标?

I am using kafka 1.1.0 and planning to use confluentinc-kafka-connect-elasticsearch--plugin.我正在使用 kafka 1.1.0 并计划使用 confluentinc-kafka-connect-elasticsearch--plugin。

Here is my elastic search sink connect config file :-这是我的弹性搜索接收器连接配置文件:-

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

based on eventType header field基于 eventType 头域

Use ExtractTopic$Value + RegexRouter to route messages to individual indicies.使用ExtractTopic$Value + RegexRouter将消息路由到单个索引。

Then use topics.regex in the ElasticSearch sink to define patterns for the topics to read from然后在 ElasticSearch 接收器中使用topics.regex来定义要读取的主题的模式

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM