简体   繁体   English

Elasticsearch接收器仅使用kafka-connect-elasticsearch +时间戳SMT仅获得新消息,而不接收前一条消息

[英]Elasticsearch sink only get new messages and not the previous one using kafka-connect-elasticsearch + timestamp SMT

I'm using the kafka-connect-elasticsearch plugin to get message from my kafka to Elasticsearch. 我正在使用kafka-connect-elasticsearch插件将消息从我的kafka发送到Elasticsearch。 My data in kafka contain a date field (timestamp format). 我在kafka中的数据包含一个日期字段(时间戳格式)。

My first issue was that when I use this plugin, Elasticsearch index didn't recognize the date field as a date type but as a long ... I kind of solve this using an SMT transformation in my connector configuration. 我的第一个问题是,当我使用此插件时,Elasticsearch索引无法将日期字段识别为日期类型,但将其识别为很长的时间...我有点在连接器配置中使用SMT转换来解决此问题。

Here is my current configuration that allow me to push data in Elastic : 这是我当前的配置,允许我在Elastic中推送数据:

{
  "name": "elasticsearch-sink-test",
  "config": {
    "connector.class": "io.confluent.connect.elasticsearch.ElasticsearchSinkConnector",
    "tasks.max": "1",
    "topics": "test.test",
    "key.ignore": "true",
    "connection.url": "http://localhost:9200",
    "type.name": "kafka-connect",
    "name": "elasticsearch-sink-test",
    "Batch.size": 100,
    "max.buffered.records": 1000,
    "Max.retries": 10,
    "Retry.backoff.ms": 1000,
    "flush.timeout.ms": 20000,
    "max.in.flight.requests": 3
    "transforms": "date",
    "transforms.date.type": "org.apache.kafka.connect.transforms.TimestampConverter$Value",
    "transforms.date.target.type": "Date",
    "transforms.date.field": "date",
    "transforms.date.format": "yyyy-MM-dd HH:mm:ss"
  }
}

My issue right now is that : Elasticsearch doesn't get all the previous messages stored in kafka but only the new one (all the new message that get push to kafka after I started the Elasticsearch connector). 我现在的问题是:Elasticsearch不会获取存储在kafka中的所有先前消息,而只会获取新的消息(在我启动Elasticsearch连接器后,所有推送到kafka的新消息)。

How can I configure the connector to make elastic get all the messages ? 如何配置连接器以使Elastic获得所有消息? Is there any workaround the make elastic "understand" that the date field is a timestamp ? 是否有任何变通办法可以使“弹性”理解日期字段为时间戳?

(For information, my data origin are a MongoDB with the debezium CDC connector) (有关信息,我的数据来源是带有debezium CDC连接器的MongoDB)

Thank you in advance 先感谢您

How can I configure the connector to make elastic get all the messages? 如何配置连接器以使Elastic获得所有消息?

Just like a regular Kafka consumer, you need to set the offsets to the earliest 就像普通的卡夫卡消费者一样,您需要将偏移量设置为最早

consumer.auto.offset.reset=earliest 

Is there any workaround the make elastic "understand" that the date field is a timestamp ? 是否有任何变通办法可以使“弹性”理解日期字段为时间戳?

Yes, using index or dynamic mappings in Elasticsearch. 是的,在Elasticsearch中使用索引或动态映射。 By default, all ingested numbers are only numeric values. 默认情况下,所有摄取的数字都是数字值。 Only properly formatted date strings actually become indexed as dates. 实际上,只有格式正确的日期字符串才会被索引为日期。 If you don't control the Elasticsearch server, or the index settings, this is usually something setup by the admin of that system 如果您不控制Elasticsearch服务器或索引设置,则通常由该系统的管理员进行设置

暂无
暂无

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

相关问题 kafka-connect-elasticsearch:将消息存储为预定义索引的格式 - kafka-connect-elasticsearch: storing messages as format of predefined index kafka-connect-elasticsearch:如何将 elasticsearch 与消费者组同步? - kafka-connect-elasticsearch: How to sync elasticsearch with consumer group? kafka-connect-elasticsearch:如何发送文件删除? - kafka-connect-elasticsearch: how to send deletes of documents? kafka-connect-elasticsearch:当使用“write.method”作为 upsert 时,是否可以在 kafka 主题上使用相同的 AVRO object 来发送部分文档? - kafka-connect-elasticsearch: When using “write.method” as upsert, is it possible to use same AVRO object on kafka topic to send partial document? kafka-connect-elasticsearch 如何将多个主题路由到同一连接器中的同一 elasticsearch 索引? - kafka-connect-elasticsearch How to route multiple topics to same elasticsearch index in same connector? kafka-connect-elasticsearch:如何根据 Kafka 主题的 header 中的某个值删除文档 - kafka-connect-elasticsearch: How to delete document based on certain value in header of the Kafka topic 自定义Kafka Connect-ElasticSearch接收器连接器 - Customize Kafka Connect - ElasticSearch Sink Connector Kafka Connect Elasticsearch 带有自定义路由的接收器连接器 - Kafka Connect Elasticsearch Sink Connector with custom _routing Kafka Connect Elasticsearch sink 没有索引文档 - Kafka Connect Elasticsearch sink no documents are indexed 如何激活和配置ElasticSearch Kafka Connect接收器? - How to activate and configure ElasticSearch Kafka Connect sink?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM