# Possibility to select "NULL" in a log file

**URL:** <https://discuss.elastic.co/t/possibility-to-select-null-in-a-log-file/170390>\
**Category:** Logstash\
**Created:** [February 28, 2019, 5:22pm UTC](https://discuss.elastic.co/t/possibility-to-select-null-in-a-log-file/170390 "2019-02-28T17:22:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gegi\_K](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gegi_k/32/38376_2.png) [@Gegi\_K](https://discuss.elastic.co/u/Gegi_K)\
**Post date:** [February 28, 2019, 5:22pm UTC](https://discuss.elastic.co/t/possibility-to-select-null-in-a-log-file/170390/1 "2019-02-28T17:22:15Z")

</div>

Dear All,

I may ask for the impossible, but maybe you can help me out... Even formulating the title bit hard and it may be misleading.

I have a logfile structure of a firewall that has some possible actions:  
Allow; Drop; Block and according to this I can set up pretty good filters...

BUT... I have a part like this:  
192.168.0.10|27189||eth0  
dstIP|dstPort||outIF

This can sometime look like this:  
192.168.0.10|443|https|eth0  
dstIP|dstPort|dstService|outIF

here I use this for the pipes: (?|)...(?|)

the issue is, if there is not well known service associated to the port we have 2 pipe symbols next to each other where there is nothing in between.  
Is there a possibility to not mess up the whole parsing?

I mean if I have %{WORD:dstPort} then it is followedby 1 character "|" which separates the dstProtocol if there is any. and the another "|" and it goes on...

is there a way to tell logstash that if there are 2 consecutive "|"-s there may be something in between? basically one tries to select nothing...

My best solution was so far to make it via regx but then I have a | at the end of the dstPort field and the dstProtocol is euther a single "|" or "|https"...

any help is much appreciated.

Thanks!

Regards,  
Gergö

---

<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 28, 2019, 5:36pm UTC](https://discuss.elastic.co/t/possibility-to-select-null-in-a-log-file/170390/2 "2019-02-28T17:36:02Z")

</div>

How about

```
"%{IPV4:ip}\|%{NUMBER:port}\|(?<protocol>[^\|]*)\|%{WORD:interface}"
```

---

<div class="post-metadata">

**Author:** ![Gegi\_K](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gegi_k/32/38376_2.png) [@Gegi\_K](https://discuss.elastic.co/u/Gegi_K)\
**Post date:** [February 28, 2019, 5:40pm UTC](https://discuss.elastic.co/t/possibility-to-select-null-in-a-log-file/170390/3 "2019-02-28T17:40:25Z")

</div>

How about... Geez, thanks! I owe you a beer!

---

<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:** [March 28, 2019, 5:40pm UTC](https://discuss.elastic.co/t/possibility-to-select-null-in-a-log-file/170390/4 "2019-03-28T17:40:30Z")

</div>

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