下载安装地址:
https://www.elastic.co/cn/downloads/beats/filebeat
配置filebeat
filebeat配置分为2个部分,input和output:
input:
filebeat.inputs: # Each - is an input. Most options can be set at the input level, so # you can use different inputs for various configurations. # Below are the input specific configurations. - type: log # Change to true to enable this input configuration. enabled: true # Paths that should be crawled and fetched. Glob based paths. paths: - /var/log/*.log - /www/wwwlogs/**
output:
output.kafka: hosts: \["127.0.0.1:9092"\] # 在这里通过引用fields来指定目标topic topic: 'test-input' version: 0.11.0.0 compression: gzip max\_message\_bytes: 1000000
注意,开启kafka output需要在modules.d/中将kafka.yml.disable改名为 kafka.yml
启动filebeat
./filebeat -e -c filebeat.yml -d "publish" # 直接启动查看启动日志 nohup ./filebeat -e -c filebeat.yml >/dev/null 2>&1 & # 后台方式启动