Flume主要有以下几种监控方式:
1.JMX监控
配置 {$FLUME_HOME}/conf/flume-env.sh
cd $FLUME_HOME/conf
vi flume-env.sh
export JAVA_OPTS="-Xms500m -Xmx10240m -Dcom.sun.management.jmxremote \ -Dcom.sun.management.jmxremote \ -Dcom.sun.management.jmxremote.authenticate=false \ -Dcom.sun.management.jmxremote.ssl=false \ -Dcom.sun.management.jmxremote.port=54321 \ -Dcom.sun.management.jmxremote.rmi.port=54322 -Djava.rmi.server.hostname=10.202.76.218"
之后启动flume
bin/flume-ng agent --conf conf/ --name tj_rt_data --conf-file jobs/dir_console.conf -Dflume.root.logger=INFO,console
附:一个agent配置
cat dir_console.conf
#描述所有组件 tj_rt_data.sources = spooling-dir-src tj_rt_data.channels = mem-channel1 tj_rt_data.sinks = console-sink2 #描述source tj_rt_data.sources.spooling-dir-src.type = spooldir tj_rt_data.sources.spooling-dir-src.spoolDir = /home/sfapp/tianjin/rt_src_path tj_rt_data.sources.spooling-dir-src.fileHeader = true tj_rt_data.sources.spooling-dir-src.fileHeaderKey = file tj_rt_data.sources.spooling-dir-src.basenameHeader = true tj_rt_data.sources.spooling-dir-src.basenameHeaderKey = basename tj_rt_data.sources.spooling-dir-src.includePattern = (^bill.*\.txt) tj_rt_data.sources.spooling-dir-src.ignorePattern = ([^ ]*\.tmp)|([^ ]*\.COMPLETED) tj_rt_data.sources.spooling-dir-src.inputCharset = GBK tj_rt_data.sources.spooling-dir-src.pollDelay = 5000 tj_rt_data.sources.spooling-dir-src.recursiveDirectorySearch = true tj_rt_data.sources.spooling-dir-src.batchSize = 200 tj_rt_data.sources.spooling-dir-src.deserializer = LINE tj_rt_data.sources.spooling-dir-src.deserializer.maxLineLength = 20480 tj_rt_data.sources.spooling-dir-src.deserializer.outputCharset = UTF-8 tj_rt_data.sources.spooling-dir-src.selector.type = replicating tj_rt_data.sources.spooling-dir-src.interceptors = i1 tj_rt_data.sources.spooling-dir-src.interceptors.i1.type = regex_extractor tj_rt_data.sources.spooling-dir-src.interceptors.i1.regex = ^.*\\$(apex|cae|dhl|ems|fedex|hto|sf|sto|tnt|ups|yto|yunda|zjs|zto|zyh)\\$.*$ tj_rt_data.sources.spooling-dir-src.interceptors.i1.serializers = s1 tj_rt_data.sources.spooling-dir-src.interceptors.i1.serializers.s1.type = org.apache.flume.interceptor.RegexExtractorInterceptorPassThroughSerializer tj_rt_data.sources.spooling-dir-src.interceptors.i1.serializers.s1.name = src_company_code #组织sinks tj_rt_data.sinks.console-sink2.type = logger #组织channel tj_rt_data.channels.mem-channel1.type = memory tj_rt_data.channels.mem-channel1.capacity = 20480 tj_rt_data.channels.mem-channel1.transactionCapacity = 2048 # 将source和sink绑定到channel tj_rt_data.sources.spooling-dir-src.channels = mem-channel1 tj_rt_data.sinks.console-sink2.channel = mem-channel1
在图形界面的系统(windows、mac、linux图形)和jdk的环境下启动jconsole
jconsole
连接jmx端口.jpg
jmx监控控制台.jpg
可以看到flume应用所使用的内存、线程、类、CPU等使用情况。
MBean可以监控flume的各个组件运行情况。
2.HTTP监控
Flume可以通过HTTP以JSON形式报告metrics,启用HTTP监控,Flume需要配置一个端口。
配置一个简单的打印conf文件: dir_console.conf ,如第1章
启动flume并指定http监控形式和端口
bin/flume-ng agent --conf conf/ --name tj_rt_data --conf-file jobs/dir_console.conf -Dflume.root.logger=INFO,console -Dflume.monitoring.type=http -Dflume.monitoring.port=1234
查看metric监控
用浏览器或者GET方式打开
http://ip:1234/metrics
获得数据如下:
标签:Flume,rt,方式,src,sources,tj,监控,data,dir From: https://www.cnblogs.com/LIAOBO/p/17362941.html