# Help with conditionals in logstash

**URL:** <https://discuss.elastic.co/t/help-with-conditionals-in-logstash/317836>\
**Category:** Logstash\
**Created:** [October 31, 2022, 5:18pm UTC](https://discuss.elastic.co/t/help-with-conditionals-in-logstash/317836 "2022-10-31T17:18:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![RaonyO](https://avatars.discourse-cdn.com/v4/letter/r/5fc32e/32.png) [@RaonyO](https://discuss.elastic.co/u/RaonyO)\
**Post date:** [October 31, 2022, 5:18pm UTC](https://discuss.elastic.co/t/help-with-conditionals-in-logstash/317836/1 "2022-10-31T17:18:44Z")

</div>

hello, I'm trying to perform a filter with some conditions, but when performing as follows, it doesn't work.

```auto
 if "dns_server_process_query_send" or "Not authoritative" in [message] { drop {} }

```

but if I use the following way it works normally:

```auto
 if "dns_server_process_query_send" in [message] { drop {} }
 if "Not authoritative" in [message] { drop {} }

```

why can't I put the two conditions inside the same IF? am i doing something wrong?

---

<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 31, 2022, 5:30pm UTC](https://discuss.elastic.co/t/help-with-conditionals-in-logstash/317836/2 "2022-10-31T17:30:07Z")

</div>

> [@RaonyO](#):
>
> why can't I put the two conditions inside the same IF?

You can. One of your conditions is `"Not authoritative" in [message]`, and the other one is `"dns_server_process_query_send"` (which will always evaluate to true). You have to use

```
if "dns_server_process_query_send" in [message] or "Not authoritative" in [message] { drop {} }

```

---

<div class="post-metadata">

**Author:** ![RaonyO](https://avatars.discourse-cdn.com/v4/letter/r/5fc32e/32.png) [@RaonyO](https://discuss.elastic.co/u/RaonyO)\
**Post date:** [October 31, 2022, 5:31pm UTC](https://discuss.elastic.co/t/help-with-conditionals-in-logstash/317836/3 "2022-10-31T17:31:34Z")

</div>

really, that's the correct way, thank you very much @Badger !

---

<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 28, 2022, 5:31pm UTC](https://discuss.elastic.co/t/help-with-conditionals-in-logstash/317836/4 "2022-11-28T17:31:43Z")

</div>

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