在 Debian 上,Filebeat 本身不“显示”日志内容,它的作用是采集日志并发送到 Elasticsearch / Logstash / Kafka 等。
所以“看日志”通常分几种情况,我按常见场景给你说明。
如果你是用 apt 安装的 Filebeat:
sudo journalctl -u filebeat -f
查看历史日志:
sudo journalctl -u filebeat --since "1 hour ago"
Filebeat 默认日志路径:
/var/log/filebeat/filebeat
查看:
sudo tail -f /var/log/filebeat/filebeat
sudo cat /etc/filebeat/filebeat.yml
重点看:
filebeat.inputs:
- type: log
paths:
- /var/log/*.log
sudo filebeat test config
sudo filebeat test output
Filebeat 只是读文件:
sudo tail -f /var/log/nginx/access.log
修改 /etc/filebeat/filebeat.yml:
output.console:
pretty: true
然后运行:
sudo filebeat -e -c /etc/filebeat/filebeat.yml
你会看到 Filebeat 采集到的每一条日志 JSON。
⚠️ 调试完记得改回:
output.elasticsearch:
hosts: ["localhost:9200"]
filebeat-*curl -X GET "localhost:9200/filebeat-*/_search?pretty" -H 'Content-Type: application/json' -d'
{
"size": 10,
"sort": [{ "@timestamp": "desc" }]
}'
sudo filebeat modules enable system
sudo filebeat setup
sudo systemctl restart filebeat
sudo usermod -aG adm filebeat
# 看 filebeat 状态
systemctl status filebeat
# 看运行日志
journalctl -u filebeat -f
# 看采集配置
cat /etc/filebeat/filebeat.yml
# 调试输出
filebeat -e -c /etc/filebeat/filebeat.yml
如果你能告诉我:
我可以给你更精确的命令。