# Filtering all Fields/Events

**URL:** https://discuss.elastic.co/t/filtering-all-fields-events/254088
**Category:** Logstash
**Created:** [November 3, 2020, 1:31am UTC](https://discuss.elastic.co/t/filtering-all-fields-events/254088 "2020-11-03T01:31:40Z")
**Posts on this page:** 1
**Showing post:** 2

<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 3, 2020, 2:21am UTC](https://discuss.elastic.co/t/filtering-all-fields-events/254088/2 "2020-11-03T02:21:55Z")

</div>

If you need to iterate over all the fields in an event, including the contents of hashes and arrays, then [this](https://discuss.elastic.co/t/to-exclude-around-350-fields-in-json-in-logstash/239019/6) may give you some ideas.

You probably do not need to do it as a ruby script, I expect it could be rewriten it as a ruby filter that uses the code option rather than the path option to get the code from a file.

Writing a regexp to match any email address that is "valid" is a really tough problem. There are valid domains that contain characters from non-English scripts such as Chinese or Cyrillic. Of course a lot of email programs will not handle such addresses even though they follow the "rules". So exotic email addresses may be "valid" but unusable.

For PII masking I would lean to being inclusive and masking things that may not be emails. [This](https://www.regular-expressions.info/email.html) page discusses some of the options for being more or less inclusive.

Personally I would lean towards using a POSIX class like [[:alnum:]] instead of [A-Za-z0-9]

---

_[View the full topic](https://discuss.elastic.co/t/filtering-all-fields-events/254088)._
