# Change type field in logstash

**URL:** <https://discuss.elastic.co/t/change-type-field-in-logstash/204368>\
**Category:** Logstash\
**Created:** [October 20, 2019, 4:56pm UTC](https://discuss.elastic.co/t/change-type-field-in-logstash/204368 "2019-10-20T16:56:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mohammad\_Mousavi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mohammad_mousavi/32/56508_2.png) [@Mohammad\_Mousavi](https://discuss.elastic.co/u/Mohammad_Mousavi)\
**Post date:** [October 20, 2019, 4:56pm UTC](https://discuss.elastic.co/t/change-type-field-in-logstash/204368/1 "2019-10-20T16:56:09Z")

</div>

Hi. I wanna have sum of network usage per client in nginx. This is the logstash before changes:  
**grok { match =\> { "message" =\> "%{IP:clientip} ... %{NUMBER:bytes}" } }**  
so at first I changed the NUMBER to INT:  
**grok { match =\> { "message" =\> "%{IP:clientip} ... %{INT:bytes}" } }**  
but it didn't work and in elasticsearch it's still text format and unable to do sum on it.  
I added this line:  
**mutate { convert =\> ["bytes", "integer"] }**  
but it's not working yet. Do I need to delete index ? I prefer not to delete it.  
this is logstash output:  
output {  
elasticsearch {  
hosts =\> ["localhost"]  
manage\_template =\> true  
ilm\_enabled =\> false  
index =\> "logstash-%{+YYYY.MM.dd}"  
}  
}  
This is elasticsearch mapping:  
"bytes": {  
"type": "text",  
"norms": false,  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
}  
or can I use PUT command to change the "bytes" format ?  
Thanx

---

<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:** [October 20, 2019, 6:02pm UTC](https://discuss.elastic.co/t/change-type-field-in-logstash/204368/2 "2019-10-20T18:02:27Z")

</div>

> [@Mohammad\_Mousavi](#):
>
> %{NUMBER:bytes}

You can convert that in grok using

```
%{NUMBER:bytes:int}

```

However, since you have already indexed that field as text elasticsearch will convert int to text as it is indexed. You will need to re-index.

---

<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:** [November 17, 2019, 6:02pm UTC](https://discuss.elastic.co/t/change-type-field-in-logstash/204368/3 "2019-11-17T18:02:28Z")

</div>

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