在CentOS上使用Filebeat进行安全审计,通常涉及以下几个步骤:
sudo yum install -y filebeat
或者从官网下载安装包进行安装:
wget https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.14.0-x86_64.rpm
sudo rpm -ivh filebeat-7.14.0-x86_64.rpm
/etc/filebeat/filebeat.yml
文件,添加或修改以下内容:filebeat.inputs:
- type: log
paths:
- /var/log/*.log
- /var/log/messages
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}"
在这个配置中,filebeat.inputs
部分指定了Filebeat应该监控的日志文件路径,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}"
通过以上步骤,你就可以在CentOS系统上成功部署和使用Filebeat来收集和分析日志数据了。