# Help splitting field into two

**URL:** <https://discuss.elastic.co/t/help-splitting-field-into-two/178459>\
**Category:** Logstash\
**Created:** [April 25, 2019, 12:57pm UTC](https://discuss.elastic.co/t/help-splitting-field-into-two/178459 "2019-04-25T12:57:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rblumenthal](https://avatars.discourse-cdn.com/v4/letter/r/5e9695/32.png) [@rblumenthal](https://discuss.elastic.co/u/rblumenthal)\
**Post date:** [April 25, 2019, 12:57pm UTC](https://discuss.elastic.co/t/help-splitting-field-into-two/178459/1 "2019-04-25T12:57:47Z")

</div>

Hey folks,

I am sending logs from Windows server using winlogbeat to logstash (6.6). The field that I am trying to split has 2 IP addresses separated by a comma. How can I go about and create 2 new fields (FirstIP and SecondIP)? There will only ever be a max of 2 IPs, but sometimes only 1.

Field:  
event\_data.param5

I tried doing something like this but filters are not my strong point by any means.

filter {  
mutate {  
split =\> ["event\_data.param5", ","]  
add\_field =\> { "FirstIP" =\> "%{[event\_data][param5], 0}" }  
}  
}

The new field, FirstIP, just appears as: %{[event\_data][param5], 0}

Any assistance or guidance would be great. 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:** [April 25, 2019, 2:05pm UTC](https://discuss.elastic.co/t/help-splitting-field-into-two/178459/2 "2019-04-25T14:05:43Z")

</div>

Surrounding a field in a grok filter with ( )? makes it optional, so the following

```
grok { match => { "message" => "%{IPV4:ip1}(,%{IPV4:ip2})?" } }

```

will match both of these

```
128.0.0.0
126.0.0.0,125.0.0.1
```

---

<div class="post-metadata">

**Author:** ![rblumenthal](https://avatars.discourse-cdn.com/v4/letter/r/5e9695/32.png) [@rblumenthal](https://discuss.elastic.co/u/rblumenthal)\
**Post date:** [April 25, 2019, 2:48pm UTC](https://discuss.elastic.co/t/help-splitting-field-into-two/178459/3 "2019-04-25T14:48:39Z")

</div>

Great thank you. That was exactly what I needed!

---

<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:** [April 25, 2019, 3:01pm UTC](https://discuss.elastic.co/t/help-splitting-field-into-two/178459/4 "2019-04-25T15:01:18Z")

</div>

There is

```
%{EMAILADDRESS:email}

```

but it is a pretty narrow definition of an email address. It does not match UUCP bang paths, for example, like "mcvax!foo"@somehost.com, and will not recognize TLDs in non-Latin characters, so if your email address is in the онлайн domain it is not going to match it.

---

<div class="post-metadata">

**Author:** ![rblumenthal](https://avatars.discourse-cdn.com/v4/letter/r/5e9695/32.png) [@rblumenthal](https://discuss.elastic.co/u/rblumenthal)\
**Post date:** [April 25, 2019, 3:02pm UTC](https://discuss.elastic.co/t/help-splitting-field-into-two/178459/5 "2019-04-25T15:02:11Z")

</div>

Ok thank you. I had just found that. I appreciate the help.

---

<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:** [May 23, 2019, 3:02pm UTC](https://discuss.elastic.co/t/help-splitting-field-into-two/178459/6 "2019-05-23T15:02:25Z")

</div>

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