实践一:regex filter interceptor

1、目标场景

regex filter interceptor的作用:

1)将event body的内容和配置中指定的正则表达式进行匹配
2)如果内容匹配,则将该event丢弃
3)如果内容不匹配,则将该event放行

2、Flume Agent配置文件

#  define agent name, source/sink/channel
a1.sources = r1
a1.sinks = k1
a1.channels = c1 # source,http,jsonhandler
a1.sources.r1.type = http
a1.sources.r1.bind = master
a1.sources.r1.port =
a1.sources.r1.handler = org.apache.flume.source.http.JSONHandler # 03 regex filter interceptor, match event body for filter
a1.sources.r1.interceptors
= i1
a1.sources.r1.interceptors.i1.type = regex_filter
a1.sources.r1.interceptors.i1.regex = ^[0-9]*$
# filter matched event
a1.sources.r1.interceptors.i1.excludeEvents = true
# logger sink
a1.sinks.k1.type = logger # channel,memory
a1.channels.c1.type = memory
a1.channels.c1.capacity =
a1.channels.c1.transactionCapacity = # bind source,sink to channel
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1

3、验证regex filter interceptor

1) 通过curl -X POST -d 'json数据' 发送带有不同body的HTTP请求,其中有1个满足regex

2)观察终端打印出的event,body为1234的event被过滤, 并没有出现

4、regex filter interceptor的官方文档

实践二:regex extractor interceptor

1、目标场景

regex extractor interceptor的作用:
1)将event body的内容和配置中指定的正则表达式进行匹配
2)如果内容匹配,将配合配置文件中给定的key, 组成key:value添加到event的header中
3)event body中的内容不会变化

2、Flume Agent的配置文件

#  define agent name, source/sink/channel
a1.sources = r1
a1.sinks = k1
a1.channels = c1 # source,http,jsonhandler
a1.sources.r1.type = http
a1.sources.r1.bind = master
a1.sources.r1.port =
a1.sources.r1.handler = org.apache.flume.source.http.JSONHandler # 03 regex extractor interceptor,match event body to extract character and digital
a1.sources.r1.interceptors = i1
a1.sources.r1.interceptors.i1.type = regex_extractor
a1.sources.r1.interceptors.i1.regex = (^[a-zA-Z]*)\\s([0-9]*$) # regex匹配并进行分组,匹配结果将有两个部分, 注意\s空白字符要进行转义
# specify key
for 2 matched part
a1.sources.r1.interceptors.i1.serializers = s1 s2
# key name
a1.sources.r1.interceptors.i1.serializers.s1.name = word
a1.sources.r1.interceptors.i1.serializers.s2.name =
digital # logger sink
a1.sinks.k1.type = logger # channel,memory
a1.channels.c1.type = memory
a1.channels.c1.capacity =
a1.channels.c1.transactionCapacity = # bind source,sink to channel
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1

3、验证regex extractor interceptor

1) 通过curl -X POST -d 'json数据'的方式发送HTTP请求,body中的内容为"shayzhang 1234", 其中shayzhang,1234将被正则表达式匹配

2) 观察logger打印到终端的event,header中将增加两部分 word:shayzhang, digital:1234

07_Flume_regex interceptor实践的更多相关文章

  1. 05_Flume_timestamp interceptor实践

    1.目标场景 2.Flume Agent配置 # specify agent,source,sink,channel a1.sources = r1 a1.sinks = k1 a1.channels ...

  2. springmvc学习笔记--Interceptor机制和实践

    前言: Spring的AOP理念, 以及j2ee中责任链(过滤器链)的设计模式, 确实深入人心, 处处可以看到它的身影. 这次借项目空闲, 来总结一下SpringMVC的Interceptor机制, ...

  3. 【转】Flume(NG)架构设计要点及配置实践

    Flume(NG)架构设计要点及配置实践   Flume NG是一个分布式.可靠.可用的系统,它能够将不同数据源的海量日志数据进行高效收集.聚合.移动,最后存储到一个中心化数据存储系统中.由原来的Fl ...

  4. Spring 实践 -拾遗

    Spring 实践 标签: Java与设计模式 Junit集成 前面多次用到@RunWith与@ContextConfiguration,在测试类添加这两个注解,程序就会自动加载Spring配置并初始 ...

  5. 【SSH2(理论+实践)】--Hibernate步步(一个)

    前几个博客讨论SSH2该框架Struts,它代表层,集成封装.和使用WebWork作为核心处理,依赖映射是它的处理核心.在使用时需要Struts.xml配置相应Action和Interceptor够完 ...

  6. 【DDD】领域驱动设计实践 —— UI层实现

    前面几篇blog主要介绍了DDD落地架构及业务建模战术,后续几篇blog会在此基础上,讲解具体的架构实现,通过完整代码demo的形式,更好地将DDD的落地方案呈现出来.本文是架构实现讲解的第一篇,主要 ...

  7. Chloe.ORM框架应用实践

    Chloe.ORM 是国人开发的一款数据库访问组件,很是简单易用.目前支持四种主流数据库:SqlServer.MySQL.Oracle,以及Sqlite,作者为这四种数据库划分出了各自对应的组件程序集 ...

  8. mybatis 3.x源码深度解析与最佳实践(最完整原创)

    mybatis 3.x源码深度解析与最佳实践 1 环境准备 1.1 mybatis介绍以及框架源码的学习目标 1.2 本系列源码解析的方式 1.3 环境搭建 1.4 从Hello World开始 2 ...

  9. Spring MVC 实践 - Component

    Spring MVC 实践 标签 : Java与Web Converter Spring MVC的数据绑定并非没有任何限制, 有案例表明: Spring在如何正确绑定数据方面是杂乱无章的. 比如: S ...

随机推荐

  1. 让你分分钟了解Web接口测试

    因为前后端架构分离技术的兴起,接口测试也越来越重要,最近一直想总结下,作为一个近三年的测试人员,接口这个词是耳濡目染的,而开发张口闭口也都是这个接口或那个接口怎么怎么样,自己遇到的bug也很多是接口问 ...

  2. java maven项目找不到jconsole-1.8.0.jar和tools-1.8.0.jar包

    今天在整合jar包时候,出现了 这是我导入的jar坐标 <dependency> <groupId>com.alibaba</groupId> <artifa ...

  3. col-md-*和col-sm-*

    屏幕大于(≥992px) ,使用col-md-* 而不是col-sm-*如果屏幕大于(≥768px),小雨<=992px,使用col-sm-* 而不是col-md-*

  4. [LeetCode] 38. Count and Say_Easy

    The count-and-say sequence is the sequence of integers with the first five terms as following: 1. 1 ...

  5. Linux系统——PXE高效能批量网络装机

    PXE:Pre-boot Excution Environment,预启动执行环境,石油Intel公司开发的网络引导技术,工作在Client.Server模式,允许客户机通过网络从远程服务器下载阴道镜 ...

  6. 转载自(http://snailz.diandian.com/post/2012-10-24/40041265730)

    PHP 5.4.8 添加系统服务命令 之前没注意,PHP 5.4.8 的安装包有自带的系统服务注册文件的 打开编译安装包,换成你自己的路径 cd /mydata/soft/php-5.4.8/ cp ...

  7. Linux命令: 结束命令

    1)ctrl+c,退出命令 2)q,退出文件

  8. Python: collections.nametuple()--映射名称到序列元素

    问题:  通过下标访问列表或者元组中元素 answer: collections.namedtuple()通过使用元组对象来解决这个问题 这个函数实际上是一个返回Python中标准元组类型子类的一个工 ...

  9. linux常用命令:iostat 命令

    Linux系统中的 iostat 是I/O statistics(输入/输出统计)的缩写,iostat工具将对系统的磁盘操作活动进行监视.它的特点是汇报磁盘活动统计情况,同时也会 汇报出CPU使用情况 ...

  10. linux服务器---代理认证

    代理认证 proxy代理服务被广泛的使用,为了安全起见,可以在服务器上增加一层安全认证机制.这里使用htpasswd建立认证账号和密码 1.创建认证账号和密码 [root@localhost wj]# ...