1.下载和安装
https://www.elastic.co/downloads/beats/filebeat
这里选择 LINUX 64-BIT 即方式一
wget https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-5.6.3-linux-x86_64.tar.gz
tar -zxvf filebeat-5.6.3-linux-x86_64.tar.gz
2.配置Filebeat
环境说明:
1)elasticsearch和logstash 在不同/相同的服务器上,只发送数据给logstash/elasticsearch
2)监控nginx日志
3)监控站点日志
2.1配置
编辑filebeat.yml
修改为
filebeat.prospectors: - input_type: log paths: - /www/wwwLog/www.foxwho.com/*.log input_type: log document_type: nginx-www.foxwho.com multiline.pattern: '^\[' multiline.negate: true multiline.match: after - input_type: log paths: - /www/wwwroot/www.foxwho.com/runtime/log/*/[0-9]*[_\w]?*.log input_type: log document_type: web-www.foxwho.com multiline.pattern: '^\[' multiline.negate: true multiline.match: after #output.elasticsearch: # hosts: ["localhost:9200"] # index: "filebeat-www.babymarkt.cn" # template.name: "filebeat" # template.path: "filebeat.template.json" # template.overwrite: false output.logstash: hosts: ["10.1.5.65:5044"] ...其他部分没有改动,不需要修改
2.启动
2.1 测试
./filebeat -e -c filebeat.yml -d "Publish"
如果能看到一堆东西输出,表示正在向elasticsearch或logstash发送日志。
如果是elasticsearch可以浏览:http://localhost:9200/_search?pretty 如果有新内容返回,表示ok
测试正常后,Ctrl+C结束
2.2启动
nohup ./filebeat -e -c filebeat.yml &
上面会转入后台运行
2.3停止
查找进程 ID
ps -ef |grep filebeat
KILL他
kill -9 id
每次修改Filebeat配置,重启Filebeat才能生效
浙公网安备 33010602011771号