flume采集多个文件夹日志

    技术2022-07-11  101

    在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
    Processed: 0.009, SQL: 9