fluentd插件hbase修改笔记

工作中需要采集日志到hbase中,fluentd提供了插件fluentd-hbase,地址为https://github.com/Furyu/fluent-plugin-hbase

不过插件只支持固定表插入数据,而工作中需求是根据日志中接口名动态创建表,对应接口插入数据,hbase中的timestamp需要使用20120522151215格式,需要对hbase插件进行二次开发,动态表创建插入数据很容易实现,修改插件中的write函数即可,timestamp格式因为没有找到函数接口,只好修改thrift接口函数

hbase插件使用的是massive_record对hbase进行操作,因此找到该操作中的row.save函数进行修改

vim  /usr/lib64/fluent/ruby/lib/ruby/gems/1.9.1/gems/massive_record-0.2.2/lib/massive_record/adapters/thrift/row.rb

修改attr_accessor :id, :column_families, :columns, :new_record, :table 为

attr_accessor :id, :column_families, :columns, :new_record, :table ,:timestamp

修改 @table.client.mutateRow(@table.name, id.to_s.dup.force_encoding(Encoding::BINARY), mutations).nil?

if @timestamp.nil?
          @table.client.mutateRow(@table.name, id.to_s.dup.force_encoding(Encoding::BINARY), mutations).nil?
          else
          @table.client.mutateRowTs(@table.name, id.to_s.dup.force_encoding(Encoding::BINARY), mutations,@timestamp).nil?

即可。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值