# Base Pattern & optional patterns parsing with logstash

**URL:** <https://discuss.elastic.co/t/base-pattern-optional-patterns-parsing-with-logstash/93351>\
**Category:** Logstash\
**Created:** [July 17, 2017, 7:56am UTC](https://discuss.elastic.co/t/base-pattern-optional-patterns-parsing-with-logstash/93351 "2017-07-17T07:56:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MaikLinnemann](https://avatars.discourse-cdn.com/v4/letter/m/8c91f0/32.png) [@MaikLinnemann](https://discuss.elastic.co/u/MaikLinnemann)\
**Post date:** [July 17, 2017, 7:56am UTC](https://discuss.elastic.co/t/base-pattern-optional-patterns-parsing-with-logstash/93351/1 "2017-07-17T07:56:18Z")

</div>

Dear Forum,

i have a problem with parsing grok filter. **This is working from command line with a ruby test script like it should** :

pattern = "%{PFLTR},?%{PORTS}?,?%{ICMP}?"

It parses the lines and gets the stuff from "%{PFLTR}" (Lets call it base string) and optionally gets the stuff from "?%{PORTS}?,?%{ICMP}?" (lets call it optional string)....All Fields are filled either with values or with empty values.

In the grok file i use in logstash, with the same line, it never respects "?%{PORTS}?,?%{ICMP}?". It only gets the stuff from "%{PFLTR}" and the other fields are just empty.

I would provide more info if necessary. Hope that somebody could give me a hint. Thanks in advance,

regards

---

<div class="post-metadata">

**Author:** ![MaikLinnemann](https://avatars.discourse-cdn.com/v4/letter/m/8c91f0/32.png) [@MaikLinnemann](https://discuss.elastic.co/u/MaikLinnemann)\
**Post date:** [July 18, 2017, 9:32am UTC](https://discuss.elastic.co/t/base-pattern-optional-patterns-parsing-with-logstash/93351/2 "2017-07-18T09:32:41Z")

</div>

I found the solution by myself. It may help someone....

PFLTR %{PACKETFILTER} **?(%{PORTS}|%{ICMP})?**

---

<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:** [August 15, 2017, 9:32am UTC](https://discuss.elastic.co/t/base-pattern-optional-patterns-parsing-with-logstash/93351/3 "2017-08-15T09:32:46Z")

</div>

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