# Delete attributes by value in Logstash 5.1.1

**URL:** <https://discuss.elastic.co/t/delete-attributes-by-value-in-logstash-5-1-1/71149>\
**Category:** Logstash\
**Created:** [January 10, 2017, 8:24pm UTC](https://discuss.elastic.co/t/delete-attributes-by-value-in-logstash-5-1-1/71149 "2017-01-10T20:24:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rcanzanese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rcanzanese/32/12626_2.png) [@rcanzanese](https://discuss.elastic.co/u/rcanzanese)\
**Post date:** [January 10, 2017, 8:24pm UTC](https://discuss.elastic.co/t/delete-attributes-by-value-in-logstash-5-1-1/71149/1 "2017-01-10T20:24:18Z")

</div>

We have recently upgraded from Logstash 2.2.4 to Logstash 5.1.1. Previously, we used the following to remove "-" valued attributes:

```
code => "event.to_hash.keep_if{|k,v| v != '-'}"

```

The new Event API breaks this code: [https://www.elastic.co/guide/en/logstash/5.0/breaking-changes.html#\_ruby\_filter\_and\_custom\_plugin\_developers](https://www.elastic.co/guide/en/logstash/5.0/breaking-changes.html#_ruby_filter_and_custom_plugin_developers) and leaves us looking for an alternative solution. Is there a way to achieve this same effect with the new Event API?

---

<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 10, 2017, 9:01pm UTC](https://discuss.elastic.co/t/delete-attributes-by-value-in-logstash-5-1-1/71149/2 "2017-01-10T21:01:05Z")

</div>

Just use the prune filter. Make sure to install v3.0.0 or later, released last week, to get support for the new event API.

---

<div class="post-metadata">

**Author:** ![rcanzanese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rcanzanese/32/12626_2.png) [@rcanzanese](https://discuss.elastic.co/u/rcanzanese)\
**Post date:** [January 10, 2017, 9:09pm UTC](https://discuss.elastic.co/t/delete-attributes-by-value-in-logstash-5-1-1/71149/4 "2017-01-10T21:09:17Z")

</div>

Thanks, hadn't come across that filter before.

Link for the lazy: [https://www.elastic.co/guide/en/logstash/current/plugins-filters-prune.html](https://www.elastic.co/guide/en/logstash/current/plugins-filters-prune.html)

---

<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 7, 2017, 9:09pm UTC](https://discuss.elastic.co/t/delete-attributes-by-value-in-logstash-5-1-1/71149/5 "2017-02-07T21:09:36Z")

</div>

Closed on February 7, 2017, 9:09pm UTC

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