flume 拦截器(interceptor)

flume内置了很多拦截器,并且会定期的添加一些拦截器,在这里列出一些flume内置的,经常使用的拦截器。

  1. 时间戳拦截器

    flume中一个最经常使用的拦截器 ,该拦截器的作用是将时间戳插入到flume的事件报头中。如果不使用任何拦截器,flume接受到的只有message。时间戳拦截器的配置。

参数默认值描述
type
类型名称timestamp,也可以使用类名的全路径
preserveExistingfalse如果设置为true,若事件中报头已经存在,不会替换时间戳报头的值

source连接到时间戳拦截器的配置:

a1.sources.r1.interceptors = timestamp
a1.sources.r1.interceptors.timestamp.type=timestamp
a1.sources.r1.interceptors.timestamp.preserveExisting=false

 2.  主机拦截器

        主机拦截器插入服务器的ip地址或者主机名,agent将这些内容插入到事件的报头中。时间报头中的key使用hostHeader配置,默认是host。主机拦截器的配置

参数默认值描述
type
类型名称host
hostHeaderhost事件投的key
useIPtrue如果设置为false,host键插入主机名
preserveExistingfalse如果设置为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.  静态拦截器

    静态拦截器的作用是将k/v插入到事件的报头中。配置如下

参数默认值描述
type

类型名称static
keykey事件头的key
valuevaluekey对应的value值
preserveExistingtrue如果设置为true,若事件中报头已经存在该key,不会替换value的值

source连接到静态拦截器的配置:

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”之外的任何个字符
excludeEventsfalse
默认收集匹配到的事件。如果为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的日志。

转载于:https://my.oschina.net/u/2311010/blog/531241

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值