新版filebeat8.x读取nginx的access.log到kafka

最简

filebeat.inputs:
- type: log
  enabled: true
  paths:
    - /usr/local/openresty/nginx/logs/access.log

output.kafka:
  enabled: true
  hosts: ["10.10.14.64:9092"]
  topic: nginx-access-log

多个

filebeat.inputs:
- type: log
  enabled: true  
  paths:
    - /var/log/test1.log
  #添加字段可发送至不同topic
  fields:
    kafka_topic: firstTopic    

- type: log
  enabled: true
  paths:
    - /var/log/test2.log
  #添加字段可发送至不同topic
  fields:
    kafka_topic: secondTopic 

output.kafka:
  enabled: true
  #kafka地址,可配置多个用逗号隔开
  hosts: ["192.168.154.128:9092","192.168.154.129:9092"]
  #根据上面添加字段发送不同topic
  topic: '%{[fields.kafka_topic]}'

 

posted @ 2023-10-26 08:39  缤纷世界  阅读(98)  评论(0编辑  收藏  举报