Regex Filtering Interceptor拦截器

  • Regex Filtering Interceptor拦截器用于过滤事件,筛选出与配置的正则表达式相匹配的事件。可以用于包含事件和排除事件。常用于数据清洗,通过正则表达式把数据过滤出来。
[root@flume0 interceptors]# touch demo3-regex-filtering-hdfs.conf
# 定义 数据源(输入端) 缓冲区 输出源(输出端)
a1.sources = r1
a1.channels = c1
a1.sinks = k1

# 输入端
a1.sources.r1.type = spooldir
a1.sources.r1.spoolDir = /opt/upload
a1.sources.r1.fileSuffix = .done

# 拦截器
a1.sources.r1.interceptors = i1
a1.sources.r1.interceptors.i1.type = regex_filter
#全部都是符合条件的数据
a1.sources.r1.interceptors.i1.regex = ^.*INFO.*$
#排除符合正则表达式的数据
# a1.sources.r1.interceptors.i1.excludeEvents  = true

# 输出端
a1.sinks.k1.type = hdfs
a1.sinks.k1.hdfs.path = hdfs://flume45:9000/interceptors/%Y%m%d/%H
#是否使用本地时间戳
a1.sinks.k1.hdfs.useLocalTimeStamp = true
# 序列化
a1.sinks.k1.hdfs.fileType = DataStream 
a1.sinks.k1.hdfs.rollInterval = 0

# 使用一个在内存中缓冲事件的通道
a1.channels.c1.type = memory
# 连接通道
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1


# 运行
bin/flume-ng agent --conf conf --name a1 --conf-file job/interceptors/demo3-regex-filtering-hdfs.conf

posted @ 2020-12-08 21:56  花红  阅读(271)  评论(0)    收藏  举报