首先先安装EFK
docker-compose.yml
version: '3'
#如果已经安装过elasticsearch可将elasticsearch下配置全部删除
services:
elasticsearch:
image: elasticsearch:7.14.0
ports:
- "9200:9200"
environment:
- discovery.type=single-node
- ES_JAVA_OPTS=-Xmx256m -Xms256m
kibana:
image: kibana:7.14.0
ports:
- "5601:5601"
depends_on:
- elasticsearch
environment:
- ELASTICSEARCH_HOSTS=http://elasticsearch:9200
- I18N_LOCALE="zh-CN"
filebeat:
image: elastic/filebeat:7.14.0
volumes:
- ./filebeat.yml:/usr/share/filebeat/filebeat.yml
#日志挂载位置
- /opt/logs:/usr/share/filebeat/logs
depends_on:
- elasticsearch
command: ["-e"]
filebeat.inputs:
- type: log
paths:
- /usr/share/filebeat/logs/*.log
output.elasticsearch:
hosts: ["your IP:9200"]
配置完成后在文件所在目录下执行
docker-compose up -d
然后配置我们的项目日志配置
配置完成后将项目打包进行发布,可以先测试一下查看你的logs里时候生成了日志,或者查看日志是否正确,然后访问
your Ip:5601 界面
![(https://img-blog.csdnimg.cn/direct/86f93770bb8a4c47950a776e5f00fa71.png)