Filebeat是轻量级的开源日志文件数据搜集器。通常在需要采集数据的客户端安装 Filebeat,并指定目录与日志格式,Filebeat 就能快速收集数据,并发送给 logstash 进行解析,或是直接发给 Elasticsearch 存储,性能上相比运行于 JVM 上的 logstash 优势明显,是对它的替代。常应用于 EFLK 架构当中。
一、部署filebeat
1、关闭防火墙和安全机制
systemctl disable --now firewalld
setenforce 0
hostnamectl set-hostname filebeat
2、安装nginx服务
yum -y install epel-release.noarch
yum -y install nginx
systemctl enable --now nginx
需要给nginx日志可读权限
3、安装 Filebeat
上传软件包 filebeat-6.7.2-linux-x86_64.tar.gz 到/opt目录
tar xf filebeat-6.7.2-linux-x86_64.tar.gz
mv /opt/filebeat-6.7.2-linux-x86_64 /usr/local/filebeat
4、设置 filebeat 的主配置文件
vim /usr/local/filebeat/filebeat.yml



5、在 Logstash 组件所在节点上新建一个 Logstash 配置文件
vim filebeat.conf
bash
input {
beats { port => "5044" }
}
#filter {}
output {
elasticsearch {
hosts => ["192.168.130.10:9200","192.168.130.20:9200","192.168.130.30:9200"]
index => "%{[fields][server_name]}-%{[fields][log_type]}-%{[fields][from]}-%{+YYYY.MM.dd}"
}
stdout {
codec => rubydebug
}
}


6、启动 logstash和filebeat
logstash -f filebeat.conf #启动logstash
在/usr/local/filebeat目录中使用./filebeat -e -c filebeat.yml #启动filebeat

7、浏览器访问kibana

