flume 用avro 连接多个agent ,拦截器

一、flume 用avro 连接多个agent

1.

2.配置文件

agent 1: source exec / sink avro
agent2 : source avro / sink logger

 3.启动 (先启动第一个,再启动第二个)

 

 

 4.echo入数据 ,根据你配置的路径(tail -F 。。。。)

 5.结果

 二、拦截器

1.头部加入时间戳,ip,自定义键值对

2.用 telnet 写入

三、

 

 1.发现  以hello 开头的  替换为 nihao

也是用 telnet 写入

2.过滤  以hello打头的语句

 regex_filter 默认是匹配上了才通过, 匹配不上则过滤掉。所以刚才上课时,没有再logger中显示是正确的: 因为没有以 Hello 打头,则没匹配上,所以没显示

如果要相反的逻辑,则要增加一个配置: 将  excludeEvents 配置为 true

3.

 

 h1 h2 h3 为 key

为value

 

 ---------------

search_replace:将括号中的密码替换为6个 ******
hello wolrd!
My password for phone is (pass:778899)

 -----------------------

regex_extractor : 将[] 中的名字放在head 里, name=>hsq
my name is [hsq]

 

 正则表达式的语法加强学习 , 可以参考 https://www.runoob.com/regexp/regexp-syntax.html

猜你喜欢

转载自www.cnblogs.com/zbf-1998/p/12666093.html