# Logstash ruby filter in separate script throws : undefined local variable or method \`new\_event\_block' for #\<LogStash::Filt ers::Ruby::Script::ExecutionContext

**URL:** <https://discuss.elastic.co/t/logstash-ruby-filter-in-separate-script-throws-undefined-local-variable-or-method-new-event-block-for-logstash-filt-ers-executioncontext/208324>\
**Category:** Logstash\
**Created:** [November 18, 2019, 2:09pm UTC](https://discuss.elastic.co/t/logstash-ruby-filter-in-separate-script-throws-undefined-local-variable-or-method-new-event-block-for-logstash-filt-ers-executioncontext/208324 "2019-11-18T14:09:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![HansPeterSloot](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hanspetersloot/32/51132_2.png) [@HansPeterSloot](https://discuss.elastic.co/u/HansPeterSloot)\
**Post date:** [November 18, 2019, 2:09pm UTC](https://discuss.elastic.co/t/logstash-ruby-filter-in-separate-script-throws-undefined-local-variable-or-method-new-event-block-for-logstash-filt-ers-executioncontext/208324/1 "2019-11-18T14:09:55Z")

</div>

Hi,

I am migrating my inline ruby script to an external ruby script file.

First I create an new event with : service\_trace\_event = LogStash::Event.new  
After filling the fields like : service\_trace\_event.set("id",result\_set.getString(1).to\_i) ,  
I do the following call: new\_event\_block.call(service\_trace\_event)

But then I get the following error:  
undefined local variable or method `new\_event\_block' for #\<LogStash::Filt  
ers::Ruby::Script::ExecutionContext:0x681d402a\>

What am I doing wrong?

Regards Hans

---

<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 18, 2019, 2:31pm UTC](https://discuss.elastic.co/t/logstash-ruby-filter-in-separate-script-throws-undefined-local-variable-or-method-new-event-block-for-logstash-filt-ers-executioncontext/208324/2 "2019-11-18T14:31:31Z")

</div>

If you want to create new events in an external ruby script file you can use LogStash::Event.new, but then just put them in an array and return them from the script's filter function.

---

<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:** [December 16, 2019, 2:31pm UTC](https://discuss.elastic.co/t/logstash-ruby-filter-in-separate-script-throws-undefined-local-variable-or-method-new-event-block-for-logstash-filt-ers-executioncontext/208324/3 "2019-12-16T14:31:33Z")

</div>

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