# How to combine two lines based on the pattern

**URL:** <https://discuss.elastic.co/t/how-to-combine-two-lines-based-on-the-pattern/162338>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [December 28, 2018, 11:24am UTC](https://discuss.elastic.co/t/how-to-combine-two-lines-based-on-the-pattern/162338 "2018-12-28T11:24:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nee\_Defeng](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nee_defeng/32/45771_2.png) [@Nee\_Defeng](https://discuss.elastic.co/u/Nee_Defeng)\
**Post date:** [December 28, 2018, 11:24am UTC](https://discuss.elastic.co/t/how-to-combine-two-lines-based-on-the-pattern/162338/1 "2018-12-28T11:24:32Z")

</div>

I have the input logs like this:

C1 is completed on 2018-12-27.  
C2 is running.  
Now it is 2018-12-28.

What I want to output to ES is:  
C1: 2018-12-27  
C2: 2018-12-28

Basically it needs to combine line #2 and #3 into one line and use the pattern to parse the output, or parse #2 and #3 lines separately and then combine these two values together. How can I do that?

---

<div class="post-metadata">

**Author:** ![steffens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steffens/32/79630_2.png) [@steffens](https://discuss.elastic.co/u/steffens)\
**Post date:** [January 2, 2019, 12:54pm UTC](https://discuss.elastic.co/t/how-to-combine-two-lines-based-on-the-pattern/162338/2 "2019-01-02T12:54:20Z")

</div>

You can combine the lines via [multiline settings in Beats](https://www.elastic.co/guide/en/beats/filebeat/current/multiline-examples.html).

Looks like you want to match on 'Now' when combining lines.  
Try `negate: true`, `match: before`, and `pattern: '^Now it is'`.

The parsing you will have to do in Logstash I guess.

---

<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:** [January 30, 2019, 12:54pm UTC](https://discuss.elastic.co/t/how-to-combine-two-lines-based-on-the-pattern/162338/3 "2019-01-30T12:54:20Z")

</div>

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