# Source file size and number of lines

**URL:** <https://discuss.elastic.co/t/source-file-size-and-number-of-lines/180986>\
**Category:** Logstash\
**Created:** [May 14, 2019, 11:05am UTC](https://discuss.elastic.co/t/source-file-size-and-number-of-lines/180986 "2019-05-14T11:05:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![saif3r](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@saif3r](https://discuss.elastic.co/u/saif3r)\
**Post date:** [May 14, 2019, 11:05am UTC](https://discuss.elastic.co/t/source-file-size-and-number-of-lines/180986/1 "2019-05-14T11:05:45Z")

</div>

Hello,

I'm processing raw .xml file using file plugin in Logstash. I'm gathering some metadata about the file like _path_ and _host_ but I would like to get **input file size** and **number of lines** as well. Is that possible? If so, how could I do that?  
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:** [May 14, 2019, 2:11pm UTC](https://discuss.elastic.co/t/source-file-size-and-number-of-lines/180986/2 "2019-05-14T14:11:57Z")

</div>

For the number of lines you could query elasticsearch for the number of documents that have particular values for path and host.

You could use an exec input to run "wc -lc" against the files.

You could use an aggregate filter with a code block that incremented a line counter and summed the length of the [message] field for each path.

There are many ways to get what you want.

---

<div class="post-metadata">

**Author:** ![saif3r](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@saif3r](https://discuss.elastic.co/u/saif3r)\
**Post date:** [May 15, 2019, 10:48am UTC](https://discuss.elastic.co/t/source-file-size-and-number-of-lines/180986/3 "2019-05-15T10:48:18Z")

</div>

Understood @Badger, thanks.

---

<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:** [June 12, 2019, 10:48am UTC](https://discuss.elastic.co/t/source-file-size-and-number-of-lines/180986/4 "2019-06-12T10:48:24Z")

</div>

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