# How do we match multiple random ips?

**URL:** <https://discuss.elastic.co/t/how-do-we-match-multiple-random-ips/1507>\
**Category:** Logstash\
**Created:** [May 28, 2015, 6:10pm UTC](https://discuss.elastic.co/t/how-do-we-match-multiple-random-ips/1507 "2015-05-28T18:10:56Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [May 28, 2015, 6:33pm UTC](https://discuss.elastic.co/t/how-do-we-match-multiple-random-ips/1507/2 "2015-05-28T18:33:45Z")

</div>

If you're okay with getting all IPs in an array field you can just use [grok](https://www.elastic.co/guide/en/logstash/current/plugins-filters-grok.html) extract all the IPs to a string and use the [mutate filter](https://www.elastic.co/guide/en/logstash/current/plugins-filters-mutate.html) to split that string.

```
filter {
  grok {
    match => ["message", "^(?<ip>%{IP}(, %{IP})*) ..."]
  }
  mutate {
    split => ["ip", ", "]
  }
}

```

It looks like you might always have at least two IPs, each followed by a space, followed by a comma-separated list of IPs. In that you'll have to adjust the filters a bit but it shouldn't be too hard.

---

_[View the full topic](https://discuss.elastic.co/t/how-do-we-match-multiple-random-ips/1507)._
