阅读量:2
以下是在Ubuntu上使用Filebeat进行实时监控的步骤:
-
安装Filebeat
sudo apt update sudo apt install filebeat -
配置监控目标
编辑配置文件/etc/filebeat/filebeat.yml,在filebeat.inputs中指定要监控的文件或目录,例如:filebeat.inputs: - type: log enabled: true paths: - /var/log/syslog - /var/log/nginx/*.log可选配置:
ignore_older:忽略超过指定时间的旧文件(如72h)。exclude_files:排除特定文件(如隐藏文件)。
-
设置输出目标
配置将数据发送到Elasticsearch或Logstash,例如:output.elasticsearch: hosts: ["localhost:9200"]或发送到Logstash:
output.logstash: hosts: ["localhost:5044"] -
启动并验证
sudo systemctl start filebeat sudo systemctl enable filebeat sudo systemctl status filebeat # 检查状态 sudo journalctl -u filebeat -f # 查看实时日志 -
可选:启用监控端点
在配置中添加以下内容,启用Filebeat的监控API(需配置认证):management.endpoint: "http://localhost:9200" management.enabled: true通过访问
http://<服务器IP>:9200/_nodes/stats/filebeat查看监控数据。
说明:确保后端服务(如Elasticsearch/Logstash)已运行,且Filebeat有权限访问日志文件。如需监控特定应用日志(如Java),需在路径中指定对应日志文件位置。
以上就是关于“如何使用Ubuntu Filebeat进行实时监控”的相关介绍,筋斗云是国内较早的云主机应用的服务商,拥有10余年行业经验,提供丰富的云服务器、租用服务器等相关产品服务。云服务器资源弹性伸缩,主机vCPU、内存性能强悍、超高I/O速度、故障秒级恢复;电子化备案,提交快速,专业团队7×24小时服务支持!
简单好用、高性价比云服务器租用链接:https://www.jindouyun.cn/product/cvm