Filebeat+Kafka+ELK

架构:

部署:

bash 复制代码
#配置nginx,部署filebeat
systemctl stop firewalld
setenforce 0
systemctl restart nginx

#解压filebeat
tar -xf filebeat-6.7.2-linux-x86_64.tar.gz
mv filebeat-6.7.2-linux-x86_64 filebeat

#日志收集
cd firebeat
vim filebeat.yml

type: log
enabled: true
paths:
  - /usr/local/nginx/logs/access.log
tags: ["access"]

type: log
enabled: true
paths:
  - /usr/local/nginx/logs/error.log
tags: ["error"]

#output.elasticsearch 添加注释
output.kafka: 取消注释
  enabled: true
  hosts: ["192.168.230.21:9092","192.168.230.22:9092","192.168.230.23:9092"]
  topic: "xy102"

#开启filebeat
./filebeat -e -c filebeat.yml

#配置logstash
cd /etc/logstash/conf.d
vim kafka.conf

input {
   kafka {
     bootstrap_servers => "192.168.230.21:9092,192.168.230.22:9092,192.168.230.23:9092"
     topics => "xy102"
     type => "nginx_kafka"
     codec => "json"
     auto_offset_reset => "latest"
     #拉取最新数据,从尾部开始拉,从头开始earliest
     decorate_events => true
     #传递给es数据库时,额外的添加kafka的属性数据
   }
}
output {
   if "access" in [tags] {
    elasticsearch {
       hosts => ["192.168.230.10:9200","192.168.230.20:9200"]
       index => "nginx_access-%{+YYYY.MM.dd}"
      
    }
   }
   if "error" in [tags] {
    elasticsearch {
       hosts => ["192.168.230.10:9200","192.168.230.20:9200"]
       index => "nginx_error-%{+YYYY.MM.dd}"
    }
  }
}

#开启logstash
logstash -f kafka.conf --path.data /opt/test20 &

#浏览器访问192.168.230.30:5601登录kibana,添加索引,查看日志信息
相关推荐
indexsunny2 天前
互联网大厂Java求职面试实战:Spring Boot微服务在电商场景中的应用与挑战
java·spring boot·redis·面试·kafka·oauth2·microservices
JackSparrow4142 天前
使用Elasticsearch代替数据库like以加快查询的各种技术方案+实现细节
大数据·clickhouse·elk·elasticsearch·搜索引擎·postgresql·全文检索
百结2142 天前
zookeeper+kafka消息队列群集部署
分布式·zookeeper·kafka
白露与泡影2 天前
从零学习Kafka:ZooKeeper vs KRaft
学习·zookeeper·kafka
Devin~Y2 天前
大厂 Java 面试实战:Spring Boot 微服务 + Redis 缓存 + Kafka 消息 + Kubernetes + RAG(小Y水货翻车记)
java·spring boot·redis·kafka·spring security·jwt·oauth2
indexsunny3 天前
互联网大厂Java面试实录:微服务+Spring Boot在电商场景中的应用
java·spring boot·redis·微服务·eureka·kafka·spring security
Jackyzhe3 天前
从零学习Kafka:ZooKeeper vs KRaft
学习·zookeeper·kafka
工作log3 天前
从零搭建 ELK + Kafka 日志收集系统(Spring Boot + Logback 直连 Kafka)
spring boot·elk·kafka
QC·Rex3 天前
消息队列架构设计 - Kafka/RocketMQ/RabbitMQ 深度对比与实战
kafka·rabbitmq·rocketmq