# How to iterate over all fields with new Event API

**URL:** https://discuss.elastic.co/t/how-to-iterate-over-all-fields-with-new-event-api/112514
**Category:** Logstash
**Created:** [December 19, 2017, 10:08pm UTC](https://discuss.elastic.co/t/how-to-iterate-over-all-fields-with-new-event-api/112514 "2017-12-19T22:08:38Z")
**Posts on this page:** 3
**Page:** 1

<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: [December 19, 2017, 10:08pm UTC](https://discuss.elastic.co/t/how-to-iterate-over-all-fields-with-new-event-api/112514/1 "2017-12-19T22:08:38Z")

</div>

With the new Event API that provides getter and setter and hides the hash, how do I iterate over all the fields in a ruby filter in logstash?

Stuff like .each and .values appear not to work (not surprising if it is no longer a hash).

---

<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: [December 20, 2017, 4:50am UTC](https://discuss.elastic.co/t/how-to-iterate-over-all-fields-with-new-event-api/112514/2 "2017-12-20T04:50:16Z")

</div>

Use `event.to_hash` to get a hash you can iterate over.

---

<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: [January 17, 2018, 4:50am UTC](https://discuss.elastic.co/t/how-to-iterate-over-all-fields-with-new-event-api/112514/3 "2018-01-17T04:50:26Z")

</div>

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