# Multiline postfix grok filter

**URL:** <https://discuss.elastic.co/t/multiline-postfix-grok-filter/31435>\
**Category:** Logstash\
**Created:** [October 1, 2015, 2:06am UTC](https://discuss.elastic.co/t/multiline-postfix-grok-filter/31435 "2015-10-01T02:06:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![etfeet](https://avatars.discourse-cdn.com/v4/letter/e/4da419/32.png) [@etfeet](https://discuss.elastic.co/u/etfeet)\
**Post date:** [October 1, 2015, 2:06am UTC](https://discuss.elastic.co/t/multiline-postfix-grok-filter/31435/1 "2015-10-01T02:06:35Z")

</div>

I'm trying to create a multi-line postfix grok pattern to have messageid, userid, username, queueid, from,to,size,etc. in the same document for graphing in kibana.

is there a way to match elements in the middle of messages without having to match everything before it?

"%{SYSLOGTIMESTAMP:pf\_ts} %{HOSTNAME:hostname} %{NOTSPACE:pf\_program}/%{NOTSPACE}: %{NOTSPACE:queueid}: uid=%{NUMBER:uid} from=\<%{USERNAME:username}\>",  
%{SYSLOGTIMESTAMP} %{HOSTNAME} %{NOTSPACE} %{POSTFIX\_QUEUEID}: message-id=\<%{NOTSPACE:messageid}\>",  
....  
instead of

%{SYSLOGTIMESTAMP:postfix\_ts} %{HOSTNAME:postfix\_hostname} %{NOTSPACE:postfix\_program}/%{NOTSPACE}[%{NUMBER}]: %{POSTFIX\_QUEUEID:postfix\_queueid}: uid=%{NUMBER:postfix\_uid} from=\<%{NOTSPACE:postfix\_from\_user}\> %{SYSLOGTIMESTAMP} %{HOSTNAME} %{NOTSPACE} %{POSTFIX\_QUEUEID}: message-id=\<%{NOTSPACE:postfix\_messageid}\> %{SYSLOGTIMESTAMP} %{HOSTNAME} %{NOTSPACE} %{POSTFIX\_QUEUEID}: from=\<%{NOTSPACE:postfix\_from}\>, size=%{NUMBER:postfix\_size}, nrcpt=%{NUMBER:postfix\_nrcpt} (queue active) %{SYSLOGTIMESTAMP} %{HOSTNAME} %{NOTSPACE} %{POSTFIX\_QUEUEID}: to=\<%{NOTSPACE:postfix\_to}\>, orig\_to=\<%{NOTSPACE:postfix\_orig\_to}\>, relay=%{WORD:postfix\_relay}, delay=%{NUMBER:postfix\_delay}, delays=%{NOTSPACE:postfix\_delays}, dsn=%{NOTSPACE:postfix\_dsn}, status=%{NOTSPACE:postfix\_status}

example log:

"Sep 30 17:30:23 rory-dev postfix/pickup[21766]: CEDD7F80708: uid=0 from= Sep 30 17:30:23 rory-dev postfix/cleanup[24115]: CEDD7F80708: message-id=[20151001003023.CEDD7F80708@rory-dev.localdomain](mailto:20151001003023.CEDD7F80708@rory-dev.localdomain) Sep 30 17:30:23 rory-dev postfix/qmgr[2079]: CEDD7F80708: from=[root@rory-dev.localdomain](mailto:root@rory-dev.localdomain), size=308, nrcpt=1 (queue active) Sep 30 17:30:23 rory-dev postfix/local[24278]: CEDD7F80708: to=[root@localhost.localdomain](mailto:root@localhost.localdomain), orig\_to=[root@localhost](mailto:root@localhost), relay=local, delay=0.11, delays=0.07/0.01/0/0.03, dsn=2.0.0, status=sent (delivered to mailbox) Sep 30 17:30:23 rory-dev postfix/qmgr[2079]: CEDD7F80708: removed",

Thank

---

<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:** [October 1, 2015, 6:27am UTC](https://discuss.elastic.co/t/multiline-postfix-grok-filter/31435/2 "2015-10-01T06:27:17Z")

</div>

These lines are not guaranteed to be consecutive so what you're trying to do will only work in special cases cases.

---

<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:27am UTC](https://discuss.elastic.co/t/multiline-postfix-grok-filter/31435/3 "2017-07-06T05:27:35Z")

</div>

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


