# Conditionals with multiple strings

**URL:** <https://discuss.elastic.co/t/conditionals-with-multiple-strings/78726>\
**Category:** Logstash\
**Created:** [March 15, 2017, 2:52pm UTC](https://discuss.elastic.co/t/conditionals-with-multiple-strings/78726 "2017-03-15T14:52:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jcannell](https://avatars.discourse-cdn.com/v4/letter/j/aca169/32.png) [@jcannell](https://discuss.elastic.co/u/jcannell)\
**Post date:** [March 15, 2017, 2:52pm UTC](https://discuss.elastic.co/t/conditionals-with-multiple-strings/78726/1 "2017-03-15T14:52:43Z")

</div>

Hello,

I'm trying to drop an event should there be either "Device Product" or "Device Vendor" in the [message] field.

This works fine:

```
 if ("Device Vendor" in [message] or "Device Product" in [message]) {
        drop { }
    }

```

However, this does not (causes logstash to crash when launched):

```
 if (["Device Vendor", "Device Product"] in [message]) {
        drop { }
    }

```

My questions:

1. How can I easily support lists of strings I don't want in a field without and'ing or or'ing excessively?
2. How can I format my config files on this forum so they're easily readable (sorry, new here and I can't seem to figure it out)?

Thank you.

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [March 15, 2017, 3:03pm UTC](https://discuss.elastic.co/t/conditionals-with-multiple-strings/78726/2 "2017-03-15T15:03:58Z")

</div>

> How can I easily support lists of strings I don't want in a field without and'ing or or'ing excessively?

I don't believe that's possible.

> How can I format my config files on this forum so they're easily readable (sorry, new here and I can't seem to figure it out)?

The toolbar contains a `</>` button for marking text as preformatted. Use it for configuration files and log snippets. If you're familiar with Markdown that's what's used here.

---

<div class="post-metadata">

**Author:** ![jcannell](https://avatars.discourse-cdn.com/v4/letter/j/aca169/32.png) [@jcannell](https://discuss.elastic.co/u/jcannell)\
**Post date:** [March 15, 2017, 4:40pm UTC](https://discuss.elastic.co/t/conditionals-with-multiple-strings/78726/3 "2017-03-15T16:40:50Z")

</div>

Interesting.

I saw this example on [https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html](https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html)

```
if [foo] in ["hello", "world", "foo"] {
    mutate { add_tag => "field in list" }
  }

```

I figured the inverse would be true (values in field instead of field in values), but I suppose it isn't.

---

<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:** [April 12, 2017, 4:41pm UTC](https://discuss.elastic.co/t/conditionals-with-multiple-strings/78726/4 "2017-04-12T16:41:08Z")

</div>

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