# Logstash and logical or

**URL:** <https://discuss.elastic.co/t/logstash-and-logical-or/291582>\
**Category:** Logstash\
**Created:** [December 13, 2021, 4:29am UTC](https://discuss.elastic.co/t/logstash-and-logical-or/291582 "2021-12-13T04:29:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![KaPBaJIOJI](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kapbajioji/32/79243_2.png) [@KaPBaJIOJI](https://discuss.elastic.co/u/KaPBaJIOJI)\
**Post date:** [December 13, 2021, 4:29am UTC](https://discuss.elastic.co/t/logstash-and-logical-or/291582/1 "2021-12-13T04:29:14Z")

</div>

Hello everyone  
I try to started config logstash  
**Work config**

```auto
filter {
    # grok log lines by program name (listed alpabetically)
    if [program] =~ /^postfix.*\/anvil$/ {
        grok {
            patterns_dir => "/etc/logstash/patterns.d"
            match => ["message", "^%{POSTFIX_ANVIL}$"]
            tag_on_failure => ["_grok_postfix_anvil_nomatch"]
            add_tag => ["_grok_postfix_success"]
        }
    }

```

I can just add a block with postfix-new, but I don't want to complicate the config  
i need add i_f [program] =~ /^postfix._/anvil$/ or /^postfix-new._/anvil$/_  
how can I get both values to be filtered. Tried adding quotes brackets but logstash won't start.  
Thanks for help

---

<div class="post-metadata">

**Author:** ![KaPBaJIOJI](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kapbajioji/32/79243_2.png) [@KaPBaJIOJI](https://discuss.elastic.co/u/KaPBaJIOJI)\
**Post date:** [December 13, 2021, 4:33am UTC](https://discuss.elastic.co/t/logstash-and-logical-or/291582/2 "2021-12-13T04:33:22Z")

</div>

/^postfix\*.\*/anvil$/  
would such a solution filter both queries?

---

<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:** [December 13, 2021, 5:11pm UTC](https://discuss.elastic.co/t/logstash-and-logical-or/291582/3 "2021-12-13T17:11:10Z")

</div>

Yes. A more specific alternative would be to allow zero or more -new in the expression: `/^postfix(-new)?\/anvil$/`

If logstash does not start then tell us what error message it logs.

---

<div class="post-metadata">

**Author:** ![KaPBaJIOJI](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kapbajioji/32/79243_2.png) [@KaPBaJIOJI](https://discuss.elastic.co/u/KaPBaJIOJI)\
**Post date:** [December 16, 2021, 3:43am UTC](https://discuss.elastic.co/t/logstash-and-logical-or/291582/4 "2021-12-16T03:43:29Z")

</div>

Thanks for the answer, added to the config, it works without problems, only I haven't checked it with `(-new)` yet, but I think everything will be fine

---

<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:** [January 13, 2022, 3:44am UTC](https://discuss.elastic.co/t/logstash-and-logical-or/291582/5 "2022-01-13T03:44:11Z")

</div>

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