# Transform input before multiline processing?

**URL:** <https://discuss.elastic.co/t/transform-input-before-multiline-processing/202242>\
**Category:** Logstash\
**Created:** [October 3, 2019, 8:58pm UTC](https://discuss.elastic.co/t/transform-input-before-multiline-processing/202242 "2019-10-03T20:58:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dpr](https://avatars.discourse-cdn.com/v4/letter/d/8797f3/32.png) [@dpr](https://discuss.elastic.co/u/dpr)\
**Post date:** [October 3, 2019, 8:58pm UTC](https://discuss.elastic.co/t/transform-input-before-multiline-processing/202242/1 "2019-10-03T20:58:50Z")

</div>

Thanks for looking at my question.

I am using the TCP input to receive XML data from a remote host, which I am parsing into XML stanzas using multiline. This works pretty well.

Unfortunately, the remote host (which I do not control) occasionally sends me broken xml line this:

```
<CurrentSummationDelivered> \r\n
  <DeviceMacId>0x00ff8d00001fe92a</DeviceMacId>\r\n  
  <TimeStamp>0x25291b44</TimeStamp>\r\n  
  <SummationDelivered>0x000000000517fe1c</SummationDelivered>\r\n  
</CurrentSummationDeli\nvered>\r

```

Note that last closing tag. The newline is in the wrong place. This breaks my current multiline configuration:

```
codec => multiline {
  pattern => "<CurrentSummationDelivered>"
  negate => "true"
  what => "previous"
}

```

When this condition occurs, it is regularly broken in exactly this way.

I'd like the "fix up" this input on the receiving end (because I have no control of the sending side). **What approaches might I use to do this in the input, before the XML processing?**

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:** [October 3, 2019, 10:16pm UTC](https://discuss.elastic.co/t/transform-input-before-multiline-processing/202242/2 "2019-10-03T22:16:09Z")

</div>

pattern can be a regular expression. Are you able to construct a regexp that always matches?

---

<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 31, 2019, 11:05pm UTC](https://discuss.elastic.co/t/transform-input-before-multiline-processing/202242/4 "2019-10-31T23:05:20Z")

</div>

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