# Save first lines of data and make it sharable for all file lines in logstash

**URL:** <https://discuss.elastic.co/t/save-first-lines-of-data-and-make-it-sharable-for-all-file-lines-in-logstash/159187>\
**Category:** Logstash\
**Created:** [December 3, 2018, 1:36pm UTC](https://discuss.elastic.co/t/save-first-lines-of-data-and-make-it-sharable-for-all-file-lines-in-logstash/159187 "2018-12-03T13:36:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![joubeh](https://avatars.discourse-cdn.com/v4/letter/j/65b543/32.png) [@joubeh](https://discuss.elastic.co/u/joubeh)\
**Post date:** [December 3, 2018, 1:36pm UTC](https://discuss.elastic.co/t/save-first-lines-of-data-and-make-it-sharable-for-all-file-lines-in-logstash/159187/1 "2018-12-03T13:36:23Z")

</div>

Hello,  
I've the following snapshot from a file that I'm using filebeat and logstash to send it to ES

> Service Endpoint: [http://1.1.1.1:8080/ECM](http://1.1.1.1:8080/ECM)  
> TestSuite : JenkinsDeploy  
> SuccessCount:4  
> FailureCount:0  
> TestCases:1 AdditionalCustomerProfile\_JO.xml, Result: Success  
> TestCases:2 CustomerProfile\_EG.xml, Result: Success  
> TestCases:3 LookUpRetrievals\_EG.xml, Result: Success  
> TestCases:4 LookUpRetrievals\_JO.xml, Result: Success

all I want to do is to keep sending the first 4 lines in each request to ES noting that I read many files and each file contains different data  
is there any way to do it?

---

<div class="post-metadata">

**Author:** ![AquaX](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aquax/32/92006_2.png) [@AquaX](https://discuss.elastic.co/u/AquaX)\
**Post date:** [December 5, 2018, 3:20am UTC](https://discuss.elastic.co/t/save-first-lines-of-data-and-make-it-sharable-for-all-file-lines-in-logstash/159187/2 "2018-12-05T03:20:12Z")

</div>

I've been thinking about this too and I think I'm going to try using the aggregate filter

[https://www.elastic.co/guide/en/logstash/current/plugins-filters-aggregate.html](https://www.elastic.co/guide/en/logstash/current/plugins-filters-aggregate.html)

Since you know what each of the lines looks like you will have to setup 4 grok filters for the first 4 lines then aggregate those together.

Then whenever the line starts with "TestCases" add the aggregated event to that event but don't define it as an end\_event.  
I'm not sure if this will work but it's worth a shot.

---

<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 2, 2019, 3:20am UTC](https://discuss.elastic.co/t/save-first-lines-of-data-and-make-it-sharable-for-all-file-lines-in-logstash/159187/3 "2019-01-02T03:20:12Z")

</div>

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