在CentOS环境下,Filebeat进行日志分析的步骤如下:
sudo yum install -y filebeat
,也可从Elastic官网下载RPM包安装。/etc/filebeat/filebeat.yml
文件,指定要收集的日志文件路径,如filebeat.inputs: - type: log paths: - /var/log/*.log
,还可设置输出到Elasticsearch的地址等参数,如output.elasticsearch: hosts: ["localhost:9200"]
。filebeat.modules: - enabled: nginx
。sudo systemctl start filebeat
命令启动服务,并设置为开机自启动sudo systemctl enable filebeat
。curl -X GET "localhost:9200/_cat/indices?v&pretty"
命令查看Elasticsearch中是否有Filebeat生成的索引,也可在Kibana中查看和分析日志。