flume HttpSource使用

HttpSource

httpsource允许是flume提供的能接收get和post的http请求,http请求会被HttpHandler接口实现类处理,从而将http请求转换为event从而提交到channel。
http适用于一些无法通过部署SDK接收日志的场景,例如游戏客户端。

HttpSource配置使用

HttpSource基本配置参数

配置参数 默认值 描述
type - http (org.apache.fluem.source.httpSource)或HttpSource
bind 0.0.0.0 绑定的IP地址或主机名
port - 绑定的端口号
enableSSL false 是否启用SSL
keystore - keystore文件的路径
keystorePassword - 进入keystore的密码
handler JSONHandler HttpSource使用的处理程序类

配置文件示例:

#source
a1.sources = r1
a1.channels = c1
a1.sources.r1.type = http
a1.sources.r1.bind=0.0.0.0
a1.sources.r1.port = 5140
a1.sources.r1.channels = c1
a1.sources.r1.hadler=HTTPSourceXMLHandler
#channel
a1.channels.c1.type=memory
a1.channels.c1.capacity=10000
a1.channels.c1.transactionCapacity=1000
#sink
a1.sinks.k1.type=logger
a1.sinks.k1.channel=c1

HttpHandler二次开发

实现HttpSourceHandler接口,实现getEvents方法,接收HttpServletRequest参数,返回生成的List集合

常见示例如下:

public class HTTPSourceXMLHandler implements HTTPSourceHandler {
   
    private final String ROOT = "events";
    private final String EVENT_TAG = "event";
    private final String HEADERS_TAG = "headers";
    private final String BODY_TAG = "body";

    private final String CONF_INSERT_TIMESTAMP = "insertTimestamp";
    private final String TIMESTAMP_HEADER = "timestamp";
    private final DocumentBuilderFactory documentBuilderFactory
            = DocumentBuilderFactory.newInstance();

    // Document builders are not thread-safe.
    // So make sure we have one for each thread.
    private final ThreadLocal<DocumentBuilder> docBuilder
            = new Thre
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值