# Ruby hash to fields of an event

**URL:** <https://discuss.elastic.co/t/ruby-hash-to-fields-of-an-event/280102>\
**Category:** Logstash\
**Created:** [July 30, 2021, 8:06pm UTC](https://discuss.elastic.co/t/ruby-hash-to-fields-of-an-event/280102 "2021-07-30T20:06:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ElasticLiver](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elasticliver/32/64869_2.png) [@ElasticLiver](https://discuss.elastic.co/u/ElasticLiver)\
**Post date:** [July 30, 2021, 8:06pm UTC](https://discuss.elastic.co/t/ruby-hash-to-fields-of-an-event/280102/1 "2021-07-30T20:06:38Z")

</div>

Hi I got the following ruby hash after parsing a long string with ruby code,

```auto
 { "mfemve"=>"0,39 ", "vmtoolsd"=>"0,39 ", "zabbix_agentd"=>"0,39 ", "powershell"=>"0,39 ", "ir_agent"=>"0,00 ", "wmiprvse"=>"0,00 ", "unsecapp"=>"0,00 ", "ccmexec"=>"0,00 ", "searchindexer"=>"0,00 "}

```

now I need to set those key and value pairs as fields and value to be indexed in elastic, so the field mfemve will have a value of 0,39, the field vmtoolsd will have a value of 0,39, and so on.

how can I do this?

---

<div class="post-metadata">

**Author:** ![Cad](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cad/32/86661_2.png) [@Cad](https://discuss.elastic.co/u/Cad)\
**Post date:** [July 30, 2021, 10:03pm UTC](https://discuss.elastic.co/t/ruby-hash-to-fields-of-an-event/280102/2 "2021-07-30T22:03:53Z")

</div>

Hi,

Something like this i think.

```auto
#Here I suppose that you have only simple values (non array for exemple)
code => 
"
hash.each { |key, value|
  event.set(key, value); 
}
"

```

---

<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:** [August 27, 2021, 10:04pm UTC](https://discuss.elastic.co/t/ruby-hash-to-fields-of-an-event/280102/3 "2021-08-27T22:04:44Z")

</div>

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