logstash-output-jdbc使用

项目需要,使用logstash定时读取log文件,并插入mysql数据库中,output使用logstash-output-jdbc插件。该插件不是默认安装的,需要使用命令:bin/logstash-plugin install logstash-output-jdbc去官方拉取。在不联网的电脑上,这种方法就不可行了,解决:在可联网的电脑安装完这个插件后,把整个logstash文件夹拷贝到无法联网的电脑。

jdbc插件依赖mysql-connector-java-5.1.41-bin.jar包,下载后放到任一目录下,并在output里写明

output{

jabc{

driver_jar_path => "jar报完整路径"

driver_class => "com.mysql.jdbc.Driver"

connection_string => "jdbc:mysql://ip:3306//DBName?autoReconnect=true&usrSSL=true&user=username&password=pwd"

statement => ["insert into table(column1,column2) values(?,?)","%{[message][1]}","%{[message][2]}"]

}

}

(拷贝后,运行bin/logstash -f test.conf时可能提示注册插件失败,再次运行bin/logstash-plugin install --no-verify logstash-output-jdbc偶尔可以解决该问题,暂不明原因)

 注:logstash版本为5.2.2,需要jdk1.8。

 

参考

https://github.com/theangryangel/logstash-output-jdbc

https://www.elastic.co/guide/en/logstash/current/index.html

转载于:https://www.cnblogs.com/ttssrs/p/6648203.html

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值