# Removing fields using mutate (JSON)

**URL:** https://discuss.elastic.co/t/removing-fields-using-mutate-json/60144
**Category:** Logstash
**Created:** [September 9, 2016, 9:05am UTC](https://discuss.elastic.co/t/removing-fields-using-mutate-json/60144 "2016-09-09T09:05:56Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![dsever](https://avatars.discourse-cdn.com/v4/letter/d/91b2a8/32.png) [@dsever](https://discuss.elastic.co/u/dsever)
#### Post date: [September 9, 2016, 9:05am UTC](https://discuss.elastic.co/t/removing-fields-using-mutate-json/60144/1 "2016-09-09T09:05:56Z")

</div>

Hi,

While parsing some json logs I'm getting into problem with unavailability to remove one subfield,  
for instance this is my JSON

"alert": [ { "src": { "url": "xxxx",  
"domain": "xxxx",  
"smtp-mail-from": "xxxxxxxx"  
},  
"severity": "xxxx",  
"dst": { "smtp-to": "xxxxx"  
},  
"explanation": {  
"protocol": "",  
"service": "xxxxxx",  
"analysis": "binary",  
"os-changes": [ {XXXXXXX

Using  
remove\_field =\> ["json","message","[alert][explanation]] i can successfully remove til the field explanation but it cuts to much, so I need to cut it as os-changes as last filed.

But I get stuck into problem that buttom example doesn't cut os-changes

remove\_field =\> ["json","message","[alert][explanation][os-changes]"]

Thanks  
Dubravko

---

<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: [September 9, 2016, 9:22am UTC](https://discuss.elastic.co/t/removing-fields-using-mutate-json/60144/2 "2016-09-09T09:22:34Z")

</div>

So you want to remove the `os-changes` subfield? It would be more obvious if you showed us what you want the resulting event to look like.

---

<div class="post-metadata">

### Author: ![dsever](https://avatars.discourse-cdn.com/v4/letter/d/91b2a8/32.png) [@dsever](https://discuss.elastic.co/u/dsever)
#### Post date: [September 9, 2016, 10:47am UTC](https://discuss.elastic.co/t/removing-fields-using-mutate-json/60144/3 "2016-09-09T10:47:34Z")

</div>

Hi,

Hi just want to remove fileld os-changes

"alert": [ { "src":  
{ "url": "xxxx",  
"domain": "xxxx",  
"smtp-mail-from": "xxxxxxxx"  
},  
"severity": "xxxx",  
"dst": { "smtp-to": "xxxxx"  
},  
"explanation": {  
"protocol": "",  
"service": "xxxxxx",  
"analysis": "binary",  
"os-changes": [{XXXXXXX }] # and want to remove all included in os-changes array, because i contains a lots of data that is only overhead to our system, it should be simple 🙂  
}

}  
]

I suppose syntax would be  
remove\_field =\> ["json","message","[alert][explanation][os-changes]"]

but for some reason it doesn't work, I'm still getting filed os-changes and its subfields.  
Dubravko

---

<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: [September 9, 2016, 10:50am UTC](https://discuss.elastic.co/t/removing-fields-using-mutate-json/60144/4 "2016-09-09T10:50:51Z")

</div>

Okay. `alert` is an array so you need `[alert][0][explanation][os-changes]` to access the first element of it

---

<div class="post-metadata">

### Author: ![dsever](https://avatars.discourse-cdn.com/v4/letter/d/91b2a8/32.png) [@dsever](https://discuss.elastic.co/u/dsever)
#### Post date: [September 9, 2016, 10:56am UTC](https://discuss.elastic.co/t/removing-fields-using-mutate-json/60144/5 "2016-09-09T10:56:54Z")

</div>

So simple 🙂  
Thanks, it works

---

<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:39am UTC](https://discuss.elastic.co/t/removing-fields-using-mutate-json/60144/6 "2017-07-06T04:39:06Z")

</div>


