# How to remove first line of a multiline message

**URL:** <https://discuss.elastic.co/t/how-to-remove-first-line-of-a-multiline-message/53156>\
**Category:** Logstash\
**Created:** [June 17, 2016, 12:40pm UTC](https://discuss.elastic.co/t/how-to-remove-first-line-of-a-multiline-message/53156 "2016-06-17T12:40:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![markus](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@markus](https://discuss.elastic.co/u/markus)\
**Post date:** [June 17, 2016, 12:40pm UTC](https://discuss.elastic.co/t/how-to-remove-first-line-of-a-multiline-message/53156/1 "2016-06-17T12:40:26Z")

</div>

hi,  
i am parsing a multiline log containg lots of garbage and in between pearls of xml data that I'd like to extract.

my data looks like this:

> some Text I'd like to drop {}  
> some Text with a token signaling XML Document starting in next line
> 
> \<?xml.... \<a\> \<b/\> \</a\> some Text I'd like to drop {} some Text with a token signaling XML Document starting in next line \<c\> \<b/\> \</c\> some Text I'd like to drop {}

Problem is not all xml's start with proper processing instructions so I have to rely on the token in the preceeding line as a hook for starting a new multiline message. I got as far as getting a multiline pattern setup giving me the XML + the preceeding line containg my token signaling the xml start.

So my message looks like this:

> some Text with a token signaling XML Document starting in next line\r\n
> 
> \<?xml ....\r\n \<a\>\r\n \<b/\>\r\n \</a\>\r\n

I'd like to remove the first line of the resulting message in order to get a valid xml. Any ideas on how to get that done?  
Thanks for your ideas/feedback,  
Markus

---

<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:** [June 21, 2016, 5:33am UTC](https://discuss.elastic.co/t/how-to-remove-first-line-of-a-multiline-message/53156/2 "2016-06-21T05:33:47Z")

</div>

The mutate filter's gsub option should be useful for this.

---

<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, 4:51am UTC](https://discuss.elastic.co/t/how-to-remove-first-line-of-a-multiline-message/53156/3 "2017-07-06T04:51:40Z")

</div>


