# Filter an IP with Variable part

**URL:** <https://discuss.elastic.co/t/filter-an-ip-with-variable-part/47552>\
**Category:** Logstash\
**Created:** [April 16, 2016, 3:13am UTC](https://discuss.elastic.co/t/filter-an-ip-with-variable-part/47552 "2016-04-16T03:13:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vtmtwwf](https://avatars.discourse-cdn.com/v4/letter/v/bc79bd/32.png) [@vtmtwwf](https://discuss.elastic.co/u/vtmtwwf)\
**Post date:** [April 16, 2016, 3:13am UTC](https://discuss.elastic.co/t/filter-an-ip-with-variable-part/47552/1 "2016-04-16T03:13:47Z")

</div>

Hello everybody!  
I am receiving logs from several routers in a building with 20 companies. I would like to identify my top 10 Internet destinations, but I would like to see the Name of the destination in my Kibana graphs, not the IP.  
So I guess I might use DNS resolving (but I am afraid it's gonna be too many requests)... or I might use the Filter and Mutate function, but I need some help:

filter { if [dst\_ip] == "31.13.95.14" { mutate { replace =\> ["dst\_ip", "BLUE-WEBSITE"] } } }

Works fine for 1 IP. But BLUE-WEBSITE has more than 1 IP, it has several in the same subnet. So I would like to do something like this, can I?

filter { if [dst\_ip] == "[31.13.95.xxx](http://31.13.95.xxx)" { mutate { replace =\> ["dst\_ip", "BLUE-WEBSITE"] } } }

But this doesn't work at all, the XXX is not understood.

Does anyone has any clue? Thank you so much!  
Vincent.

---

<div class="post-metadata">

**Author:** ![vtmtwwf](https://avatars.discourse-cdn.com/v4/letter/v/bc79bd/32.png) [@vtmtwwf](https://discuss.elastic.co/u/vtmtwwf)\
**Post date:** [April 16, 2016, 4:32am UTC](https://discuss.elastic.co/t/filter-an-ip-with-variable-part/47552/2 "2016-04-16T04:32:47Z")

</div>

Hi there!

I've just found something that seems to work:

filter { if [dst\_ip] =~ "(^31.13.95.)" { mutate { replace =\> ["dst\_ip", "BLUE-WEBSITE"] } } }

But I am looking forward to read your good suggestions.  
Vincent.

---

<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:** [April 18, 2016, 9:09pm UTC](https://discuss.elastic.co/t/filter-an-ip-with-variable-part/47552/3 "2016-04-18T21:09:20Z")

</div>

Have a look at the translate filter.

---

<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:** [July 6, 2017, 5:01am UTC](https://discuss.elastic.co/t/filter-an-ip-with-variable-part/47552/4 "2017-07-06T05:01:47Z")

</div>

Closed on July 6, 2017, 5:01am UTC


