重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
这篇文章主要介绍“Flume Interceptors怎么部署”,在日常操作中,相信很多人在Flume Interceptors怎么部署问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”Flume Interceptors怎么部署”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!
成都创新互联主要业务有网站营销策划、成都做网站、成都网站制作、微信公众号开发、小程序定制开发、H5页面制作、程序开发等业务。一次合作终身朋友,是我们奉行的宗旨;我们不仅仅把客户当客户,还把客户视为我们的合作伙伴,在开展业务的过程中,公司还积累了丰富的行业经验、成都营销网站建设资源和合作伙伴关系资源,并逐渐建立起规范的客户服务和保障体系。
一、Timestamp Interceptor
在event headers中,添加timestamp标签
[root@hftest0001 conf]# pwd /opt/apache-flume-1.6.0-bin/conf [root@hftest0001 conf]# vi s-exec_c-m_s-logger.conf agent.sources = exec_tail agent.channels = memoryChannel agent.sinks = loggerSink agent.sources.exec_tail.type = exec agent.sources.exec_tail.command = tail -F /opt/flume-data/exec-tail.log agent.sources.exec_tail.channels = memoryChannel agent.sources.exec_tail.interceptors = i1 agent.sources.exec_tail.interceptors.i1.type = timestamp #agent.sources.exec_tail.interceptors.i1.preserveExisting = true agent.sinks.loggerSink.type = logger #agent.sinks.loggerSink.maxBytesToLog = 1 agent.sinks.loggerSink.channel = memoryChannel agent.channels.memoryChannel.type = memory agent.channels.memoryChannel.capacity = 100 ===>结果 Event: { headers:{timestamp=1452668731658} body: 78 78 xx }
二、Host Interceptor
获取agent部署那台server的ip或是hostname,或添加到host标签中
[root@hftest0001 conf]# pwd /opt/apache-flume-1.6.0-bin/conf [root@hftest0001 conf]# vi s-exec_c-m_s-logger.conf agent.sources.exec_tail.type = exec agent.sources.exec_tail.command = tail -F /opt/flume-data/exec-tail.log agent.sources.exec_tail.channels = memoryChannel agent.sources.exec_tail.interceptors = i1 i2 agent.sources.exec_tail.interceptors.i1.type = timestamp #agent.sources.exec_tail.interceptors.i1.preserveExisting = true agent.sources.exec_tail.interceptors.i2.type = host #agent.sources.exec_tail.interceptors.i2.userIP = false =>default:true 设置为false,则获取的值为hostname #agent.sources.exec_tail.interceptors.i2.hostHeader = hostname => default:header中key为host,可以设置更改 #agent.sources.exec_tail.interceptors.i2.preserveExisting = true agent.sinks.loggerSink.type = logger #agent.sinks.loggerSink.maxBytesToLog = 1 agent.sinks.loggerSink.channel = memoryChannel agent.channels.memoryChannel.type = memory agent.channels.memoryChannel.capacity = 100 ===>result Event: { headers:{timestamp=1452669139164, host=${ip}} body: 78 78 xx }
三、Static Interceptor
自定义向header中添加k-v: 用途,如想知道events是那个dc的,那个country,那个city。也可以根据这些header信息,进行数据分流等等
[root@hftest0001 conf]# pwd /opt/apache-flume-1.6.0-bin/conf [root@hftest0001 conf]# vi s-exec_c-m_s-logger.conf #agent.sources.exec_tail.interceptors.i2.userIP = false #agent.sources.exec_tail.interceptors.i2.hostHeader = hostname #agent.sources.exec_tail.interceptors.i2.preserveExisting = true agent.sources.exec_tail.interceptors.i3.type = static agent.sources.exec_tail.interceptors.i3.key = country agent.sources.exec_tail.interceptors.i3.value = USA agent.sources.exec_tail.interceptors.i4.type = static agent.sources.exec_tail.interceptors.i4.key = city agent.sources.exec_tail.interceptors.i4.value = NEW_YORK agent.sinks.loggerSink.type = logger #agent.sinks.loggerSink.maxBytesToLog = 1 agent.sinks.loggerSink.channel = memoryChannel agent.channels.memoryChannel.type = memory agent.channels.memoryChannel.capacity = 100 ===> result Event: { headers:{timestamp=1452669538967, host=${IP}, city=NEW_YORK, country=USA} body: 78 78 xx }
到此,关于“Flume Interceptors怎么部署”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注创新互联网站,小编会继续努力为大家带来更多实用的文章!