flume攔截器-時間戳攔截器

0.功能作用:

將時間戳放到event的header(Map<key,value>)

1.Timestamp.conf
#1.定義agent名, source、channel、sink的名稱
a4.sources = r1
a4.channels = c1
a4.sinks = k1

#2.具體定義source
a4.sources.r1.type = spooldir
a4.sources.r1.spoolDir = /opt/module/flume-1.8.0/upload

#定義攔截器,爲文件最後添加時間戳
a4.sources.r1.interceptors = timestamp
a4.sources.r1.interceptors.timestamp.type = org.apache.flume.interceptor.TimestampInterceptor$Builder

#具體定義channel
a4.channels.c1.type = memory
a4.channels.c1.capacity = 10000
a4.channels.c1.transactionCapacity = 100


#具體定義sink
a4.sinks.k1.type = hdfs
a4.sinks.k1.hdfs.path = hdfs://hadoop2:9000/flume-interceptors/%H
a4.sinks.k1.hdfs.filePrefix = events-
a4.sinks.k1.hdfs.fileType = DataStream

#不按照條數生成文件
a4.sinks.k1.hdfs.rollCount = 0
#HDFS上的文件達到128M時生成一個文件
a4.sinks.k1.hdfs.rollSize = 134217728
#HDFS上的文件達到60秒生成一個文件
a4.sinks.k1.hdfs.rollInterval = 60

#組裝source、channel、sink
a4.sources.r1.channels = c1
a4.sinks.k1.channel = c1
2.啓動命令:
bin/flume-ng agent -c conf/ -f jobconf/uuid.conf -n a4 -Dflume.root.logger==INFO,console
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章