在CentOS上使用Filebeat分析日志,可按以下步骤操作:
sudo yum install filebeat -y安装。/etc/filebeat/filebeat.yml文件,指定要监控的日志文件路径,如filebeat.inputs: - type: log enabled: true paths: - /var/log/*.log,还可设置输出目标为Elasticsearch,如output.elasticsearch: hosts: - "localhost:9200",并根据需要添加处理器,如processors: - dissect: tokenizer: "%{timestamp} %{level} %{message}" field: "message"来解析日志。sudo systemctl start filebeat启动服务,并通过sudo systemctl enable filebeat设置开机自启。sudo systemctl status filebeat检查服务状态,确保其正常运行。