在CentOS上通过Filebeat实现日志可视化的步骤如下:
sudo yum install -y filebeat
/etc/filebeat/filebeat.yml
文件,添加或修改以下内容,以配置Filebeat收集系统日志:filebeat.inputs:
- type: log
paths:
- /var/log/*.log
fields:
type: "systemlog"
log_topic: "systemlog"
fields_under_root: true
exclude_lines: ["DBG"]
exclude_files: [".gz"]
output.elasticsearch:
hosts:
- "elasticsearch-host:9200"
index: "system-logs-%{yyyy.MM.dd}"
在这个配置中,paths
指定了要收集的日志文件路径,fields
定义了日志的类型和字段,output.elasticsearch
指定了Elasticsearch的地址和索引名称。
sudo systemctl start filebeat
sudo systemctl enable filebeat
sudo systemctl status filebeat
http://your-kibana-host:5601
在Kibana中,你可以创建索引模式并添加Filebeat生成的索引,然后使用Discover功能来查看和分析日志数据。
filebeat.inputs:
- type: log
paths:
- /var/log/your-application/*.log
processors:
- dissect:
tokenizer: "%{timestamp} %{level} %{message}"
field: "message"
output.elasticsearch:
hosts:
- "elasticsearch-host:9200"
index: "your-application-logs-%{yyyy.MM.dd}"
通过以上步骤,你就可以使用Filebeat在CentOS系统上收集和分析日志数据,并通过Kibana实现日志的可视化。