# Make Grok filter fields aggregatable

**URL:** <https://discuss.elastic.co/t/make-grok-filter-fields-aggregatable/137345>\
**Category:** Logstash\
**Created:** [June 26, 2018, 4:03am UTC](https://discuss.elastic.co/t/make-grok-filter-fields-aggregatable/137345 "2018-06-26T04:03:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bobbytan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bobbytan/32/32720_2.png) [@bobbytan](https://discuss.elastic.co/u/bobbytan)\
**Post date:** [June 26, 2018, 4:03am UTC](https://discuss.elastic.co/t/make-grok-filter-fields-aggregatable/137345/1 "2018-06-26T04:03:29Z")

</div>

Hello,

I have succesfully filtered out fields needed from logs by using GROK.The data within these field shown in stdout are correct,however these fields(error code &loglevel) are not aggregatable in kibana.How do I change this?

 ![Capture](https://us1.discourse-cdn.com/elastic/original/3X/2/6/26aa4519f5c73a53f028e025486f6907b6f6c37e.PNG)

**Config file:**  
input {

file {  
path =\> "C:\Users\bob\Downloads\data\error\_test.txt"  
start\_position =\>"beginning"  
sincedb\_path =\> "/dev/null"

```
}

```

}

filter {  
grok{  
match =\> ["message", "%{TIMESTAMP\_ISO8601:logdate} %{LOGLEVEL:loglevel} %{GREEDYDATA:messsage} %{WORD:YO}%{GREEDYDATA:messsages} %{INT:errorcode}\r"]  
}  
date {  
match =\> ["logdate", "yyyy-MM-dd HH:mm:ss,SSS", "ISO8601"]  
}

}

output{  
elasticsearch {  
hosts =\> ["localhost:9200"]  
index=\> "error\_test"

}  
stdout { codec =\> rubydebug }  
}

---

<div class="post-metadata">

**Author:** ![bobbytan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bobbytan/32/32720_2.png) [@bobbytan](https://discuss.elastic.co/u/bobbytan)\
**Post date:** [June 26, 2018, 4:05am UTC](https://discuss.elastic.co/t/make-grok-filter-fields-aggregatable/137345/2 "2018-06-26T04:05:13Z")

</div>

have tried using:  
**mutate{convert =\> ["errorcode","integer"]}**

it does not work either

---

<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:** [June 26, 2018, 6:43am UTC](https://discuss.elastic.co/t/make-grok-filter-fields-aggregatable/137345/3 "2018-06-26T06:43:52Z")

</div>

Logstash's default index template (which applies to indexes matching logstash-\*) provides .keyword subfields that can be used for aggregations. Alternatively, define your own index template where you force fields to be of a certain type.

> have tried using:  
> mutate{convert =\> ["errorcode","integer"]}

This'll convert the type of the field in a document but you need to reindex your data to change the field's mapping in the index. If you're just testing things out you can simply delete your index.

---

<div class="post-metadata">

**Author:** ![bobbytan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bobbytan/32/32720_2.png) [@bobbytan](https://discuss.elastic.co/u/bobbytan)\
**Post date:** [June 26, 2018, 7:02am UTC](https://discuss.elastic.co/t/make-grok-filter-fields-aggregatable/137345/4 "2018-06-26T07:02:47Z")

</div>

Thank You for the response.I tried refreshing field list within the management tab in kibana and this seems to solve the issue.

---

<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 24, 2018, 7:02am UTC](https://discuss.elastic.co/t/make-grok-filter-fields-aggregatable/137345/5 "2018-07-24T07:02:51Z")

</div>

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