# Can Logstash run update operation in MongoDb

**URL:** <https://discuss.elastic.co/t/can-logstash-run-update-operation-in-mongodb/130467>\
**Category:** Logstash\
**Created:** [May 3, 2018, 2:03pm UTC](https://discuss.elastic.co/t/can-logstash-run-update-operation-in-mongodb/130467 "2018-05-03T14:03:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hederson](https://avatars.discourse-cdn.com/v4/letter/h/76d3ee/32.png) [@Hederson](https://discuss.elastic.co/u/Hederson)\
**Post date:** [May 3, 2018, 2:03pm UTC](https://discuss.elastic.co/t/can-logstash-run-update-operation-in-mongodb/130467/1 "2018-05-03T14:03:47Z")

</div>

I am using Logstash 6.2.4 for replicate data from a MS Sql Server table to a collection MongoDB. Since the records are inserted in the source table, they can be updated with new information. I need to update these new information in the existing records in MongoDB. Does anyone know if it's possible to update a record in MongoDB using Logstash? How can I do it?

Thanks.

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [May 3, 2018, 5:19pm UTC](https://discuss.elastic.co/t/can-logstash-run-update-operation-in-mongodb/130467/2 "2018-05-03T17:19:17Z")

</div>

The mongodb output plugin?

---

<div class="post-metadata">

**Author:** ![Hederson](https://avatars.discourse-cdn.com/v4/letter/h/76d3ee/32.png) [@Hederson](https://discuss.elastic.co/u/Hederson)\
**Post date:** [May 3, 2018, 5:50pm UTC](https://discuss.elastic.co/t/can-logstash-run-update-operation-in-mongodb/130467/3 "2018-05-03T17:50:16Z")

</div>

Hi Magnus!  
Yes, I am using the mongodb output plugin. My pipeline code is look like this:

```
input {
 jdbc {
    jdbc_driver_library => "/usr/local/java/jdk1.8.0_171/lib/sqljdbc42.jar"
    jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
    jdbc_connection_string => "jdbc:sqlserver://xxx.xxx.xx.xx:1433;databaseName=xxxx"
    jdbc_user => "xxxxxx"
    jdbc_password => "xxxxx"
    statement => "select * from table where data >= getdate()-10"
    #schedule => "* 1 * * *" # todo dia a 1h. "min hor dia mes fuso"
    #clean_run => true
    #record_last_run => true
    #use_column_value => false #para o sql_last_value fucionar para data
    #tracking_column => "data"
  }
}
# The filter part of this file is commented out to indicate that it is
# optional.
# filter {
#
# }
output {
  mongodb {
    uri => "mongodb://xxx.xx.x.xx:27017,xxx.xx.x.xx:27017,xxx.xx.x.xx:27017/"
    database => "databaseName"
    collection => "collectionName"
    #_id => "%{id}"

  }

}

```

I will run this pipeline every day. Then, I need to update the records that are saved in MongoDB because the source records have new values in some attributes.

---

<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:** [May 31, 2018, 5:50pm UTC](https://discuss.elastic.co/t/can-logstash-run-update-operation-in-mongodb/130467/4 "2018-05-31T17:50:16Z")

</div>

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