# Best Way To Match Hundreds of Value Possibilities in Logstash

**URL:** <https://discuss.elastic.co/t/best-way-to-match-hundreds-of-value-possibilities-in-logstash/217471>\
**Category:** Logstash\
**Created:** [January 31, 2020, 10:53pm UTC](https://discuss.elastic.co/t/best-way-to-match-hundreds-of-value-possibilities-in-logstash/217471 "2020-01-31T22:53:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![joshuasmith](https://avatars.discourse-cdn.com/v4/letter/j/74df32/32.png) [@joshuasmith](https://discuss.elastic.co/u/joshuasmith)\
**Post date:** [January 31, 2020, 10:53pm UTC](https://discuss.elastic.co/t/best-way-to-match-hundreds-of-value-possibilities-in-logstash/217471/1 "2020-01-31T22:53:12Z")

</div>

Good day,

I am trying to find the most efficient way in Logstash filters to say "if field X is one of these dozens/hundreds/thousands of values do something".

For instance, I have multiple log sources (Windows logs, firewall logs, etc.) where I have a field and want to match something.

Here are some specific examples:

- I want to do a mutate if a Windows Event ID is equal to one of dozens of values (4624, 4625, etc.)
- I want to perform a mutate on an IP address from a firewall log if the IP address matches one of several thousand IPs
- I am trying to mutate an entry when a fields string value matches one of several dozen strings

In the past if it was only a few values I would do a filter similar to this:  
if [winlog][event\_id] == 4624 or [winlog][event\_id] == 4625 or [winlog][event\_id] == 4720 or [winlog][event\_id] == 5136 or [winlog][event\_id] == 4744 {  
mutate { add\_tag =\> ['tag\_name\_here'] }  
}

However, that solution doesn't scale very well and I am sure there is a better way but google fu isn't leading me to a good answer. Sorry if I missed it.

Any suggestions?

Thanks!

---

<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 1, 2020, 12:03am UTC](https://discuss.elastic.co/t/best-way-to-match-hundreds-of-value-possibilities-in-logstash/217471/2 "2020-02-01T00:03:18Z")

</div>

You could use a translate filter to tag the events.

---

<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:** [February 29, 2020, 12:08am UTC](https://discuss.elastic.co/t/best-way-to-match-hundreds-of-value-possibilities-in-logstash/217471/3 "2020-02-29T00:08:19Z")

</div>

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