在flume1.6版本及之前,如果想要監控多個目錄下的多個文件,可以使用Filelistener,在flume1.7之後,增加了TAILDIR,主要是監控文件的變化
參考配置:
#配置Agent a1 的組件
a1.sources=r1
a1.sinks=s1
a1.channels=c1
#描述/配置a1的source1
a1.sources.r1.type=TAILDIR
#偏移量文件
a1.sources.r1.positionFile = /opt/module/flume/data/taildir_position.json
#文件的組,可以定義多種
a1.sources.r1.filegroups = f1 f2
#第一組監控的是test1文件夾中的什麼文件:.log文件
a1.sources.r1.filegroups.f1 = /opt/module/flume/data/test1/.*log
#第二組監控的是test2文件夾中的什麼文件:以.txt結尾的文件
a1.sources.r1.filegroups.f2 = /opt/module/flume/data/test2/.*txt
#描述sink
a1.sinks.s1.type=file_roll
a1.sinks.s1.sink.directory=/home/work/rolldata
a1.sinks.s1.sink.rollInterval=0
#描述內存channel
a1.channels.c1.type=memory
a1.channels.c1.capacity=1000
a1.channels.c1.transactionCapacity=100
#位channel 綁定 source和sink
a1.sources.r1.channels=c1
a1.sinks.s1.channel=c1