在CentOS上利用Filebeat进行性能监控,可按以下步骤操作:
安装Filebeat
通过包管理器安装(推荐):
sudo yum install filebeat -y  
或手动下载安装包解压配置。
配置监控目标
/etc/filebeat/filebeat.yml,启用系统模块监控CPU、内存等指标:filebeat.modules:  
- module: system  
  enabled: true  
  period: 10s  # 采集间隔  
filebeat.inputs:  
- type: log  
  enabled: true  
  paths: ["/var/log/*.log"]  
设置输出目标
将数据发送至Elasticsearch(需提前部署):
output.elasticsearch:  
  hosts: ["localhost:9200"]  
  index: "filebeat-%{+yyyy.MM.dd}"  
  # 可选:启用认证  
  # username: "elastic"  
  # password: "your_password"  
启动与验证
sudo systemctl start filebeat  
sudo systemctl enable filebeat  
sudo systemctl status filebeat  # 检查状态  
通过curl http://localhost:9200/_cat/indices确认数据是否写入Elasticsearch。
可视化分析
filebeat-*),在Discover页面查看原始日志。高级配置(可选)
monitoring模块,将Filebeat运行状态(如CPU、内存占用)发送至Elasticsearch。说明:Filebeat本身不直接提供性能分析功能,需依赖Elasticsearch和Kibana进行数据存储与可视化。若需更专业的性能监控,可结合Prometheus+Grafana方案。
参考来源: