# Removing specific fields

**URL:** https://discuss.elastic.co/t/removing-specific-fields/130013
**Category:** Logstash
**Created:** [April 30, 2018, 10:43am UTC](https://discuss.elastic.co/t/removing-specific-fields/130013 "2018-04-30T10:43:47Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Nikolay\_Petrov](https://avatars.discourse-cdn.com/v4/letter/n/4af34b/32.png) [@Nikolay\_Petrov](https://discuss.elastic.co/u/Nikolay_Petrov)
#### Post date: [April 30, 2018, 10:43am UTC](https://discuss.elastic.co/t/removing-specific-fields/130013/1 "2018-04-30T10:43:48Z")

</div>

Hi,  
I'm trying to remove fields like this "\*\_bytes" using logstash filter, without any success so far:

> {  
> ...  
> "mountpoints": {  
> "/soft": {  
> "size\_bytes": "21003628544",  
> "available\_bytes": "20957556736",  
> "used\_bytes": "46071808",  
> },  
> "/dev/shm": {  
> "size\_bytes": "521474048",  
> "available\_bytes": "521474048",  
> "used\_bytes": "0",  
> },  
> "/": {  
> "size\_bytes": "8319852544",  
> "available\_bytes": "5288181760",  
> "used\_bytes": "3031670784",  
> }  
> },  
> "disks": {  
> "xvdb": {  
> "size\_bytes": "21474836480"  
> },  
> "xvda": {  
> "size\_bytes": "8589934592"  
> }  
> },  
> "partitions": {  
> "/dev/xvda1": {  
> "size\_bytes": "8588886016",  
> }  
> },  
> ...  
> }

my logstash logstash filter:

> ...  
> ruby {  
> code =\> "  
> event.to\_hash.keys.each { |k|  
> if k.end\_with?('bytes')  
> event.remove(k)  
> end  
> }  
> "  
> }
> 
> ```
> prune {
> interpolate => true
> blacklist_names => ["^.*bytes$", "&{}>;,", "[^.*][.*][.*_bytes$]" ]
> }
> 
> mutate {
> remove_field => [".*bytes", "^.*[.*bytes]$" ]
> }
> 
> ```
> 
> ...  
> i'm not sure what i missed into the regexp or any other filter that can be used.

---

<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: [April 30, 2018, 6:27pm UTC](https://discuss.elastic.co/t/removing-specific-fields/130013/2 "2018-04-30T18:27:35Z")

</div>

The prune filter doesn't work with nested fields ([https://github.com/logstash-plugins/logstash-filter-prune/issues/12](https://github.com/logstash-plugins/logstash-filter-prune/issues/12)) and your ruby snippet only processes the keys at the top level of the event. You'd have to write Ruby code that recurses into the subhashes. I don't have time to provide an example of that, but since it's not a Logstash-specific problem I imagine you'll find a solution at e.g. StackOverflow.

---

<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: [May 28, 2018, 6:27pm UTC](https://discuss.elastic.co/t/removing-specific-fields/130013/3 "2018-05-28T18:27:43Z")

</div>

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