06_Flume_interceptor_时间戳+Host
1、目标场景

2、flume agent配置文件
# define agent name, source/sink/channel name
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 timestamp and host interceptors work before source
a1.sources.r1.interceptors = i1 i2 # 两个interceptor串联,依次作用于event
a1.sources.r1.interceptors.i1.type = timestamp
a1.sources.r1.interceptors.i1.preserveExisting = false a1.sources.r1.interceptors.i2.type = host
# flume event的头部将添加 “hostname”:实际主机名
a1.sources.r1.interceptors.i2.hostHeader = hostname # 指定key,value将填充为flume agent所在节点的主机名
a1.sources.r1.interceptors.i2.useIP = false # IP和主机名,二选一即可 # hdfs sink
a1.sinks.k1.type = hdfs
a1.sinks.k1.hdfs.path = hdfs://master:9000/flume/%Y-%m-%d/ # hdfs sink将根据event header中的时间戳进行替换
# 和hostHeader的值保持一致,hdfs sink将提取event中key为hostnmae的值,基于该值创建文件名前缀
a1.sinks.k1.hdfs.filePrefix = %{hostname} # hdfs sink将根据event header中的hostnmae对应的value进行替换
a1.sinks.k1.hdfs.fileType = DataStream
a1.sinks.k1.hdfs.writeFormat = Text
a1.sinks.k1.hdfs.rollInterval =
a1.sinks.k1.hdfs.rollCount =
a1.sinks.k1.hdfs.rollSize = # channel,memory
a1.channels.c1.type = memory
a1.channels.c1.capacity =
a1.channels.c1.transactionCapacity = # bind source,sink to channel
a1.sinks.k1.channel = c1
a1.sources.r1.channels = c1
3、验证timestamp+host interceptor
验证思路:
1)先将interceptor作用后的event,通过logger sink打印到console,验证header是否正常添加
2)修改sink为hdfs, 观察目录和文件的名称是否能够按照预期创建(时间戳-目录,hostname-文件前缀)
验证过程:
1)发送header为空的http请求,logger sink打印event到终端,观察event header中是否被添加了timestamp以及hostname

2)ogger打印到console的event,header发生了变化

3)修改sink为hdfs, 观察HDFS的目录名(时间戳)和文件前缀(hostnme)
*目录名被正常替换(基于event header中的时间戳)

*文件前缀被正常替换(基于event header中的hostname:实际主机名)

* 文件内容被写入为event的body

06_Flume_interceptor_时间戳+Host的更多相关文章
- kafka笔记-Kafka在zookeeper中的存储结构【转】
参考链接:apache kafka系列之在zookeeper中存储结构 http://blog.csdn.net/lizhitao/article/details/23744675 1.topic注 ...
- kafka在zookeeper中的存储结构
参考site:http://kafka.apache.org/documentation.html#impl_zookeeper 1.zookeeper客户端相关命令 在确保zookeeper服务启动 ...
- 快速搭建日志系统——ELK STACK
什么是ELK STACK ELK Stack是Elasticserach.Logstash.Kibana三种工具组合而成的一个日志解决方案.ELK可以将我们的系统日志.访问日志.运行日志.错误日志等进 ...
- flume组件汇总 source、sink、channel
Flume Source Source类型 说明 Avro Source 支持Avro协议(实际上是Avro RPC),内置支持 Thrift Source 支持Thrift协议,内置支持 Exec ...
- apache kafka系列之在zookeeper中存储结构
1.topic注册信息 /brokers/topics/[topic] : 存储某个topic的partitions所有分配信息 Schema: { "version": ...
- Kafka学习之路 (五)Kafka在zookeeper中的存储
一.Kafka在zookeeper中存储结构图 二.分析 2.1 topic注册信息 /brokers/topics/[topic] : 存储某个topic的partitions所有分配信息 [zk: ...
- kafka在zookeeper中存储结构
1.topic注册信息 /brokers/topics/[topic] : 存储某个topic的partitions所有分配信息 Schema: { "version": ...
- Kafka(四)Kafka在zookeeper中的存储
一 Kafka在zookeeper中存储结构图 二 分析 2.1 topic注册信息 /brokers/topics/[topic] : 存储某个topic的partitions所有分配信息 [zk: ...
- tcpdump学习笔记
简介 简单的说,tcpdump就是一个抓包工具,类似Wireshark. tcpdump可以根据使用者的定义过滤/截取网络上的数据包,并进行分析.tcpdump可以将数据包的头部完全接 ...
随机推荐
- Elasticsearch Date类型使用技巧
elasticsearch原生支持date类型.这里简单记录下使用的方法. 使用date类型可以用如下两种方式: 使用毫秒的时间戳,直接将毫秒值传入即可. 传入格式化的字符串,默认是ISO 8601标 ...
- KMP(http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2772)
#include <stdio.h>#include <string.h>#include <stdlib.h>char a[1000001],b[1000001] ...
- 翻译[RFC6238] TOTP: Time-Based One-Time Password Algorithm
在闲暇时间做了一个TOTP相关的开源项目,在项目初步完成之余,我尝试对[RFC6238]文档进行了翻译,供大家参考与查阅,若有不妥之处,还望各位前辈海涵斧正. [RFC6238] : Time-Bas ...
- Rpgmakermv(5) MiniLabel插件介绍
============================================================================ Introduction ========== ...
- Hdu dp
4856 这题说的是给了一个图 这个图有很多的隧道每个隧道是单向的 只能从一个入口进入从另一个入口出来 要求计算出走完这些隧道花的总时间 因为这个图是一个网格行的然后 先用bfs算出隧道的出口到每个隧 ...
- python 元组 序列上使用enumerate()函数
不能直接for n,x,y in enumerate(data)
- Python: 字典列表: itemgetter 函数: 根据某个或某几个字典字段来排序列表
问题:根据某个或某几个字典字段来排序Python列表 answer: 通过使用operator 模块的itemgetter 函数,可以非常容易的排序这样的数据结构 eg: rows = [ {'fna ...
- Spring,Struts2,MyBatis,Activiti,Maven,H2,Tomcat集成(二)——Struts2集成
1. pom.xml文件添struts2依赖jar包: <!-- 与Struts2集成必须使用 --> <dependency> <groupId>org.spri ...
- python excel练习:新建sheet、修改名称、设定颜色、打印sheet名称,复制,保存
练习: 新建一个sheet 设定一个sheet的插入位置 修改sheet的名称为‘xiaxiaoxu’ 设定该sheet的背景标签的颜色 获取全部sheet的名称,打印每个sheet的名称 copy一 ...
- [转载]论asp.net out、ref、return
论asp.net out.ref.return ref(引用类型) ref引用类型进出都必须赋值,赋值后会改变类型原来的指针. out(值类型) out值类型进可以不赋值,出必须赋值. r ...