flume 使用 exec 采集容器日志,转储磁盘
在该场景下,docker 服务为superset,flume 的sources 选择 exec , sinks选择 file roll 。
任务配置
具体配置文件如下:
#simple.conf: A single-node Flume configuration
# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1
# Describe/configure the source
a1.sources.r1.type = exec
# exec source 监控命令是tail -f ,日志文件可随意指定,这里选择的是容器服务的日志文件
a1.sources.r1.command = tail -F /data/docker/containers/e511e3e4b3445efeb38fe822ac086dfc5ebb8bdc4a725dc6e2969ef2092c78ec/e511e3e4b3445efeb38fe822ac086dfc5ebb8bdc4a725dc6e2969ef2092c78ec-json.log
# Describe the sink
a1.sinks.k1.type = file_roll
#指定文件转存储目录,可自建
a1.sinks.k1.sink.directory = /home/test/log
# one day roll once 一天滚动一次,为了防止转储日志文件过大,按天进行文件滚动
a1.sinks.k1.sink.rollInterval = 86400
#a1.sinks.k1.sink.pathManager = superset
# 定义日志文件后缀
a1.sinks.k1.sink.pat