最新Flume1.7 自定义 MongodbSink 结合TAILDIR Sources的使用
Flume MongodbSink
此mongodb支持3.0
MongodbSink
flume-ng-mongodbsink
An Apache Flume Sink that send JSON to MongoDB collection
配置文件 configuration properties
| Property Name | Default | Description |
|---|---|---|
| hostNames | - | host1:port1,host2,port2,...the mongodb host and port |
| database | - | the mongodb database |
| collection | - | the collection of database |
| user | - | the username of databse |
| password | - | the password of database |
| batchSize | 100 | the batchSize of sources |
| authentication_enabled | False | Whether u need a password and a user |
如果没有密码和用户名 就不需要user password authentication_enabled T
如果有密码,设置authentication_enabled =True
Example
# 定义数据出口
a1.sinks.s.type = com.kenshuchong.MongodbSink.MongoSinkSelf
a1.sinks.s.hostNames=127.0.0.1:27017
a1.sinks.s.authentication_enabled=True
a1.sinks.s.database = database
a1.sinks.s.password = password
a1.sinks.s.user = user
a1.sinks.s.collection = collection
a1.sinks.s.batchSize = 100
a1.sinks.s.channel = c
自定义修改Custom modify
可以修改其中生成json部分
line 76-82 jsonEvent is the event body
json event是日志主体
String cuTime = getCurrentTime();
String jsonEvent = new String(event.getBody(), StandardCharsets.UTF_8);
Document sentEvent = new Document("log",jsonEvent)
.append("Dir","/data/ngnix.log")
.append("Time", cuTime);
documents.add(sentEvent);
tips
本mongodbsink 支持3.0版本
线上使用需在flume/lib下添加一下几个jar包
- mongodb-driver-3.0.2.jar
- mongodb-driver-core-3.0.2.jar
- bson-3.0.2.jar
结合TAILDIR srouce实时采集日志并存入mongodb中
需求
- 日志存储在/opt/rec/log
- 日志需要采集其中的ERROR级别日志
- 日志存储在mongodb中
处理需求
- 采用新的TAILDIR source来对/log进行实时采集
- 给suorce配置正则拦截器,拦截非ERROR日志
- 采用自定义mongodbsink实时将日志插入mongodb中
- positionFile 为存储文件读取偏移地址的josn文件,这种只从最新位置读取
- 只有检测到了文件位置有新的偏移才会再次读取文件
配置文件
#定义组件名称
a1.sources = r
a1.sinks = s
a1.channels = c
#定义数据入口
a1.sources.r.type = TAILDIR
a1.sources.r.channels = c
a1.sources.r.positionFile = /home/ch/logMonitor/taildir_position.json
a1.sources.r.filegroups = f1
a1.sources.r.filegroups.f1 = /opt/rec/log/*.log
##定义拦截器
a1.sources.r.interceptors=i1
a1.sources.r.interceptors.i1.type=regex_filter
a1.sources.r.interceptors.i1.regex= ERROR
# 定义数据出口
a1.sinks.s.type = com.kenshuchong.MongodbSink.MongoSinkSelf
a1.sinks.s.hostNames=127.0.0.1:27017
a1.sinks.s.authentication_enabled=True
a1.sinks.s.database = database
a1.sinks.s.password = password
a1.sinks.s.user = user
a1.sinks.s.collection = logsearch_info
a1.sinks.s.batchSize = 100
a1.sinks.s.channel = c
# 使用内存管道
a1.channels.c.type = memory
a1.channels.c.capacity = 10000
a1.channels.c.transactionCapacity = 100
最新Flume1.7 自定义 MongodbSink 结合TAILDIR Sources的使用的更多相关文章
- docker最新版本如何自定义配置文件
1 如果你想使用 /etc/default/docker文件配置你的docker 在 /etc/systemd/system/docker.service.d/docker.conf 添加下面---- ...
- 2、Flume1.7.0入门:安装、部署、及flume的案例
一.什么是Flume? flume 作为 cloudera 开发的实时日志收集系统,受到了业界的认可与广泛应用. flume的特点: flume是一个分布式.可靠.和高可用的海量日志采集.聚合和传输的 ...
- 自定义和扩展 SharePoint 2010 Server 功能区
了解构成 SharePoint 2010 服务器功能区的组件以及如何通过演练两个功能区自定义项方案来自定义功能区. 适用范围: Microsoft SharePoint Foundation 2010 ...
- Apache Flume 1.7.0 自定义输入输出
自定义http source config a1.sources.r1.type=http a1.sources.r1.bind=localhost a1.sources.r1.port= a1.so ...
- Flume初见与实践
Photo by Janke Laskowski on Unsplash 参考书籍:<Flume构建高可用.可扩展的海量日志采集系统> --Hari Shreedharan 著 以下简称& ...
- Flume 详解&实战
Flume 1. 概述 Flume是一个高可用,高可靠,分布式的海量日志采集.聚合和传输的系统.Flume基于流式架构,灵活简单. Flume的作用 Flume最主要的作用就是,实时读取服务器本地磁盘 ...
- Flume案例Ganglia监控
Flume案例和Flume监控系统的使用: 安装 将apache-flume-1.7.0-bin.tar.gz上传到linux的/opt/software目录下 解压apache-flume-1.7. ...
- Tomcat+Jenkins+SonarQube+SVN+Maven 集成自动化环境搭建(Windows10环境下)
说在前面的话: 从接到任务到完成共用了7天的时间.正常人用不到这个时间. 此时的功能表现是: 登录本地JenKins对项目进行构建,能够自动从SVN读取最新代码并按照Maven项目构建,构建完成能够自 ...
- 【Flume】Flume基础之安装与使用
1.Flume简介 (1) Flume提供一个分布式的,可靠的,对大数据量的日志进行高效收集.聚集.移动的服务,Flume只能在Unix环境下运行. (2) Flume基于流式架构,容错性强, ...
随机推荐
- Difference between ReLU、LReLU、PReLU、CReLU、ELU、SELU
激活函数 ReLU.LReLU.PReLU.CReLU.ELU.SELU 的定义和区别 ReLU tensorflow中:tf.nn.relu(features, name=None) LReLU ...
- CSS 几款比较常用的翻转特效
第一个:360度翻转特效 <style>* { margin:0; padding:0; } .aa { width: 220px; height: 220px; margin: 0 au ...
- pycharm 调试Django 奇葩问题:Process finished with exit code -1073741819
想自己整个BLOG,发现python+Django好像还不错,尝试一下.在使用过程中,突然pycharm不能调试django工程.网上搜索也没解决,是google哦.好像记得启动pycharm时,看到 ...
- Redis redis-trib集群配置
redis文档:http://doc.redisfans.com/ 参考:https://www.cnblogs.com/wuxl360/p/5920330.html http://www.cnblo ...
- 【 PostgreSQL】后台周期执行函数实例(shell+crontab)
工作中常见函数后台周期执行的情况,Oracle有job实现,gp数据库可以通过shell+crontab实现.流程如下: gpadmin用户下创建函数sh脚本. 将sh挂在crontab任务上 ### ...
- C语言高精度乘法
#include <stdio.h> void highPrecision (int N ); ] = {, }, length = ; //开辟一个大的数组,全局变量length记录长度 ...
- Mysql使用binlog恢复数据解决误操作问题的两种方法
为保证没有其他参数配置影响,重新安装配置了一台最小化安装的CentOS7虚拟机 1. 基础知识 安装mysql5.6数据库Mysql binlog初步理解 2. 配置mysql 开启binlog.修 ...
- [翻译] CoreImage-with-EAGLContext
CoreImage-with-EAGLContext https://github.com/anaglik/CoreImage-with-EAGLContext Simple example of d ...
- [翻译] DKTagCloudView - 标签云View
DKTagCloudView 效果(支持点击view触发事件): Overview DKTagCloudView is a tag clouds view on iOS. It can generat ...
- C#(.NET)面试题:做一个能自定义输入命令的表格程序
目前为止,已经面试 5 10 家了... 这个试题面试的公司是某一上市公司. 试题是英文的(后面给出翻译): you're given a task of writing a simple pro ...