# How to calculate the filesize in logstash

**URL:** <https://discuss.elastic.co/t/how-to-calculate-the-filesize-in-logstash/95379>\
**Category:** Logstash\
**Created:** [August 1, 2017, 4:34pm UTC](https://discuss.elastic.co/t/how-to-calculate-the-filesize-in-logstash/95379 "2017-08-01T16:34:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sudi\_2611](https://avatars.discourse-cdn.com/v4/letter/s/47e85d/32.png) [@sudi\_2611](https://discuss.elastic.co/u/sudi_2611)\
**Post date:** [August 1, 2017, 4:34pm UTC](https://discuss.elastic.co/t/how-to-calculate-the-filesize-in-logstash/95379/1 "2017-08-01T16:34:54Z")

</div>

Hi,

i am new to elasticsearch, am i trying to calculate the HDFS space conumption via kibana..  
i have a fsimage which contains the csv file from cluster..the file size is in byes and my code in logstash is as follows:

file {  
path =\> '/etc/logstash/scripts/fsimage.csv.\*'  
start\_position =\> "beginning"  
type =\> "fsimage"  
}  
}

filter {  
if [type] == "fsimage" {  
csv {  
separator =\> "|"  
columns =\> ["HDFSPath", "replication", "ModificationTime", "AccessTime", "PreferredBlockSize", "BlocksCount", "FileSize", "NSQUOTA", "DSQUOTA", "permission", "user", "group"]  
convert =\> {  
'replication' =\> 'integer'  
'PreferredBlockSize' =\> 'integer'  
'BlocksCount' =\> 'integer'  
'FileSize' =\> 'integer'  
'NSQUOTA' =\> 'integer'  
'DSQUOTA' =\> 'integer'  
}  
eg of a csv file:  
XXXXXX|3|2016-12-3011:34|2016-12-3011:34|134217728|1|88807|0|0|-rw-r--r--|kbd\_b9xf|hdfs

the problem is filesize which 88807 bytes is calculated only once but in hdfs total space is fs \* replication count..how do i calculate filesize as fs \* replication count in above script....

---

<div class="post-metadata">

**Author:** ![mhgeay](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mhgeay/32/21365_2.png) [@mhgeay](https://discuss.elastic.co/u/mhgeay)\
**Post date:** [August 22, 2017, 1:23pm UTC](https://discuss.elastic.co/t/how-to-calculate-the-filesize-in-logstash/95379/2 "2017-08-22T13:23:59Z")

</div>

Hello sudi,

For me you have 2 options :  
You have the logstash solution (do the multiplication by logstash) : you should use the Ruby plugin as recommended by @magnusbaeck on this [topic](https://discuss.elastic.co/t/field-value-calculation-conversions-in-logstash-filter-plugin/42147).

Or (it's better for me), try to use Kibana visualisation to do the operation, it's more flexible to get raw data and manipulate it trough Kibana (you may use in the future).

Hope it's help you !

---

<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:** [September 19, 2017, 1:24pm UTC](https://discuss.elastic.co/t/how-to-calculate-the-filesize-in-logstash/95379/3 "2017-09-19T13:24:16Z")

</div>

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