要在CentOS系统上使用Filebeat监控日志,可以按照以下步骤进行操作:
首先,下载并安装适合CentOS的Filebeat版本。可以从Elastic官方网站下载RPM包,然后使用yum
进行安装。
cd /opt/software/
wget https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.10.1-linux-x86_64.tar.gz
tar -xvf filebeat-7.10.1-linux-x86_64.tar.gz
mv filebeat-7.10.1-linux-x86_64 filebeat
安装完成后,编辑/etc/filebeat/filebeat.yml
配置文件,指定要监控的日志文件路径和其他相关设置。
filebeat.inputs:
- type: log
enabled: true
paths:
- /var/log/*.log
fields:
type: "systemlog"
log_topic: "systemlog"
fields_under_root: true
exclude_lines: ["DBG"]
exclude_files: [".gz"]
output.elasticsearch:
hosts: ["192.168.122.200:9200"]
username: "elastic"
password: "your_password"
index: "systemlog-%{+YYYY.MM.dd}"
配置完成后,启动Filebeat服务,并设置为开机自启动。
systemctl enable filebeat
systemctl start filebeat
可以使用以下命令查看Filebeat日志,以确保它正在正确地收集和发送日志数据。
sudo journalctl -u filebeat
通过Kibana界面查看收集到的日志数据,并进行可视化展示。确保Kibana已经安装并与Elasticsearch配置正确。
# 访问Kibana界面,通常是 http://your_server_ip:5601
通过以上步骤,您可以在CentOS系统上成功配置并使用Filebeat来监控系统日志,并将日志数据发送到Elasticsearch进行分析和可视化。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>