zoukankan      html  css  js  c++  java
  • Interceptors

    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
    ----
     
  • 相关阅读:
    rabbitmq
    C#操作redis
    C#设计模式——桥接模式
    C#设计模式——代理模式
    C#设计模式——外观者模式
    WPF Item内TextBox获取焦点时如何选中当前Item
    解决异常System.Runtime.Interopservices.COMException RequestLock问题
    【转】WPF中Binding的技巧(一)
    【转】WPF中的Binding技巧(二)
    ASP.NET State Service服务
  • 原文地址:https://www.cnblogs.com/zpb2016/p/5766939.html
Copyright © 2011-2022 走看看