# Consider only first IP on apache access log

**URL:** <https://discuss.elastic.co/t/consider-only-first-ip-on-apache-access-log/79040>\
**Category:** Logstash\
**Created:** [March 17, 2017, 2:27pm UTC](https://discuss.elastic.co/t/consider-only-first-ip-on-apache-access-log/79040 "2017-03-17T14:27:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nick76](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nick76/32/6697_2.png) [@nick76](https://discuss.elastic.co/u/nick76)\
**Post date:** [March 17, 2017, 2:27pm UTC](https://discuss.elastic.co/t/consider-only-first-ip-on-apache-access-log/79040/1 "2017-03-17T14:27:58Z")

</div>

Hello all,  
I need an help about a small problem I've:  
in my access log I have a list of IPs (the end user, ha proxy, varnish ....) one after the other. in order to filter correctly I wish to retain only client IP.  
what should I do to achieve that? I can also add all the IPs in another field (that won't be indexed).  
thank you very much  
best regards  
Nick

---

<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 17, 2017, 2:35pm UTC](https://discuss.elastic.co/t/consider-only-first-ip-on-apache-access-log/79040/2 "2017-03-17T14:35:00Z")

</div>

Capture the first IP address, then match but don't capture zero, one, or more additional IP addresses.

```
%{IP:ip_address}(, %{IP})*
```

---

<div class="post-metadata">

**Author:** ![nick76](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nick76/32/6697_2.png) [@nick76](https://discuss.elastic.co/u/nick76)\
**Post date:** [March 17, 2017, 2:57pm UTC](https://discuss.elastic.co/t/consider-only-first-ip-on-apache-access-log/79040/3 "2017-03-17T14:57:21Z")

</div>

Hi Magnus,  
thank you very much, works like a charm.  
best regards  
Nick

---

<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 14, 2017, 2:57pm UTC](https://discuss.elastic.co/t/consider-only-first-ip-on-apache-access-log/79040/4 "2017-04-14T14:57:29Z")

</div>

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