安装 fluent-bit ,以及导入日志目录到es中
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了安装 fluent-bit ,以及导入日志目录到es中相关的知识,希望对你有一定的参考价值。
#!/bin/bash # by gaogd esname=internal-2013865141.cn-north-1.elb.amazonaws.com.cn esport=9200 fluentdir=/work/opt/fluentb/build/conf logdir=/data/logs/ host=`hostname` function createfluentbconf () { if [ ! -d $logdir/fluent ] then mkdir -p $logdir/fluent fi if [ ! -d $fluentdir/build/conf ] then mkdir -p $fluentdir/build/conf fi cat > /etc/supervisor/conf.d/fluentb.conf <<EOF [program:fluentb] directory=/work/opt/fluentb/build command=/work/opt/fluentb/build/bin/fluent-bit -c /work/opt/fluentb/build/conf/fluent.conf ;process_name=%(process_num)02d numprocs=1 user=root autostart=true autorestart=true redirect_stderr=true stdout_logfile=/data/logs/fluent/fluent.log stdout_logfile_maxbytes=50MB stdout_logfile_backups=5 EOF cat >${fluentdir}/fluent.conf<<EOF [SERVICE] Flush 1 Daemon Off Log_Level info ###INPUT ###OUTPUT EOF for name in `ls ${logdir}` do cat >${fluentdir}/input-${name}.conf<<EOF [INPUT] Name tail Path /data/logs/${name}/*.log Db /data/logs/${name}/${name}.pos Tag ${name} Mem_Buf_Limit 5MB EOF cat >${fluentdir}/output-${name}.conf<<EOF [OUTPUT] Name es Match ${name} Host ${esname} Port ${esport} Index fluentd-${name} Logstash_Format On Logstash_Prefix fluentd-${name} Include_Tag_Key On EOF #sed -i "/###INPUT/a\@INCLUDE ${fluentdir}/input-${name}.conf" ${fluentdir}/fluent.conf #sed -i "/###OUTPUT/a\@INCLUDE ${fluentdir}/output-${name}.conf" ${fluentdir}/fluent.conf done cat ${fluentdir}/input-* >>${fluentdir}/fluent.conf cat ${fluentdir}/output-*>>${fluentdir}/fluent.conf cat >>${fluentdir}/fluent.conf<<EOF [FILTER] Name record_modifier Match * Record hostname "${host}" EOF } function installfluentd () { apt-get install gcc cmake g++ openssl -y rm -rf /work/opt/fluent* mkdir -p /work/{source,opt} cd /work/source/ mv /tmp/fluent-bit-0.12.0.tar.gz . tar xf fluent-bit-0.12.0.tar.gz mv fluent-bit-0.12.0 /work/opt/ cd /work/opt/ /bin/ln -s /work/opt/fluent-bit-0.12.0/ fluentb mkdir -p /work/opt/fluentb/build && cd /work/opt/fluentb/build && cmake ../ && make && make install } installfluentd createfluentbconf
本文出自 “奋斗吧” 博客,请务必保留此出处http://lvnian.blog.51cto.com/7155281/1966607
以上是关于安装 fluent-bit ,以及导入日志目录到es中的主要内容,如果未能解决你的问题,请参考以下文章
收集kubernetes控制台日志及元数据(fluent-bit+es+kibana搭建)
使用 LogParser 导入IIS Log到SqlServer数据库中
fluent-bit debug调试,采集kubernetes podIP
Filebeat 导入 Elastaticsearch 的方法