# Custom Multiline Parsing

**URL:** <https://discuss.elastic.co/t/custom-multiline-parsing/197946>\
**Category:** Logstash\
**Created:** [September 3, 2019, 8:54pm UTC](https://discuss.elastic.co/t/custom-multiline-parsing/197946 "2019-09-03T20:54:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Naveesh\_Doolhur](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/naveesh_doolhur/32/53548_2.png) [@Naveesh\_Doolhur](https://discuss.elastic.co/u/Naveesh_Doolhur)\
**Post date:** [September 3, 2019, 8:54pm UTC](https://discuss.elastic.co/t/custom-multiline-parsing/197946/1 "2019-09-03T20:54:30Z")

</div>

I have a Log file as follows:

```
===================================== REQUEST 03-09-2019 01:12:25.808599 REF:5001462 =========================================
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Service2>
    <Rqst>
        <MsgHdr>
            <Version>006</Version>
            <TimeGMT>2019090221123353</TimeGMT>
        </MsgHdr>
    </Rqst>
</Service2>

===================================== RESPONSE 03-09-2019 01:12:27.434655 Ref:5001462 =========================================
<Service2><Resp><MsgHdr><Version>006</Version><TimeGMT>20190903011227</TimeGMT></MsgHdr></Resp></Service2>

```

There is a request and then a response. Any idea how it can be parsed? I would need the whole Request XML and Response XML in a single row as well as the request and response time. Both have the same Ref field.

Thanks

---

<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:** [September 4, 2019, 12:02pm UTC](https://discuss.elastic.co/t/custom-multiline-parsing/197946/2 "2019-09-04T12:02:26Z")

</div>

I would start with

```
    grok {
        match => { "message" => "=+ %{DATA:header} =+
%{GREEDYDATA:[@metadata][xml]}" }
    }
    xml { source => "[@metadata][xml]" target => "theXML" force_array => false }
```

---

<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:** [October 2, 2019, 12:02pm UTC](https://discuss.elastic.co/t/custom-multiline-parsing/197946/3 "2019-10-02T12:02:34Z")

</div>

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