flume拦截器可以修改或者删除事件,flume还支持连接器链,事件可以经过一系列拦截器。多个拦截器在配置文件中以空格分隔,拦截器的顺序就是事件处理的顺序,只有一个拦截器通过之后才会进行到下一个拦截器。
一 Timestamp Interceptor:
该拦截器会插入到事件头中,会在事件头中插入一个key是timestamp的KV对,value的值是相关的timestamp。该拦截器可以保护相关的已经存在的timestamp。可以设置以下参数:
type 该组件的名称,此处是timestamp
preserveExisting 默认值是false,如果timestamp已经存在,应该被保护
a1.sources= r1
a1.channels= c1
a1.sources.r1.channels= c1
a1.sources.r1.type= seq
a1.sources.r1.interceptors= i1
a1.sources.r1.interceptors.i1.type= timestamp
二 HostInterceptor
该拦截器会插入当前agent运行机器的hostname或者ip,插入KV对,key名称是host,可以设置以下值:
type:该组件的名称,此处是host
preserveExisting:默认值是false,如果在头部已经存在host,则应该被保护
useIP: 默认值是true,使用ip,而非hostname
hostHeader: 默认值是host,头部的key名称
三StaticInterceptor
该拦截器允许用户追加静态头部在所有事件中,可以设置以下参数
type:该组件的名称,此处是static
preserveExisting:默认值是true,如果头部已经存在,则应该被保护
key:默认值是key,头部创建的key名称
value:默认值是value,静态value值
a1.sources= r1
a1.channels= c1
a1.sources.r1.channels= c1
a1.sources.r1.type= seq
a1.sources.r1.interceptors= i1
a1.sources.r1.interceptors.i1.type= static
a1.sources.r1.interceptors.i1.key= datacenter
a1.sources.r1.interceptors.i1.value= NEW_YORK