# Filter Ruby configuration Error

**URL:** <https://discuss.elastic.co/t/filter-ruby-configuration-error/115996>\
**Category:** Logstash\
**Created:** [January 18, 2018, 8:30am UTC](https://discuss.elastic.co/t/filter-ruby-configuration-error/115996 "2018-01-18T08:30:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![moriol](https://avatars.discourse-cdn.com/v4/letter/m/439d5e/32.png) [@moriol](https://discuss.elastic.co/u/moriol)\
**Post date:** [January 18, 2018, 8:30am UTC](https://discuss.elastic.co/t/filter-ruby-configuration-error/115996/1 "2018-01-18T08:30:10Z")

</div>

I have data that is coming in via Logstash with ActiveMQ bus that looks like this:  
"DataType1" =\> {  
"system:subsystem123" =\> [  
[0] {"field": "test}],  
"system:subsystem234" =\> [  
[0] { "field": "test"}],  
"system:subsystem837" =\> [  
[0] { "field": "test"}],  
etc.

I am trying to extract data from DataType1. I want to move the contents of the array  
[[0] { "field": "test"}], one level up to be on the same level as "system:subsystem123"  
My output should look like:  
{ "DataType1": [  
{  
"system:\_subsystem": system101:subsystem123",  
"field: test"  
}

I have the following ruby:  
ruby {  
code =\>  
"event.get('DataType1').each { |e|  
h = {}  
h['system\_subsystem'] = e.first  
h.merge! e[1][0]  
event.set([DataType1']) \<\< h  
}"  
}  
I am getting the following error:  
Ruby exception occurred: wrong number of arguments calling `set` (1 for 2)

Any advice?

---

<div class="post-metadata">

**Author:** ![paz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paz/32/28003_2.png) [@paz](https://discuss.elastic.co/u/paz)\
**Post date:** [January 18, 2018, 11:27am UTC](https://discuss.elastic.co/t/filter-ruby-configuration-error/115996/2 "2018-01-18T11:27:31Z")

</div>

_event.set_ takes 2 arguments, the field which it refers and the value to change that field to.  
If you want to append values on each iteration, you could try something like this (untested)

```auto
ruby {
    code => "
        event.get('DataType1').each { |e|
            h = {}
            h['system_subsystem'] = e.first
            h.merge! e[1][0]
            event.set('DataType1', event.get('DataType1') + [h])}
   "
}
```

---

<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 15, 2018, 11:27am UTC](https://discuss.elastic.co/t/filter-ruby-configuration-error/115996/3 "2018-02-15T11:27:35Z")

</div>

Closed on February 15, 2018, 11:27am UTC

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