在Debian系统上利用Filebeat进行日志收集的步骤如下:
sudo apt update
sudo apt install filebeat
sudo nano /etc/filebeat/filebeat.yml
filebeat.inputs
部分,添加要监控的日志文件路径。例如:filebeat.inputs:
- type: log
enabled: true
paths:
- /var/log/*.log
- /var/log/myapp/*.log
ignore_older: 72h
这个配置会让Filebeat监控 /var/log/*.log
和 /var/log/myapp/*.log
路径下的所有日志文件,并忽略超过72小时的文件。
output.elasticsearch:
hosts: ["localhost:9200"]
index: "filebeat-%{+yyyy.MM.dd}"
确保你的Elasticsearch服务正在运行并可以接受来自Filebeat的连接。
sudo systemctl start filebeat
sudo systemctl enable filebeat
sudo systemctl status filebeat
sudo journalctl -u filebeat -f
以上步骤应该可以帮助你在Debian系统中成功安装和配置Filebeat,开始收集指定的日志文件并将其发送到Elasticsearch进行存储和分析。请根据实际需求调整配置文件中的路径和索引名称。