分享

flume syslog to hdfs 如何给信息添加时间

grinsky 发表于 2016-6-22 16:24:33 [显示全部楼层] 回帖奖励 阅读模式 关闭右栏 1 6954
使用flume从rsyslog tcp 收信息,写入到hdfs中。
flume的配置如下:
[mw_shl_code=xml,true]# Please paste flume.conf here. Example:
# Sources, channels, and sinks are defined per
# agent name, in this case 'tier1'.
tier1.sources  = source1
tier1.channels = channel1
tier1.sinks    = sink1
# For each source, channel, and sink, set
# standard properties.
tier1.sources.source1.type     =  syslogtcp
tier1.sources.source1.host     = 0.0.0.0
tier1.sources.source1.port     = 5140
tier1.sources.source1.channels = channel1
tier1.channels.channel1.type   = memory
tier1.sinks.sink1.type         = hdfs
tier1.sinks.sink1.hdfs.path         = hdfs://hadoop1:8020/flume/123syslog/%y-%m-%d/
tier1.sinks.sink1.hdfs.rollInterval  = 1800
tier1.sinks.sink1.hdfs.rollSize   = 10240
tier1.sinks.sink1.hdfs.kerberosPrincipal = flume/hadoop1@ATM.COM
tier1.sinks.sink1.hdfs.kerberosKeytab = /etc/flume-ng/conf/flume.keytab
tier1.sinks.sink1.hdfs.fileType = DataStream
tier1.sinks.sink1.hdfs.fileSuffix = .log
tier1.sinks.sink1.channel      = channel1
# Other properties are specific to each type of
# source, channel, or sink. In this case, we
# specify the capacity of the memory channel.
tier1.channels.channel1.capacity = 100[/mw_shl_code]

在hdsf是有消息成功写入,收到的消息内容如下:
[mw_shl_code=applescript,true]CROND[24708]: (root) CMD (/opt/yunv/ip.deny/denyip.sh)
CROND[25028]: (root) CMD (/opt/yunv/ip.deny/denyip.sh)
CROND[25426]: (root) CMD (/opt/yunv/ip.deny/denyip.sh)
CROND[25776]: (root) CMD (/opt/yunv/ip.deny/denyip.sh)
CROND[26164]: (root) CMD (/opt/yunv/ip.deny/denyip.sh)
CROND[26485]: (root) CMD (/opt/yunv/ip.deny/denyip.sh)
CROND[26870]: (root) CMD (/opt/yunv/ip.deny/denyip.sh)
CROND[27193]: (root) CMD (/opt/yunv/ip.deny/denyip.sh)
CROND[27194]: (root) CMD (/usr/lib64/sa/sa1 1 1)
CROND[27620]: (root) CMD (/opt/yunv/ip.deny/denyip.sh)[/mw_shl_code]

但却没有时间啊,如何给每一条消息前加上时间呢?或者要在rsyslog怎么配置,让发送的消息带有时间?
我的rsyslog.conf就在最后加了一行 @@hadoop1:5140  
其他的都是默认的。
有知道的麻烦帮下。

已有(1)人评论

跳转到指定楼层
tntzbzc 发表于 2016-6-22 17:37:44
每太看懂楼主的意思,对于flume,如果想加时间戳,可以采用下面形式
。。.sinks.k1.hdfs.useLocalTimeStamp=true


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条