在 CentOS 上给 Filebeat 配置证书,通常出现在以下两种场景:
下面以 Filebeat → Elasticsearch / Logstash(TLS) 为例说明。
常见证书文件:
ca.crt:CA 证书(必须)client.crt:Filebeat 客户端证书(可选,双向认证时需要)client.key:客户端私钥(可选)将证书放到例如:
/etc/filebeat/certs/
设置权限(非常重要):
chmod 600 /etc/filebeat/certs/*
chown root:root /etc/filebeat/certs/*
编辑配置文件:
vi /etc/filebeat/filebeat.yml
output.elasticsearch:
hosts: ["https://es-node1:9200"]
username: "filebeat_writer"
password: "your_password"
ssl:
enabled: true
certificate_authorities: ["/etc/filebeat/certs/ca.crt"]
output.elasticsearch:
hosts: ["https://es-node1:9200"]
ssl:
enabled: true
certificate_authorities: ["/etc/filebeat/certs/ca.crt"]
certificate: "/etc/filebeat/certs/client.crt"
key: "/etc/filebeat/certs/client.key"
output.logstash:
hosts: ["logstash-host:5044"]
ssl:
enabled: true
certificate_authorities: ["/etc/filebeat/certs/ca.crt"]
certificate: "/etc/filebeat/certs/client.crt"
key: "/etc/filebeat/certs/client.key"
ssl:
verification_mode: none
⚠️ 生产环境 不要使用
systemctl restart filebeat
systemctl status filebeat
查看日志:
journalctl -u filebeat -f
测试配置:
filebeat test output
failed to load SSL certificate
✅ 检查证书文件权限和属主
✅ 使用 绝对路径
setsebool -P filebeat_connect_any 1
或临时关闭测试:
setenforce 0
如果你能告诉我:
我可以给你一份 可直接用的 filebeat.yml 示例。