# Multiple vs one filter for different inputs

**URL:** <https://discuss.elastic.co/t/multiple-vs-one-filter-for-different-inputs/264696>\
**Category:** Logstash\
**Created:** [February 18, 2021, 11:27am UTC](https://discuss.elastic.co/t/multiple-vs-one-filter-for-different-inputs/264696 "2021-02-18T11:27:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sastorsl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sastorsl/32/44972_2.png) [@sastorsl](https://discuss.elastic.co/u/sastorsl)\
**Post date:** [February 18, 2021, 11:27am UTC](https://discuss.elastic.co/t/multiple-vs-one-filter-for-different-inputs/264696/1 "2021-02-18T11:27:47Z")

</div>

In logstash we have multiple _sources_ of input data - so we use conditionals on a document field (`doc_type`) to apply the various filters.

Is there any real difference or benefit between having **one** filter with conditionals inside vs having **multiple** filters where each filter starts with the conditional?

**One filter**

```
filter {
    if [doc_type] == 'type1' {
        grok { ...}
        }
    if [doc_type] == 'type2' {
        grok { ...}
        }
}

```

**Multiple filters**

```
filter {
    if [doc_type] == 'type1' {
        grok { ...}
        }
}
filter {
    if [doc_type] == 'type2' {
        grok { ...}
        }
}
```

---

<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:** [February 18, 2021, 5:27pm UTC](https://discuss.elastic.co/t/multiple-vs-one-filter-for-different-inputs/264696/2 "2021-02-18T17:27:17Z")

</div>

> [@sastorsl](#):
>
> Is there any real difference or benefit between having **one** filter with conditionals inside vs having **multiple** filters where each filter starts with the conditional?

Not that I can think of. I believe they will be compiled down into the same code.

---

<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:** [March 18, 2021, 5:27pm UTC](https://discuss.elastic.co/t/multiple-vs-one-filter-for-different-inputs/264696/3 "2021-03-18T17:27:59Z")

</div>

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