logstash java插件_Logstash自定义输入插件来调用java类(Logstash custom input plugin to call java class)...

I have written a custom filter plugin for logstash to call a java class.

Requirement:

Input plugin: read from queue

Custom plugin: For each message in queue call the java class

**Code:**

# encoding: utf-8

require "logstash/filters/base"

require "logstash/namespace"

require "java"

require "test.jar"

class LogStash::Filters::Example < LogStash::Filters::Base

config_name "example"

public

def register

end # def register

public

def filter(event)

object = Java::Com.test.Test.new

a = object.readMessage(event.get("message"))

event.set("message",a)

filter_matched(event)

end # def filter

end # class LogStash::Filters::Example

Problem: Is there a way that I can instantiate the java class just once? For every message that i read from the queue i do not want to create a new instance of the java class, but rather instantiate it during logstash startup and use the same object for all incoming messages.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值