部署filebeat采集nginx 其余应用请参考
1.下载并安装 Filebeat
第一次使用 Filebeat?请参阅入门指南。https://www.elastic.co/guide/en/beats/filebeat/7.4/filebeat-getting-started.html
curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.4.2-x86_64.rpm
sudo rpm -vi filebeat-7.4.2-x86_64.rpm
2.编辑配置
修改/etc/filebeat/filebeat.yml设置连接信息:
output.elasticsearch:
hosts: ["<es_url>"]
username: "elastic"
password: "<password>"
setup.kibana:
host: "<kibana_url>"
哪里<password>是elastic用户的密码,<es_url>是Elasticsearch<kibana_url>的URL,是Kibana的URL。
本次部署并未使用x-pack安全认证,username&password 可直接注释。以下为示例
setup.kibana:
host: "ADDR:PORT"
output.elasticsearch:
hosts: ["ADDR:PORT"]
3.启用和配置 nginx 模块
sudo filebeat modules enable nginx
修改/etc/filebeat/modules.d/nginx.yml文件中的设置。 以下为示例
- module: nginx
# Access logs
access:
enabled: true
# Set custom paths for the log files. If left empty,
# Filebeat will choose the paths depending on your OS.
var.paths: ["/usr/local/nginx/logs/access.log*"]
# Error logs
error:
enabled: true
# Set custom paths for the log files. If left empty,
# Filebeat will choose the paths depending on your OS.
#var.paths:
var.paths: ["/usr/local/nginx/logs/error.log*"]
4.启动 Filebeat
该
setup
命令加载 Kibana 仪表板。如果已设置仪表板,请省略此命令。sudo filebeat setup sudo service filebeat start sudo systemctl start filebeat
···
即查看filebeat状态是否正常,无误后,kibana找寻对应索引即可。