# Matching multiline log message with Grok

**URL:** <https://discuss.elastic.co/t/matching-multiline-log-message-with-grok/165474>\
**Category:** Logstash\
**Created:** [January 23, 2019, 7:37pm UTC](https://discuss.elastic.co/t/matching-multiline-log-message-with-grok/165474 "2019-01-23T19:37:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![yungnvn](https://avatars.discourse-cdn.com/v4/letter/y/71e660/32.png) [@yungnvn](https://discuss.elastic.co/u/yungnvn)\
**Post date:** [January 23, 2019, 7:37pm UTC](https://discuss.elastic.co/t/matching-multiline-log-message-with-grok/165474/1 "2019-01-23T19:37:42Z")

</div>

I have these three lines of log messages:

```
2019-01-10 15:41:22,164 INFO [ajp-nio-8010-exec-21] wt.system.out manlla - specIdOR:com.lcs.wc.specification.FlexSpecToSeasonLink:1071796633
2019-01-10 15:41:24,160 DEBUG [ajp-nio-8010-exec-34] rfa.jsp.main.Main manlla - 
#################################################################

[REQUEST MADE]
 user = manlla
 ipAddress = 0.0.0.0
 host = 0.0.0.0
 activity = VIEW_SEASON_PRODUCT_LINK
 action = 
 oid = OR:com.lcs.wc.specification.FlexSpecToSeasonLink:10717
 oidList = null
 returnActivity = VIEW_SEASON_PRODUCT_LINK
 returnAction = INIT
 returnOid = OR:com.lcs.wc.specification.FlexSpecToSeasonLink:10717
 typeOid = 
 typeAttributeOid = 
 tabId = 
 tabPage = SOURCING
 errorMessage = null
 sessionId = D90C1D4507BEB3F2B112B0D843.tomcat1
#################################################################
 url = ?activity=VIEW_SEASON_PRODUCT_LINK&action=&oid=OR:com.lcs.wc.specification.FlexSpecToSeasonLink:1071796633&oidList=null&typeOid=&typeAttributeOid=&tabId=&tabPage=SOURCING
#################################################################
2019-01-10 15:41:24,199 DEBUG [ajp-nio-8010-exec-34] rfa.jsp.main.MainTemplate manlla - templateType = 

```

I'm able to parse the first line correctly with this GROK pattern:

%{DATESTAMP:timestamp} %{WORD:severity} %{DATA:var1} %{JAVACLASS:out} %{USERNAME:user} %{GREEDYDATA:msg}

However, I'm having trouble getting to the second log line. Once that line's parsed I'd need to ignore all the # and set the msg field starting from [REQUEST MADE] and end it at the next instance of a log message.

Any help on this would be appreciated! I'm using the GROK debugger to parse this so let me know if more info is required.

---

<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:** [January 23, 2019, 8:55pm UTC](https://discuss.elastic.co/t/matching-multiline-log-message-with-grok/165474/2 "2019-01-23T20:55:50Z")

</div>

Is the second line really a single line? Can you edit your post to use either \</\> in the toolbar above the editing pane or precede and follow the log with lines containing 3 backticks ```

---

<div class="post-metadata">

**Author:** ![yungnvn](https://avatars.discourse-cdn.com/v4/letter/y/71e660/32.png) [@yungnvn](https://discuss.elastic.co/u/yungnvn)\
**Post date:** [January 23, 2019, 9:16pm UTC](https://discuss.elastic.co/t/matching-multiline-log-message-with-grok/165474/3 "2019-01-23T21:16:41Z")

</div>

Unfortunately that second line is one big log message. I'm thinking I'll remove the # and then keep everything else in the message field.

---

<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:** [January 23, 2019, 10:42pm UTC](https://discuss.elastic.co/t/matching-multiline-log-message-with-grok/165474/4 "2019-01-23T22:42:44Z")

</div>

It's one message, but it is not one line. So you will need to combine the lines into a single event. Possibly with a multiline codec on a file input, or if you are using filebeat then you can do it in the beat.

For a file input, this might work.

```
codec => multiline {
    pattern => "^%{TIMESTAMP_ISO8601} "
    negate => true
    what => "previous"
}
```

---

<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:** [February 20, 2019, 10:42pm UTC](https://discuss.elastic.co/t/matching-multiline-log-message-with-grok/165474/5 "2019-02-20T22:42:49Z")

</div>

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