目录
一、Flume拦截器(interceptor)介绍
拦截器是简单的插件式组件,设置在source和channel之间。source接收到的事件event,在写入channel之前,拦截器都可以进行转换或者删除这些事件。每个拦截器只处理同一个source接收到的事件。可以自定义拦截器。
二、Flume内置的拦截器
1、时间戳拦截器
flume中一个最经常使用的拦截器 ,该拦截器的作用是将时间戳插入到flume的事件event报头中。如果不使用任何拦截器,flume接受到的只有message。时间戳拦截器的配置:
参数 |
默认值 |
描述 |
type |
timestamp |
类型名称timestamp,也可以使用类名的全路径org.apache.flume.interceptor.TimestampInterceptor$Builder |
preserveExisting |
false |
如果设置为true,若事件中报头已经存在,不会替换时间戳报头的值 |
source连接到时间戳拦截器的配置:
a1.sources.r1.interceptors=i1
a1.sources.r1.interceptors.i1.type=timestamp
a1.sources.r1.interceptors.i1.preserveExisting=false
2、主机拦截器
主机拦截器插入服务器的ip地址或者主机名,agent将这些内容插入到事件的报头中。事件报头中的key使用hostHeader配置,默认是host。主机拦截器的配置:
参数 |
默认值 |
描述 |
type |
host |
类型名称host,也可以使用类名的全路径org.apache.flume.interceptor.HostInterceptor$Builder |
hostHeader |
host |
事件头的key |
useIP |
true |
如果设置为false,host键插入主机名 |
p |