# Sync mongodb and elastic using logstash

**URL:** <https://discuss.elastic.co/t/sync-mongodb-and-elastic-using-logstash/234075>\
**Category:** Logstash\
**Created:** [May 25, 2020, 1:40am UTC](https://discuss.elastic.co/t/sync-mongodb-and-elastic-using-logstash/234075 "2020-05-25T01:40:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![farshid](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/farshid/32/68979_2.png) [@farshid](https://discuss.elastic.co/u/farshid)\
**Post date:** [May 25, 2020, 1:40am UTC](https://discuss.elastic.co/t/sync-mongodb-and-elastic-using-logstash/234075/1 "2020-05-25T01:40:52Z")

</div>

I have same problem with logstash issue [Sync mongodb data to elasticsearch(update if exists or insert) using logstash](https://discuss.elastic.co/t/sync-mongodb-data-to-elasticsearch-update-if-exists-or-insert-using-logstash/206897/2)

[https://discuss.elastic.co/t/sync-mongodb-data-to-elasticsearch-update-if-exists-or-insert-using-logstash/206897/2](https://discuss.elastic.co/t/sync-mongodb-data-to-elasticsearch-update-if-exists-or-insert-using-logstash/206897/2)

if someone solved this probelm help me  
thank you

I just want to sync the data from mongodb to elastic using logstash. Its working good, when any new record comes in mongodb, logstash pushes into elastic. But when I update any record in mongodb then it does not change into elasticsearch. I want to make changes in the config file so that when any record updates in mongo it should reflect in elastic as well.

I have already tried by making action =\> "index" as well as action =\>"update" in .conf file.

input{  
mongodb{  
uri =\> 'mongodb://localhost:27017/DBname'

placeholder\_db\_dir =\> '/opt/logstash'  
placeholder\_db\_name =\> 'logstash\_sqlite.db'  
collection =\> "collectionName"  
batch\_size =\> 500  
}  
}

filter {  
mutate {  
remove\_field =\> ["\_id"]  
}  
}

output{  
elasticsearch{  
action =\> "index"  
hosts =\> ["localhost:9200"]  
index =\> "mongo\_hi\_log\_data"  
}  
stdout{ codec =\> rubydebug }  
}

---

<div class="post-metadata">

**Author:** ![ptamba](https://avatars.discourse-cdn.com/v4/letter/p/7feea3/32.png) [@ptamba](https://discuss.elastic.co/u/ptamba)\
**Post date:** [May 25, 2020, 5:38am UTC](https://discuss.elastic.co/t/sync-mongodb-and-elastic-using-logstash/234075/2 "2020-05-25T05:38:43Z")

</div>

This was designed for parsing logs that were written into mongodb. This means that it may not re-parse db entries that were changed and already parsed.

based on [this](https://github.com/phutchins/logstash-input-mongodb/blob/master/README.md)

are you using that plugins? because i don’t see mongodb plugins in official [elastic documentation](https://www.elastic.co/guide/en/logstash/current/input-plugins.html)

---

<div class="post-metadata">

**Author:** ![farshid](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/farshid/32/68979_2.png) [@farshid](https://discuss.elastic.co/u/farshid)\
**Post date:** [May 25, 2020, 9:17am UTC](https://discuss.elastic.co/t/sync-mongodb-and-elastic-using-logstash/234075/3 "2020-05-25T09:17:33Z")

</div>

I'm using these plugins :

RUN logstash-plugin install logstash-output-elasticsearch  
RUN logstash-plugin install logstash-input-mongodb

and installed successfully.

I have seen update actions in logstash docs

---

<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:** [June 22, 2020, 9:27am UTC](https://discuss.elastic.co/t/sync-mongodb-and-elastic-using-logstash/234075/4 "2020-06-22T09:27:38Z")

</div>

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