# Never ending story: how to check and remove empty fields, arrays etc

**URL:** <https://discuss.elastic.co/t/never-ending-story-how-to-check-and-remove-empty-fields-arrays-etc/154243>\
**Category:** Logstash\
**Created:** [October 26, 2018, 5:38pm UTC](https://discuss.elastic.co/t/never-ending-story-how-to-check-and-remove-empty-fields-arrays-etc/154243 "2018-10-26T17:38:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jetnet](https://avatars.discourse-cdn.com/v4/letter/j/a87d85/32.png) [@jetnet](https://discuss.elastic.co/u/jetnet)\
**Post date:** [October 26, 2018, 5:38pm UTC](https://discuss.elastic.co/t/never-ending-story-how-to-check-and-remove-empty-fields-arrays-etc/154243/1 "2018-10-26T17:38:35Z")

</div>

[season I](https://discuss.elastic.co/t/how-can-i-check-if-the-tags-array-is-empty/27856)  
[season II](https://discuss.elastic.co/t/how-to-tell-if-tags-array-is-empty-in-ls-6/121357)  
[season III](https://discuss.elastic.co/t/how-to-check-if-a-hash-is-empty-no-keys/93227/2)

season IV (thanks to season III):

```auto
  ruby {
        # Initialize the suspects once:
        init => "SuspectFields = ['tags']"
        code => "
                SuspectFields.each do |field|
                        event.remove(field) if event.get('field').nil? or event.get('field').empty?
                end
        "
  }

```

to be continued...

---

<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 23, 2018, 5:49pm UTC](https://discuss.elastic.co/t/never-ending-story-how-to-check-and-remove-empty-fields-arrays-etc/154243/2 "2018-11-23T17:49:34Z")

</div>

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