filebeat 接入kafka

1,在官網下載filebeat
官網下載地址:
https://www.elastic.co/cn/downloadsapache

2,下載kafka
下載地址:
http://archive.apache.org/dist/kafka/bootstrap

3,下載完kafka以後,直接解壓便可
wget -c http://archive.apache.org/dist/kafka/2.1.1/kafka_2.11-2.1.1.tgz
tar -xf kafka-2.1.1-src.tg併發

4,kafka經常使用命令介紹
進入kafka目錄
cd kafka_2.11-2.1.1ide

啓動zookeeper
./bin/zookeeper-server-start.sh ./config/zookeeper.properties &測試

啓動kafka
./bin/kafka-server-start.sh ./config/server.properties &日誌

建立topic
./bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
列出topic
./bin/kafka-topics.sh --list --zookeeper localhost:2181server

啓動生產者併發送消息
./bin/kafka-console-producer.sh --broker-list localhost:9092 --topic testblog

開啓另一個終端,啓動消費者接受消息
./bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginningget

效果圖以下:
生產者:
filebeat 接入kafka
消費者:
filebeat 接入kafkakafka

5,測試成功,如今咱們配置filebeat的配置文件
filebeat.inputs:

  • type: log
    enabled: true
    paths:
    #- /var/log/*.log
    • /var/log/messages #監聽的日誌文件
      filebeat.config.modules:
      path: ${path.config}/modules.d/*.yml
      reload.enabled: false
      setup.template.settings:
      index.number_of_shards: 3
      output.kafka:
      enabled: true
      hosts: ["10.10.100.215:9092","10.10.100.216:9092","10.10.100.217:9092"] # kafka集羣配置
      topic: "caolihua01" #kafka 訂閱的主題

6,啓動filebeat並查看控制檯輸出
filebeat 接入kafka

7,查看kafka是否接受到filebeat收集到的日誌信息
./bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning
filebeat 接入kafka

相關文章
相關標籤/搜索