简介
1 2 3 4 |
Filebeat附带预构建的模块,这些模块包含收集、解析、充实和可视化各种日志文件格式数据所需的配置,每个Filebeat模块由一个或多个文件集组成,这些文件集包含摄取节点管道、Elasticsearch模板、Filebeat勘探者配置和Kibana仪表盘。 Filebeat模块很好的入门,它是轻量级单用途的日志收集工具,用于在没有安装java的服务器上专门收集日志,可以将日志转发到logstash、elasticsearch或redis等场景中进行下一步处理 |
filebeat部署
安装
1 2 3 4 5 6 7 8 |
#上传 [root@web01 ~]# rz [root@web01 ~]# ll -rw-r--r-- 1 root root 11790119 May 24 2020 filebeat-6.6.0-x86_64.rpm #安装 [root@web01 ~]# yum localinstall -y filebeat-6.6.0-x86_64.rpm |
配置Filebeat收集单类型日志到本地文件
1)配置
1 2 3 4 5 6 7 8 9 10 11 12 |
#编辑Filebeat配置文件 [root@web01 ~]# vim /etc/filebeat/filebeat.yml filebeat.inputs: - type: log enabled: true paths: - /var/log/nginx/access.log output.file: path: "/tmp/" filename: "filebeat_nginx.log" |
2)启动
1 2 3 4 5 6 7 8 9 10 11 |
#启动Filebeat(CentOS6) [root@web01 ~]# /etc/init.d/filebeat start #启动Filebeat(CentOS7) [root@web01 ~]# systemctl start filebeat #检测进程 [root@web01 ~]# ps -ef|grep filebeat root 10881 1 0 01:06 pts/1 00:00:00 /usr/share/filebeat/bin/filebeat-god -r / -n -p /var/run/filebeat.pid -- /usr/share/filebeat/bin/filebeat -c /etc/filebeat/filebeat.yml -path.home /usr/share/filebeat -path.config /etc/filebeat -path.data /var/lib/filebeat -path.logs /var/log/filebeat root 10882 10881 0 01:06 pts/1 00:00:00 /usr/share/filebeat/bin/filebeat -c /etc/filebeat/filebeat.yml -path.home /usr/share/filebeat -path.config /etc/filebeat -path.data /var/lib/filebeat -path.logs /var/log/filebeat |
3)验证文件
1 2 3 |
[root@web01 ~]# ll /tmp/ -rw------- 1 root root 3760 Dec 8 17:47 filebeat_nginx.log |
配置filebeat收集日志到ES
1)配置
1 2 3 4 5 6 7 8 9 10 11 |
[root@web01 ~]# vim /etc/filebeat/filebeat.yml filebeat.inputs: - type: log enabled: true paths: - /var/log/nginx/access.log output.elasticsearch: hosts: ["10.0.0.71:9200"] index: |
2)启动
1 2 3 4 |
[root@web01 ~]# filebeat -e -c /etc/filebeat/filebeat.yml [root@web01 ~]# systemctl start filebeat |
Filebeat收集单类型多个日志到Logstash
1)配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
#编辑Filebeat配置文件 [root@web01 ~]# vim /etc/filebeat/filebeat.yml filebeat.inputs: - type: log paths: - /var/log/nginx/access.log - /usr/local/tomcat/logs/tomcat_access_json.2020-12-08.log document_type: ngx_zls output.logstash: #logstash 服务器地址,可以是多个 hosts: ["10.0.0.81:6666"] #是否开启输出至logstash,默认即为true enabled: true #工作线程数 worker: 1 #压缩级别 compression_level: 3 |
2)重启
1 2 3 |
#重启Filebeat [root@web01 ~]# systemctl restart filebeat |
3)logstash收集filebeat传来的数据到ES
1 2 3 4 5 6 7 8 9 10 11 12 13 |
[root@redis01 ~]# vim /etc/logstash/conf.d/filebeat_logstash_es.conf input { beats { port => "6666" } } output { elasticsearch { hosts => ["10.0.0.71:9200"] index => "filebeat_logstash_%{+YYYY-MM-dd}" } } |
4)启动logstash
1 |
[root@redis01 ~]# /usr/share/logstash/bin/logstash -f /etc/logstash/conf.d/filebeat_logstash_es.conf |