要在CentOS上自定义Filebeat的输出,您需要编辑Filebeat的配置文件。以下是自定义Filebeat输出的步骤:
Filebeat的配置文件通常位于/etc/filebeat/filebeat.yml
。使用文本编辑器打开它,例如使用vi或nano:
sudo vi /etc/filebeat/filebeat.yml
在配置文件中,找到output
部分。这里可以定义Filebeat的输出模块。例如,如果您想将日志发送到Elasticsearch,可以使用以下配置:
output.elasticsearch:
hosts: ["localhost:9200"]
index: "filebeat-%{[agent.version]}-%{+yyyy.MM.dd}"
如果您想将日志发送到Logstash,可以使用以下配置:
output.logstash:
hosts: ["localhost:5044"]
某些输出模块允许您自定义设置。例如,如果您使用的是Elasticsearch输出模块,可以自定义索引名称、文档类型等。以下是一个自定义Elasticsearch输出模块设置的示例:
output.elasticsearch:
hosts: ["localhost:9200"]
index: "my-custom-index-%{[agent.version]}-%{+yyyy.MM.dd}"
document_type: "_doc"
pipeline: "my_custom_pipeline"
保存对配置文件的更改并关闭文本编辑器。
要使更改生效,请重启Filebeat服务:
sudo systemctl restart filebeat
现在,Filebeat将使用您自定义的输出设置将日志发送到指定的目标。请确保目标服务(如Elasticsearch或Logstash)已正确配置并可以接收来自Filebeat的日志。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:filebeat在centos上如何自定义输出格式