# MongoDB input plug-in for logstash

**URL:** <https://discuss.elastic.co/t/mongodb-input-plug-in-for-logstash/374345>\
**Category:** Logstash\
**Tags:** async-search\
**Created:** [February 11, 2025, 6:08am UTC](https://discuss.elastic.co/t/mongodb-input-plug-in-for-logstash/374345 "2025-02-11T06:08:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anand\_Konagala](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anand_konagala/32/120215_2.png) [@Anand\_Konagala](https://discuss.elastic.co/u/Anand_Konagala)\
**Post date:** [February 11, 2025, 6:08am UTC](https://discuss.elastic.co/t/mongodb-input-plug-in-for-logstash/374345/1 "2025-02-11T06:08:05Z")

</div>

Hi Team,

I am using **Logstash (v8.17.1)** to sync data from MongoDB to Elasticsearch. The **document creation works fine** , but I am facing issues with syncing **only updated documents** from MongoDB.

I tried filtering documents using,

```auto
filter=> { "last_updated": { "$gte": { "$date": "{{placeholder}}" } } }

```

but Logstash throws an error:

```auto
[ERROR][logstash.inputs.mongodb] Unknown setting 'filter' for mongodb

```

Tried using a MongoDB aggregation pipeline:

```auto
input {
  mongodb {
    uri => "mongodb://localhost:27017/Resumes"
    collection => "CoarthaTechnoSolutions"
    placeholder_db_dir => "/home/anand/logstash-mongo/"
    placeholder_db_name => "logstash_sqlite.db"
    pipeline => '[{ "$match": { "last_updated": { "$gte": { "$date": "{{placeholder}}" } } } }]'
  }
}

```

Suggest me a best way,

### **My Questions:**

1. **What is the recommended way to fetch only recently updated documents from MongoDB in Logstash?**
2. **Is `pipeline` officially supported in MongoDB input plugin?**
3. **Would Change Streams be a better approach?** If yes, how can I integrate them with Logstash?

Thanks
