环境
- win10系统
- filebeat 7.10.0
- CentOS7 集群(虚拟机)
- kafka 0.11
第一步 下载filebeat
下载地址
我下载的是图中圈出的压缩包版本,也有MSI版本供下载。
第二步 配置filebeat
- 将下载的压缩包解压到“C:\Program Files\Filebeat”。
- 修改该目录中的配置文件filebeat.yml,主要修改以下几个地方:
- 添加filebeat要采集的源文件相关信息,主要在inputs中。
# ============================== Filebeat inputs ===============================
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 #这里一定要改成true才会生效
# Paths that should be crawled and fetched. Glob based paths.
paths:
#- /var/log/*.log 这是linux中的路径
#- c:\programdata\elasticsearch\logs\*
- e:\Lab\Logs\test.log #日志文件路径
添加输出信息(kafka),主要在output中。
# ---------------------------- kafka Output----------------------------
output.kafka:
# initial brokers for reading cluster metadata hosts是string数组类型,支持多个kafka实例地址(此处不是配置zookeeper地址)
hosts: ["XXXX:9092"]
# message topic selection + partitioning
#发送到kafka的那个topic,我这里事先在fields中配置了一个kafka_topic字段,下边有写
topic: '%{[fields.kafka_topic]}'
version: 0.11.0.0 #kafka版本
partition