# Multiline Filter Help to find specific field

**URL:** <https://discuss.elastic.co/t/multiline-filter-help-to-find-specific-field/116090>\
**Category:** Logstash\
**Created:** [January 18, 2018, 3:27pm UTC](https://discuss.elastic.co/t/multiline-filter-help-to-find-specific-field/116090 "2018-01-18T15:27:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![moriol](https://avatars.discourse-cdn.com/v4/letter/m/439d5e/32.png) [@moriol](https://discuss.elastic.co/u/moriol)\
**Post date:** [January 18, 2018, 3:27pm UTC](https://discuss.elastic.co/t/multiline-filter-help-to-find-specific-field/116090/1 "2018-01-18T15:27:55Z")

</div>

I have an xml file that I need to ingest with Logstash, with specific fields. It has structure:  
\< Test\>  
\< Type\>  
\< Data\>  
..........  
..........  
\< /Data\>  
\< /Type\>  
\< /Test\>

I am trying to use multiline codec, in order to filter through the message and get the data I need with a specific pattern.  
The data I only want to ingest is everything inside of \< Data\>......\< /Data\> and ignore the rest of the data.

I have following configuration, which seems to take for start each event, but ingests data until the next . I seem to get in each event \< Data\>\< /Data\> \< /Test\>\< Test\>\< Type\>  
codec =\> multiline {  
# pattern =\> "._\< Data\>._"  
pattern =\> "\<(Data)|(Data)\>"  
negate =\> true  
what =\> "previous"  
}

How to take only everything in \< Data\>\< /Data\> into account?

---

<div class="post-metadata">

**Author:** ![moriol](https://avatars.discourse-cdn.com/v4/letter/m/439d5e/32.png) [@moriol](https://discuss.elastic.co/u/moriol)\
**Post date:** [January 18, 2018, 3:48pm UTC](https://discuss.elastic.co/t/multiline-filter-help-to-find-specific-field/116090/2 "2018-01-18T15:48:50Z")

</div>

I managed to resolve with:  
codec =\> multiline {  
pattern =\> "._\<( Test|Type|Data)\>._"  
negate =\> true  
what =\> "previous"

and then in filter drop anything containing:  
if [message] =~ "\< Test\>" {  
drop {}}  
Same for Data.

Is there a better way with multiline to deal with 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:** [February 15, 2018, 3:48pm UTC](https://discuss.elastic.co/t/multiline-filter-help-to-find-specific-field/116090/3 "2018-02-15T15:48:54Z")

</div>

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