在 CentOS 上运行的 Filebeat 支持的输出(Output)类型与 Filebeat 官方版本一致,和操作系统关系不大。下面按常见场景给你一个完整说明。
直接把日志发送到 Elasticsearch 集群。
output.elasticsearch:
hosts: ["http://localhost:9200"]
username: "elastic"
password: "changeme"
✅ 支持:
通过 Logstash 做日志预处理后再输出。
output.logstash:
hosts: ["localhost:5044"]
✅ 常用于:
将日志发送到 Kafka 消息队列。
output.kafka:
hosts: ["localhost:9092"]
topic: "filebeat-logs"
✅ 适合:
输出到 Redis(List / Channel)。
output.redis:
hosts: ["localhost:6379"]
key: "filebeat"
db: 0
✅ 常用于:
将日志写入本地文件(调试用)。
output.file:
path: "/tmp/filebeat-output"
filename: "filebeat"
⚠️ 不建议生产环境使用
直接输出到标准输出。
output.console:
pretty: true
✅ 常用于:
直接输出到 Elastic Cloud(SaaS)。
output.elasticcloud:
url: "https://xxxx.cloud.es.io"
username: "elastic"
password: "xxxx"
| 输出类型 | 状态 |
|---|---|
| Elasticsearch 2.x / 5.x | 已不支持 |
| Output to syslog | ❌ 不支持 |
| Output to MySQL / MongoDB | ❌ 不支持 |
查看版本:
filebeat version
Filebeat 不支持同时启用多个 output。
❌ 错误示例:
output.elasticsearch:
...
output.logstash:
...
✅ 正确方式:
| 场景 | 推荐输出 |
|---|---|
| ELK 架构 | Elasticsearch |
| 日志复杂解析 | Logstash |
| 高并发 | Kafka |
| 临时缓冲 | Redis |
| 调试 | Console / File |
filebeat export config
或查看配置模板:
filebeat modules list
如果你愿意,可以告诉我:
我可以帮你直接写一份 可用的 filebeat.yml 配置。