您的位置:首页 > 教育 > 培训 > Filebeat+Kafka+ELK

Filebeat+Kafka+ELK

2025/4/17 11:51:00 来源:https://blog.csdn.net/QChestnut/article/details/140951676  浏览:    关键词:Filebeat+Kafka+ELK

架构:

在这里插入图片描述

部署:

#配置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.ymltype: 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: truehosts: ["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.confinput {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"#拉取最新数据,从尾部开始拉,从头开始earliestdecorate_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,添加索引,查看日志信息

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com