# Use filter in output

**URL:** <https://discuss.elastic.co/t/use-filter-in-output/204444>\
**Category:** Logstash\
**Created:** [October 21, 2019, 10:43am UTC](https://discuss.elastic.co/t/use-filter-in-output/204444 "2019-10-21T10:43:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![NicolasJ](https://avatars.discourse-cdn.com/v4/letter/n/aca169/32.png) [@NicolasJ](https://discuss.elastic.co/u/NicolasJ)\
**Post date:** [October 21, 2019, 10:43am UTC](https://discuss.elastic.co/t/use-filter-in-output/204444/1 "2019-10-21T10:43:06Z")

</div>

Hi all,

I wonder if it is possible to use filter value in output.  
For example, my output is formatted like this :

output {  
mongodb {  
id =\> "mongodb\_plugin\_id"  
collection =\> ""  
database =\> "my\_mogodb\_database"  
uri =\> "mongodb://username:password@localhost:27017/my\_mogodb\_database"  
codec =\> "json"  
}  
}

And I would like to set dynamically depending on a pattern extract in the filter.

hope to be clear enough and as I am new in logstash I am a little bit confused.

Best regards

---

<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:** [October 21, 2019, 12:00pm UTC](https://discuss.elastic.co/t/use-filter-in-output/204444/2 "2019-10-21T12:00:13Z")

</div>

You can sometimes reference fields from an event in the configuration of an output using a [sprintf](https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html#sprintf) reference. Does that help?

---

<div class="post-metadata">

**Author:** ![NicolasJ](https://avatars.discourse-cdn.com/v4/letter/n/aca169/32.png) [@NicolasJ](https://discuss.elastic.co/u/NicolasJ)\
**Post date:** [October 21, 2019, 1:09pm UTC](https://discuss.elastic.co/t/use-filter-in-output/204444/3 "2019-10-21T13:09:54Z")

</div>

Thanks for your reply @Badger, I think that I have to read more on documentation. I still do not know how to use what you mentioned.

---

<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 18, 2019, 1:09pm UTC](https://discuss.elastic.co/t/use-filter-in-output/204444/4 "2019-11-18T13:09:58Z")

</div>

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