flume内置了不少拦截器,而且会按期的添加一些拦截器,在这里列出一些flume内置的,常用的拦截器。
java
时间戳拦截器服务器
flume中一个最常用的拦截器 ,该拦截器的做用是将时间戳插入到flume的事件报头中。若是不使用任何拦截器,flume接受到的只有message。时间戳拦截器的配置。spa
参数 | 默认值 | 描述 |
type | 类型名称timestamp,也能够使用类名的全路径 | |
preserveExisting | false | 若是设置为true,若事件中报头已经存在,不会替换时间戳报头的值 |
source链接到时间戳拦截器的配置:日志
a1.sources.r1.interceptors = timestamp a1.sources.r1.interceptors.timestamp.type=timestamp a1.sources.r1.interceptors.timestamp.preserveExisting=false
2. 主机拦截器
code
主机拦截器插入服务器的ip地址或者主机名,agent将这些内容插入到事件的报头中。时间报头中的key使用hostHeader配置,默认是host。主机拦截器的配置
orm
参数 | 默认值 | 描述 |
type | 类型名称host | |
hostHeader | host | 事件投的key |
useIP | true | 若是设置为false,host键插入主机名 |
preserveExisting | false | 若是设置为true,若事件中报头已经存在,不会替换host报头的值 |
source链接到主机拦截器的配置:事件
a1.sources.r1.interceptors = host a1.sources.r1.interceptors.host.type=host a1.sources.r1.interceptors.host.useIP=false a1.sources.r1.interceptors.timestamp.preserveExisting=true
3. 静态拦截器ip
静态拦截器的做用是将k/v插入到事件的报头中。配置以下
ci
参数 | 默认值 | 描述 |
type |
类型名称static | |
key | key | 事件头的key |
value | value | key对应的value值 |
preserveExisting | true | 若是设置为true,若事件中报头已经存在该key,不会替换value的值 |
source链接到静态拦截器的配置:it
a1.sources.r1.interceptors = static a1.sources.r1.interceptors.static.type=static a1.sources.r1.interceptors.static.key=logs a1.sources.r1.interceptors.static.value=logFlume a1.sources.r1.interceptors.static.preserveExisting=false
4. 正则过滤拦截器
在日志采集的时候,可能有一些数据是咱们不须要的,这样添加过滤拦截器,能够过滤掉不须要的日志,也能够根据须要收集知足正则条件的日志。
参数 | 默认值 | 描述 |
type |
类型名称REGEX_FILTER | |
regex | .* | 匹配除“\n”以外的任何个字符 |
excludeEvents | false |
默认收集匹配到的事件。若是为true,则会删除匹配到的event,收集未匹配到的。 |
source链接到正则过滤拦截器的配置:
a1.sources.r1.interceptors = regex a1.sources.r1.interceptors.regex.type=REGEX_FILTER a1.sources.r1.interceptors.regex.regex=(rm)|(kill) a1.sources.r1.interceptors.regex.excludeEvents=false
这样配置的拦截器就只会接收日志消息中带有rm 或者kill的日志。