Sync mongodb data to elasticsearch(update if exists or insert) using logstash

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.

Here is my mongodata.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 }
  }

**I want to sync the data from mongodb to elastic using logstash when any record is updated or inserted in mongodb**

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