1.参考文档
https://www.cnblogs.com/tchua/p/11049589.html
https://www.cnblogs.com/springboot/p/9278668.html
2.创建独立网络
docker network create --driver bridge --subnet=172.18.12.0/16 --gateway=172.18.1.1 elk-net
3.ELK集成docker
https://hub.docker.com/r/sebp/elk/tags
docker run -dit --network=elk-net --ip 172.18.12.1 --name elk -p 5601:5601 -p 9200:9200 -p 5044:5044 sebp/elk:660
访问: http://localhost:5601
4.下载tomcat(测试用)
docker run -dit --network=elk-net --ip 172.18.12.5 --name elk-tomcat-filebeat -p 8888:8080 tomcat:9.0.35-jdk8-openjdk
说明安装成功
5.在tomcat的container中安装filebeat
- 下载filebeat
curl -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-6.6.0-amd64.deb
- 在tomcat容器中安装filebeat
docker cp filebeat-6.6.0-amd64.deb elk-tomcat-filebeat:/usr/local
docker exec -it elk-tomcat-filebeat bash
cd /usr/local
dpkg -i filebeat-6.6.0-amd64.deb
6.在tomcat的container中配置
- 将配置文件从container中拷贝出来
docker cp elk-tomcat-filebeat:/etc/filebeat/filebeat.yml .
-
修改配置
enabled: true
/usr/local/tomcat/logs/*.log
hosts: [“172.18.1.1:9200”] -
修改后放回容器
docker cp filebeat.yml elk-tomcat-filebeat:/etc/filebeat/filebeat.yml
- 启动filebeat
docker exec -it elk-tomcat-filebeat bash
filebeat modules enable elasticsearch
filebeat setup
filebeat -e