# Logstash remove unwanted fields

**URL:** <https://discuss.elastic.co/t/logstash-remove-unwanted-fields/116805>\
**Category:** Logstash\
**Created:** [January 24, 2018, 6:13am UTC](https://discuss.elastic.co/t/logstash-remove-unwanted-fields/116805 "2018-01-24T06:13:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![saikrishnagaddipati](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@saikrishnagaddipati](https://discuss.elastic.co/u/saikrishnagaddipati)\
**Post date:** [January 24, 2018, 6:13am UTC](https://discuss.elastic.co/t/logstash-remove-unwanted-fields/116805/1 "2018-01-24T06:13:15Z")

</div>

I am using logstaah 5.6.4  
I am trying to parse the below message field in logstash and add a field "error\_code" but logstash adds all the fields(bytes, syslog\_hostname, method, method2). How to configure logstash to stop adding the unwanted fields?  
message: 1332414 Backup hgnmowi88-ben Done 0 16142082 idk-dev-db Prod-Differential hqidwinfmd03-ben

and my logstash confi is below

if [type] == "hostup" {  
grok {  
match =\> { "message" =\> "%{NUMBER:bytes}\s\*%{WORD:method}\s\*%{SYSLOGHOST:syslog\_hostname}\s\*%{WORD:method2}\s\*%{INT:number}\s\*%{INT:number2}\s\*%{USERNAME:user\_id}\s\*%{SYSLOGHOST:syslog\_hostname2}"}  
add\_field =\> { "error\_code" =\> "%{number}"}  
}  
}

---

<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:** [January 25, 2018, 9:08pm UTC](https://discuss.elastic.co/t/logstash-remove-unwanted-fields/116805/2 "2018-01-25T21:08:27Z")

</div>

To match and capture into a field use `%{PATTERN:field}`. To match without capturing into a field use `%{PATTERN}`.

> add\_field =\> { "error\_code" =\> "%{number}"}

Remove this line and replace `%{INT:number}` with `%{INT:error_code}`.

---

<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:** [February 22, 2018, 9:08pm UTC](https://discuss.elastic.co/t/logstash-remove-unwanted-fields/116805/3 "2018-02-22T21:08:35Z")

</div>

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