在Ubuntu上自定义Filebeat配置文件可按以下步骤进行:
/etc/filebeat/filebeat.yml
,用文本编辑器打开,如sudo nano /etc/filebeat/filebeat.yml
。filebeat.inputs
部分,可设置日志文件路径、类型等,如paths: ["/var/log/*.log"]
。output.elasticsearch
部分设置主机、端口、索引等,如hosts: ["localhost:9200"]
,还可通过processors
添加处理器来自定义输出格式,如添加自定义字段processors: - add_fields: fields: custom_field: "custom_value"
。logging.level: info
。sudo systemctl restart filebeat
。