在Ubuntu上,Filebeat可以通过配置文件将数据转发到其他服务器或服务。以下是使用Filebeat将数据转发到Elasticsearch和Logstash的步骤:
安装Filebeat:
sudo apt-get update
sudo apt-get install filebeat
配置Filebeat:
编辑Filebeat的配置文件 /etc/filebeat/filebeat.yml。
filebeat.inputs:
- type: log
enabled: true
paths:
- /var/log/*.log
output.elasticsearch:
hosts: ["your_elasticsearch_host:9200"]
index: "filebeat-%{[agent.version]}-%{+yyyy.MM.dd}"
将 your_elasticsearch_host 替换为你的Elasticsearch服务器地址。
启动Filebeat:
sudo systemctl start filebeat
sudo systemctl enable filebeat
安装Filebeat: 同上。
配置Filebeat:
编辑Filebeat的配置文件 /etc/filebeat/filebeat.yml。
filebeat.inputs:
- type: log
enabled: true
paths:
- /var/log/*.log
output.logstash:
hosts: ["your_logstash_host:5044"]
将 your_logstash_host 替换为你的Logstash服务器地址。
启动Filebeat: 同上。
/etc/filebeat/filebeat.yml 文件,修改 logging.level 设置。如果你的Elasticsearch启用了X-Pack安全功能,需要在Filebeat配置中添加用户名和密码:
output.elasticsearch:
hosts: ["your_elasticsearch_host:9200"]
index: "filebeat-%{[agent.version]}-%{+yyyy.MM.dd}"
username: "your_username"
password: "your_password"
如果你的Logstash启用了X-Pack安全功能,需要在Filebeat配置中添加认证信息:
output.logstash:
hosts: ["your_logstash_host:5044"]
ssl.enabled: true
ssl.certificate_authorities: ["/etc/filebeat/logstash-ca.pem"]
ssl.certificate: "/etc/filebeat/logstash.pem"
ssl.key: "/etc/filebeat/logstash-key.pem"
user: "your_username"
password: "your_password"
通过以上步骤,你可以在Ubuntu上配置Filebeat将数据转发到Elasticsearch或Logstash。