# Parsing multiline, look for closing character?

**URL:** <https://discuss.elastic.co/t/parsing-multiline-look-for-closing-character/119850>\
**Category:** Logstash\
**Created:** [February 14, 2018, 5:15pm UTC](https://discuss.elastic.co/t/parsing-multiline-look-for-closing-character/119850 "2018-02-14T17:15:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![cptnclvn](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@cptnclvn](https://discuss.elastic.co/u/cptnclvn)\
**Post date:** [February 14, 2018, 5:15pm UTC](https://discuss.elastic.co/t/parsing-multiline-look-for-closing-character/119850/1 "2018-02-14T17:15:25Z")

</div>

I am working on a project to parse vCenter logs and when vCenter passes an Event, it puts the event details on multiple messages(see below).

> "message":"\<14\>1 2018-02-14T10:01:12.888790-06:00 vcenter01 vpxd 4683 - - Event [96904] [1-1] [2018-02-14T16:01:12.888057Z] [vim.event.VmReconfiguredEvent] [info] [VSPHERE.LOCAL\Administrator] [DC] [96903] [Reconfigured eventtest on [esxi01.domain.com](http://esxi01.domain.com) in DC. "  
> "message":" "  
> "message":"Modified: "  
> "message":" "  
> "message":"config.hardware.numCPU: 2 -\> 1; "  
> "message":""  
> "message":" Added: "  
> "message":" "  
> "message":" Deleted: "  
> "message":" "  
> "message":"]"

Is it possible to have logstash, when it encounters the closing "]" that it will search the above messages for the opening and concat it into one? Or is there a better solution to combine these messages into one?

---

<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 14, 2018, 5:51pm UTC](https://discuss.elastic.co/t/parsing-multiline-look-for-closing-character/119850/2 "2018-02-14T17:51:51Z")

</div>

Yes, a multiline codec will do that.

```auto
    codec => multiline {
      what => "next"
      negate => "true"
      pattern => '"message":"]"'
    }

```

---

<div class="post-metadata">

**Author:** ![cptnclvn](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@cptnclvn](https://discuss.elastic.co/u/cptnclvn)\
**Post date:** [February 14, 2018, 5:54pm UTC](https://discuss.elastic.co/t/parsing-multiline-look-for-closing-character/119850/3 "2018-02-14T17:54:39Z")

</div>

Thanks for the reply. My understanding might be lacking but how does it know which lines to concat or where to start with this codec?

---

<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 14, 2018, 7:09pm UTC](https://discuss.elastic.co/t/parsing-multiline-look-for-closing-character/119850/4 "2018-02-14T19:09:29Z")

</div>

The documentation is [here](https://www.elastic.co/guide/en/logstash/current/plugins-codecs-multiline.html). That combination of what and negate mean if the line does _not_ match the pattern, then prepend this line to the _next_ line. An event is not emitted until a line _does_ match the pattern.

---

<div class="post-metadata">

**Author:** ![cptnclvn](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@cptnclvn](https://discuss.elastic.co/u/cptnclvn)\
**Post date:** [February 14, 2018, 9:24pm UTC](https://discuss.elastic.co/t/parsing-multiline-look-for-closing-character/119850/5 "2018-02-14T21:24:34Z")

</div>

I figured out a slightly different route to go. The messages that i receive all start with so i setup the multiline codec to postpend any line that doesn't start with that pattern. Code below.

 

> codec =\> multiline {  
> pattern =\> "^\<%{POSINT}\>1 "  
> 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:** [March 14, 2018, 9:24pm UTC](https://discuss.elastic.co/t/parsing-multiline-look-for-closing-character/119850/6 "2018-03-14T21:24:59Z")

</div>

Closed on March 14, 2018, 9:24pm UTC

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