Logstash: Can't generate new event in custom filter using ruby


(Jay Dabhi) #1

0
down vote
favorite
I am designing the my custom log-stash filter using the ruby.This filter generates the event after certain period.I am generating the new event from the thread.Following is the my code of the thread function which is producing the event.

public
def timer_thread()
while 1
sleep(2)
keys = @dict.keys
keys.each { |key|
@dict[key][1] = @dict[key][1] - 2
if @dict[key][1] < 0
message = "No repsonse for the UE number: " + key
@dict.delete(key)
@logger.info(message)
e = LogStash::Event.new()
e.set("Notification",message)
yield e if block_given?
end
}

 end

end
As you can see I am creating the new event and emitting it.But in my output I can only see the log message not my event. What is wrong? Please help me out


(Magnus B├Ąck) #2

Only filter() can use yield to produce a new message. I don't know OTOH how to inject new events from background threads invoked from filters.


(Jay Dabhi) #3

I am able to solve my problem using flush() method.This method will be called by logstash after every 5 sec.From flush() method we can generate the event.


(system) #4

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