# Mongo Output document deletion

**URL:** <https://discuss.elastic.co/t/mongo-output-document-deletion/249693>\
**Category:** Logstash\
**Created:** [September 23, 2020, 6:25pm UTC](https://discuss.elastic.co/t/mongo-output-document-deletion/249693 "2020-09-23T18:25:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![arichiardi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arichiardi/32/76109_2.png) [@arichiardi](https://discuss.elastic.co/u/arichiardi)\
**Post date:** [September 23, 2020, 6:25pm UTC](https://discuss.elastic.co/t/mongo-output-document-deletion/249693/1 "2020-09-23T18:25:50Z")

</div>

Hi there,

I am learning how to use the [MongoDB output pluing](https://www.elastic.co/guide/en/logstash/current/plugins-outputs-mongodb.html#plugins-outputs-mongodb-common-options) and trying to understand how to delete a document in a collection.

I was wondering if this is supported.

The alternative I can think of is to have a `tombstone` flag that tells Mongo that the document is deleted plus subsequent garbage collection.

Thank you all in advance for any answer!

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [September 23, 2020, 6:36pm UTC](https://discuss.elastic.co/t/mongo-output-document-deletion/249693/2 "2020-09-23T18:36:00Z")

</div>

The [code](https://github.com/logstash-plugins/logstash-output-mongodb/blob/c38344c7b25e665be9bcffbb76598db5e8d2a69f/lib/logstash/outputs/mongodb.rb#L106) always calls either insert\_one or insert\_many. I do not see a way to do a deletion.

---

<div class="post-metadata">

**Author:** ![arichiardi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arichiardi/32/76109_2.png) [@arichiardi](https://discuss.elastic.co/u/arichiardi)\
**Post date:** [October 9, 2020, 6:08pm UTC](https://discuss.elastic.co/t/mongo-output-document-deletion/249693/3 "2020-10-09T18:08:42Z")

</div>

There is a PR in `logstash-output-mongo` and I am working on one myself.

Had to learn ruby 😃 But this is definitely possible!

---

<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:** [November 6, 2020, 6:08pm UTC](https://discuss.elastic.co/t/mongo-output-document-deletion/249693/4 "2020-11-06T18:08:48Z")

</div>

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