1.概述

Flume有能力在运行阶段修改/删除Event,这是通过拦截器(Interceptors)来实现的。
拦截器需要实现org.apache.flume.interceptor.Interceptor接口。
拦截器可以修改或删除事件基于开发者在选择器中选择的任何条件。
拦截器采用了责任链模式,多个拦截器可以按指定顺序拦截。
一个拦截器返回的事件列表被传递给链中的下一个拦截器。
如果一个拦截器需要删除事件,它只需要在返回的事件集中不包含要删除的事件即可。
如果要删除所有事件,只需返回一个空列表。
 

2.Timestamp Interceptor

这个拦截器在事件头中插入以毫秒为单位的当前处理时间。
头的名字为timestamp,值为当前处理的时间戳。
如果在之前已经有这个时间戳,则保留原有的时间戳。
 
参数说明:
!type – 类型名称,必须是timestamp或自定义类的全路径名
preserveExisting false 如果时间戳已经存在是否保留
 

3.Host Interceptor

这个拦截器插入当前处理Agent的主机名或ip
头的名字为host或配置的名称
值是主机名或ip地址,基于配置。
 
参数说明:
!type – 类型名称,必须是host
preserveExisting false 如果主机名已经存在是否保留
useIP true 如果配置为true则用IP,配置为false则用主机名
hostHeader host 加入头时使用的名称
 

4.Static Interceptor

此拦截器允许用户增加静态头信息使用静态的值到所有事件。
目前的实现中不允许一次指定多个头。
如果需要增加多个静态头可以指定多个Static interceptors
属性说明:
!type – 类型,必须是static
preserveExisting true 如果配置头已经存在是否应该保留
key key 要增加的透明
value value 要增加的头值
 

5.UUID Interceptor

这个拦截器在所有事件头中增加一个全局一致性标志。
其实就是UUID。
 
属性说明:
!type – 类型名称,必须是org.apache.flume.sink.solr.morphline.UUIDInterceptor$Builder
headerName id 头名称
preserveExisting true 如果头已经存在,是否保留
prefix “” 在UUID前拼接的字符串前缀
 

6.Morphline  Interceptor

7.Search and Replace Interceptor

这个拦截器提供了简单的基于字符串的正则搜索和替换功能。
 
属性说明:
type – 类型名称,必须是"search_replace"
searchPattern – 要搜索和替换的正则表达式
replaceString – 要替换为的字符串
charset UTF-8 字符集编码,默认utf-8
 

8.Regex Filtering Interceptor

此拦截器通过解析事件体去匹配给定正则表达式来筛选事件。
所提供的正则表达式即可以用来包含或刨除事件。
 
属性说明:
!type – 类型,必须设定为regex_filter
regex ”.*” 所要匹配的正则表达式
excludeEvents false 如果是true则刨除匹配的事件,false则包含匹配的事件。
 

9.Regex Extractor Interceptor

使用指定正则表达式匹配事件,并将匹配到的组作为头加入到事件中。
它也支持插件化的序列化器用来格式化匹配到的组在加入他们作为头之前。
 
属性说明:
!type – 类型,必须是regex_extractor
!regex – 要匹配的正则表达式
!serializers – Space-separated list of serializers for mapping matches to header names and serializing their values. (See example below) Flume provides built-in support for the following serializers: org.apache.flume.interceptor.RegexExtractorInterceptorPassThroughSerializer org.apache.flume.interceptor.RegexExtractorInterceptorMillisSerializer
serializers.<s1>.type default Must be default (org.apache.flume.interceptor.RegexExtractorInterceptorPassThroughSerializer), org.apache.flume.interceptor.RegexExtractorInterceptorMillisSerializer, or the FQCN of a custom class that implements org.apache.flume.interceptor.RegexExtractorInterceptorSerializer
serializers.<s1>.name –  
serializers.* – Serializer-specific properties
 
----
If the Flume event body contained 1:2:3.4foobar5 and the following configuration was used
 
a1.sources.r1.interceptors.i1.regex = (\\d):(\\d):(\\d)
a1.sources.r1.interceptors.i1.serializers = s1 s2 s3
a1.sources.r1.interceptors.i1.serializers.s1.name = one
a1.sources.r1.interceptors.i1.serializers.s2.name = two
a1.sources.r1.interceptors.i1.serializers.s3.name = three
 
The extracted event will contain the same body but the following headers will have been added one=>1, two=>2, three=>3
----
 

Interceptors - 拦截器的更多相关文章

  1. (vue.js)axios interceptors 拦截器中添加headers 属性

    (vue.js)axios interceptors 拦截器中添加headers 属性:http://www.codes51.com/itwd/4282111.html 问题: (vue.js)axi ...

  2. flume1.8 Interceptors拦截器(五)

    1. Flume Interceptors Flume有能力修改/删除流程中的events.这是在拦截器(interceptor)的帮助下完成的.拦截器(Interceptors)是实现org.apa ...

  3. springMVC之mvc:interceptors拦截器的用法

    1.配置拦截器 在springMVC.xml配置文件增加: <mvc:interceptors> <!-- 日志拦截器 --> <mvc:interceptor> ...

  4. angular之interceptors拦截器

    <!DOCTYPE html> <html ng-app="nickApp"> <head> <meta charset="UT ...

  5. springMVC <mvc:interceptors>拦截器的使用

    首先在springMVC.xml配置如下代码 <!-- 拦截器 --> <mvc:interceptors> <bean class="com.base.Acc ...

  6. angular http interceptors 拦截器使用分享

    拦截器 在开始创建拦截器之前,一定要了解 $q和延期承诺api 出于全局错误处理,身份验证或请求的任何同步或异步预处理或响应的后处理目的,希望能够在将请求移交给服务器之前拦截请求,并在将请求移交给服务 ...

  7. vue interceptors(拦截器)

    拦截器 顾名思义: 就是半路个您劫持, 拦截器 其实在项目和自己写demo中,总会遇到请求方面需要在请求头里面做判断或者添加一些东西, 这时候 vue 中应用中axios的 interceptors  ...

  8. vue拦截器Vue.http.interceptors.push

    刚开始学vue,github上down了一个开源项目,看源代码的时候看到了这个地方: /** * @export * @param {any} request * @param {any} next ...

  9. SpringMVC配置拦截器实现登录控制

    SpringMVC读取Cookie判断用户是否登录,对每一个action都要进行判断.之前使用jstl标签在页面上判断session如果没有登录就使用如下代码跳转到登录页面. <c:if tes ...

随机推荐

  1. Codeforces 838E Convex Countour

    题 OvO http://codeforces.com/contest/838/problem/E (IndiaHacks 2nd Elimination 2017 (unofficial, unra ...

  2. Shell操作

    Shell 1. 我们无法直接和内核打交道,Shell就是用来解释命令,用来和内核打交道用的. 2. Shell有不同形式(同样命令在不同shell中不一定通用):cshell.bash.kshell ...

  3. 错误/异常:org.hibernate.MappingException: Unknown entity: com.shore.entity.Student 的解决方法

    1.错误/异常视图 错误/异常描述:Hibernate配置文件 映射异常,不明实体类Student(org.hibernate.MappingException: Unknown entity: co ...

  4. 状压dpHDU - 4856

    J - Tunnels HDU - 4856 题目大意:地图上有些管道,在管道行走里不需要花费时间,但从一个管道的出口走到另一个管道的入口则需要花费时间,问走完所有管道最短的时间,如果不行,则输出-1 ...

  5. Catch That Cow (POJ - 3278)(简单BFS)

    转载请注明出处:https://blog.csdn.net/Mercury_Lc/article/details/82693928作者:Mercury_Lc 题目链接 题解:给你x.y,x可以加1.减 ...

  6. 基于node、webpack、搭建一个koa服务器

    1.首先需要node(去官网下载) 2.见一个文件夹  比如koa          cmd——r       cd  koa文件 3.npm init 4.安装webpack       (本地安装 ...

  7. scrapy pipeline

    pipeline的四个方法 @classmethod def from_crawler(cls, crawler): """ 初始化的时候,用以创建pipeline对象 ...

  8. beautifulsoup 安装

    pip install beautifulsoup4

  9. 主线程 Looper.loop() 死循环为何不会ANR

    先看下 ActivityThread 中的这段代码: 而 loop() 方法中,存在一个死循环: public static void loop() { ... ... ... for (;;) { ...

  10. Mysql 修改密码和设置远程连接

    [参考文章]:mysql修改root密码和设置权限 1. 修改密码 1.1 set password 登录mysql set password for 用户名@localhost = password ...