# Data Type Conversion for bytes

**URL:** <https://discuss.elastic.co/t/data-type-conversion-for-bytes/63061>\
**Category:** Logstash\
**Created:** [October 14, 2016, 1:50pm UTC](https://discuss.elastic.co/t/data-type-conversion-for-bytes/63061 "2016-10-14T13:50:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hans](https://avatars.discourse-cdn.com/v4/letter/h/e19b73/32.png) [@Hans](https://discuss.elastic.co/u/Hans)\
**Post date:** [October 14, 2016, 1:50pm UTC](https://discuss.elastic.co/t/data-type-conversion-for-bytes/63061/1 "2016-10-14T13:50:50Z")

</div>

Hi, I am importing a csv file and need to convert the fields that contain numbers to float to compute them in Kibana. However the bytes fields that contain volume of data should in Kibana be recognized as such. How can I do this, here is the current filter configuration I am using:

filter {  
csv {  
columns =\> [  
"BytesDownloaded",  
"BytesUploaded",  
]  
separator =\> ","  
remove\_field =\> ["message"]  
}  
mutate {  
convert =\> { "BytesDownloaded" =\> "float" }  
convert =\> { "BytesUploaded" =\> "float" }  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [October 15, 2016, 8:57pm UTC](https://discuss.elastic.co/t/data-type-conversion-for-bytes/63061/2 "2016-10-15T20:57:55Z")

</div>

Does this not work? What is the field mapped as in ES?

---

<div class="post-metadata">

**Author:** ![Hans](https://avatars.discourse-cdn.com/v4/letter/h/e19b73/32.png) [@Hans](https://discuss.elastic.co/u/Hans)\
**Post date:** [October 16, 2016, 1:41pm UTC](https://discuss.elastic.co/t/data-type-conversion-for-bytes/63061/3 "2016-10-16T13:41:13Z")

</div>

They are seen as numbers only

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [October 16, 2016, 3:36pm UTC](https://discuss.elastic.co/t/data-type-conversion-for-bytes/63061/4 "2016-10-16T15:36:00Z")

</div>

- Why are you converting the fields to floats? Byte counts are discrete and should be integers.
- How are the fields currently mapped in ES? Use the get mapping API. I have no idea what you mean by "They are seen as numbers only".

---

<div class="post-metadata">

**Author:** ![Hans](https://avatars.discourse-cdn.com/v4/letter/h/e19b73/32.png) [@Hans](https://discuss.elastic.co/u/Hans)\
**Post date:** [October 16, 2016, 6:05pm UTC](https://discuss.elastic.co/t/data-type-conversion-for-bytes/63061/5 "2016-10-16T18:05:34Z")

</div>

Apologies for not being clear, let me try and elaborate. The objective is the following:  
I have a CSV file that I would like to use in Kibana and when computing the volumes in bytes that the dashboard automatically computes values to MBytes, Gytes, etc. as applicable. As per the filter on top is what I am currently using, I also tried integers however when in Kibana dashboard it shows in bytes only. Here is an example:  
 ![](https://us1.discourse-cdn.com/elastic/original/2X/9/97c1cc1d81a192cac1791aa0152213e3038c653f.png)  
In Kibana the type is number.

In Elastic search it is mapped as the following:  
"Bytes\_of\_Downlink\_Data\_Packets\_Received\_Interface(Byte)":{"type":"double"}

I am using the default logstash indexing:  
output {  
elasticsearch {  
hosts =\> ["localhost:9200"]

```
index => "logstash-%{+MM.YYYY}"

```

}  
}

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [October 16, 2016, 9:00pm UTC](https://discuss.elastic.co/t/data-type-conversion-for-bytes/63061/6 "2016-10-16T21:00:39Z")

</div>

> [@Hans](#):
>
> in Kibana and when computing the volumes in bytes that the dashboard automatically computes values to MBytes, Gytes, etc. as applicable.

Currently the only way to do that is to create a scripted field and divide by 1024^N. Or do the same thing via a ruby filter in LS before it hits ES.

I think KB 5 will allow you to set a field modifier so you can dynamically "convert" such things.

---

<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:** [July 6, 2017, 4:34am UTC](https://discuss.elastic.co/t/data-type-conversion-for-bytes/63061/7 "2017-07-06T04:34:01Z")

</div>


