# Whitelist nested field

**URL:** https://discuss.elastic.co/t/whitelist-nested-field/317773
**Category:** Logstash
**Created:** [October 31, 2022, 3:39am UTC](https://discuss.elastic.co/t/whitelist-nested-field/317773 "2022-10-31T03:39:09Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![yuswanul](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuswanul/32/101662_2.png) [@yuswanul](https://discuss.elastic.co/u/yuswanul)
#### Post date: [October 31, 2022, 3:39am UTC](https://discuss.elastic.co/t/whitelist-nested-field/317773/1 "2022-10-31T03:39:09Z")

</div>

Hi everyone,

i plan to whitelist some fields, but they are nested field. i already tried prune to whitelist them and it didn't work. for example:

> Request Body : {"tipe":"FF","nama":"ABC","nik":"","handphone":"00012","email":"","channelId":"7777","clientId":"1234"}

if i want to whitelist only channelId and clientId, how do i do that? Thanks

---

<div class="post-metadata">

### Author: ![Rios](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rios/32/95745_2.png) [@Rios](https://discuss.elastic.co/u/Rios)
#### Post date: [October 31, 2022, 6:33am UTC](https://discuss.elastic.co/t/whitelist-nested-field/317773/2 "2022-10-31T06:33:28Z")

</div>

How does it look in LS?  
If is nested like:  
"Request Body" : {"tipe":"FF","nama":"ABC","nik":"","handphone":"00012","email":"","channelId":"7777","clientId":"1234"}  
then should be like this:  
["Request Body"]["tipe"]  
["Request Body"]["nama"]  
...  
If are not nested, then is simple just "tipe"

---

<div class="post-metadata">

### Author: ![yuswanul](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuswanul/32/101662_2.png) [@yuswanul](https://discuss.elastic.co/u/yuswanul)
#### Post date: [October 31, 2022, 6:50am UTC](https://discuss.elastic.co/t/whitelist-nested-field/317773/3 "2022-10-31T06:50:42Z")

</div>

oh, sorry i forget to tell you that i have a json filter like this:

> json{  
> source =\> "requestBody"  
> target =\> "requestBody"  
> skip\_on\_invalid\_json =\> true  
> }

i tried using prune like this before but it didn't work:  
`[requestBody][channelId], [requestBody][clientId]`

is "" inside the bracket will take effect?

---

<div class="post-metadata">

### Author: ![Rios](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rios/32/95745_2.png) [@Rios](https://discuss.elastic.co/u/Rios)
#### Post date: [October 31, 2022, 6:55am UTC](https://discuss.elastic.co/t/whitelist-nested-field/317773/4 "2022-10-31T06:55:59Z")

</div>

Should be like this: [requestBody][channelId]  
If is still not working, check in ruby debugger, you might have an array like this [requestBody][0][channelId]

---

<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 31, 2022, 4:46pm UTC](https://discuss.elastic.co/t/whitelist-nested-field/317773/5 "2022-10-31T16:46:00Z")

</div>

> [@yuswanul](#):
>
> i tried using prune like this before but it didn't work:  
> `[requestBody][channelId], [requestBody][clientId]`

A prune filter only operates on top-level fields, it cannot whitelist or blacklist nested fields.

---

<div class="post-metadata">

### Author: ![Rios](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rios/32/95745_2.png) [@Rios](https://discuss.elastic.co/u/Rios)
#### Post date: [October 31, 2022, 4:53pm UTC](https://discuss.elastic.co/t/whitelist-nested-field/317773/6 "2022-10-31T16:53:07Z")

</div>

As workaround, then you can copy white list fields in another fields, and remove requestBody

` mutate { remove_field => ["requestBody"] }`

---

<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 28, 2022, 4:54pm UTC](https://discuss.elastic.co/t/whitelist-nested-field/317773/7 "2022-11-28T16:54:01Z")

</div>

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