# Logstash filter for muliple values not working

**URL:** <https://discuss.elastic.co/t/logstash-filter-for-muliple-values-not-working/272087>\
**Category:** Logstash\
**Created:** [May 4, 2021, 4:15pm UTC](https://discuss.elastic.co/t/logstash-filter-for-muliple-values-not-working/272087 "2021-05-04T16:15:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rohitarorait82](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rohitarorait82/32/82981_2.png) [@rohitarorait82](https://discuss.elastic.co/u/rohitarorait82)\
**Post date:** [May 4, 2021, 4:15pm UTC](https://discuss.elastic.co/t/logstash-filter-for-muliple-values-not-working/272087/1 "2021-05-04T16:15:15Z")

</div>

Hi All,

I am trying to remove message for few service tags, but I am facing below issue.

**Below is not working**

```
if [SERVICE] in ["GET", "UPDATE"] {
mutate { remove_field => ["message"] }
}

```

**Below is working**

```
if "GET" not in [SERVICE] and "UPDATE" not in [SERVICE]{
mutate { remove_field => ["message"] }
}

```

Can someone please suggest what is wrong with the one which is not working

---

<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:** [May 4, 2021, 7:37pm UTC](https://discuss.elastic.co/t/logstash-filter-for-muliple-values-not-working/272087/2 "2021-05-04T19:37:45Z")

</div>

The first is an array membership test. It is equivalent to

```
if [SERVICE] == "GET" or [SERVICE] == "UPDATE" { ...

```

The second does substring matches. If "GET" appears anywhere in the [SERVICE] field then `"GET" not in [SERVICE]` is false. In other words it is

```
if [SERVICE] !~ /GET/ and [SERVICE] !~ /UPDATE/ { ...

```

which is very different to the first.

---

<div class="post-metadata">

**Author:** ![rohitarorait82](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rohitarorait82/32/82981_2.png) [@rohitarorait82](https://discuss.elastic.co/u/rohitarorait82)\
**Post date:** [May 5, 2021, 5:04am UTC](https://discuss.elastic.co/t/logstash-filter-for-muliple-values-not-working/272087/3 "2021-05-05T05:04:01Z")

</div>

Hi @Badger ,

Thanks for your reply, yes service name is exact GET and UPDATE only. I missed **not** in the first statement while posting this question.

For any other service message should be removed , right ? but it is not getting removed this way.

```auto
if [SERVICE] not in ["GET", "UPDATE"] {
mutate { remove_field => ["message"] }
}

```

---

<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:** [June 2, 2021, 5:04am UTC](https://discuss.elastic.co/t/logstash-filter-for-muliple-values-not-working/272087/4 "2021-06-02T05:04:25Z")

</div>

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