# Extract from ElasticSearch, into Kafka, continuously add any new ES updates using logstash

**URL:** <https://discuss.elastic.co/t/extract-from-elasticsearch-into-kafka-continuously-add-any-new-es-updates-using-logstash/328172>\
**Category:** Logstash\
**Created:** [March 21, 2023, 2:21pm UTC](https://discuss.elastic.co/t/extract-from-elasticsearch-into-kafka-continuously-add-any-new-es-updates-using-logstash/328172 "2023-03-21T14:21:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aniketdatir](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@aniketdatir](https://discuss.elastic.co/u/aniketdatir)\
**Post date:** [March 21, 2023, 2:21pm UTC](https://discuss.elastic.co/t/extract-from-elasticsearch-into-kafka-continuously-add-any-new-es-updates-using-logstash/328172/1 "2023-03-21T14:21:20Z")

</div>

Hi Team,

My objective is to add latest ES index documents to kafka  
Below is my logstash conf -\>  
'''  
input {  
elasticsearch {  
hosts =\> ["IP"]  
index =\> "Index\_name"  
query =\> '{"query":{"range":{"@timestamp":{"gte": "now-5m"}}}}'  
}  
}

output {  
kafka {  
codec =\> json  
topic\_id =\> "topic\_name"  
bootstrap\_servers =\> "IP"  
}  
}  
'''  
it works. But everytime I run it added all the documents to kafka.  
It should add only latest updates from index but not all.

Do i need to add date filter, or change the query part? Kindly assist how to do this?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 18, 2023, 2:21pm UTC](https://discuss.elastic.co/t/extract-from-elasticsearch-into-kafka-continuously-add-any-new-es-updates-using-logstash/328172/2 "2023-04-18T14:21:24Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
