# Prune filter plugin - How whitelist a nested field?

**URL:** <https://discuss.elastic.co/t/prune-filter-plugin-how-whitelist-a-nested-field/255720>\
**Category:** Logstash\
**Created:** [November 17, 2020, 2:53pm UTC](https://discuss.elastic.co/t/prune-filter-plugin-how-whitelist-a-nested-field/255720 "2020-11-17T14:53:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![21908](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/21908/32/77808_2.png) [@21908](https://discuss.elastic.co/u/21908)\
**Post date:** [November 17, 2020, 2:53pm UTC](https://discuss.elastic.co/t/prune-filter-plugin-how-whitelist-a-nested-field/255720/1 "2020-11-17T14:53:04Z")

</div>

Documentation at

> **[Prune filter plugin | Logstash Reference \[7.10\] | Elastic](https://www.elastic.co/guide/en/logstash/current/plugins-filters-prune.html)**

has this example and it mentions that it would allow only `"msg"` through.

```auto
filter {
      prune {
        whitelist_names => ["^msg$"]
      }
    }

```

If I have a single record that has

```auto
    "source" => {
        "bytes" => 172,
           "ip" => "192.168.56.105",
         "port" => 38996
    },
    .....
    "server" => {
        "bytes" => 2400,
           "ip" => "192.168.56.102",
         "port" => 9200
    },

```

Notice how both have the "ip" field. How would I go about only sending source.ip through?

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [November 17, 2020, 3:03pm UTC](https://discuss.elastic.co/t/prune-filter-plugin-how-whitelist-a-nested-field/255720/2 "2020-11-17T15:03:11Z")

</div>

Try to use the following format:

```auto
      prune {
        whitelist_names => ["[source][ip]"]
      }

```

---

<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:** [November 17, 2020, 3:09pm UTC](https://discuss.elastic.co/t/prune-filter-plugin-how-whitelist-a-nested-field/255720/3 "2020-11-17T15:09:30Z")

</div>

> [@21908](#):
>
> How would I go about only sending source.ip through?

You cannot do that using a prune filter.

> This filter currently only support operations on top-level fields, i.e. whitelisting and blacklisting of subfields based on name or value does not work.

You could do it in a ruby filter.

---

<div class="post-metadata">

**Author:** ![21908](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/21908/32/77808_2.png) [@21908](https://discuss.elastic.co/u/21908)\
**Post date:** [November 17, 2020, 3:16pm UTC](https://discuss.elastic.co/t/prune-filter-plugin-how-whitelist-a-nested-field/255720/4 "2020-11-17T15:16:14Z")

</div>

Thank you, I'm checking out this filter now. Any chance you have an example or a webpage example that you could direct me too?

---

<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:** [December 15, 2020, 3:16pm UTC](https://discuss.elastic.co/t/prune-filter-plugin-how-whitelist-a-nested-field/255720/5 "2020-12-15T15:16:23Z")

</div>

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