Filebeat收集nginx容器日志并同步到Elastic Cloud
1)Filebeat工作原理
Filebeat是一个用于转发和集中日志数据的轻量级传送程序。作为代理安装在服务器上,Filebeat监视指定的日志文件或位置,收集日志事件,并将它们转发到Elasticsearch或Logstash进行索引。
本文摘选自本人gitbook,地址:https://maxidea.gitbook.io/k8s-testing/
转载请标注出处。
2)目标
设置filebeat容器收集nginx容器的日志,并收集到Elastic Cloud上的Elasticsearch Service
3)docker.elastic.co镜像加速
由于官方filebeat镜像存放在官方仓库docker.elastic.co,这个仓库在国内访问速度很慢,所以我们直接用已经有阿里云镜像加速的dockerhub仓库地址。(具体加速配置可以参考https://developer.aliyun.com/mirror/docker-ce)
拉取dockerhub上filebeat镜像:
docker pull store/elastic/filebeat:7.6.2
4)下载配置文件
下载官方的配置文件:
curl -L -O https://raw.githubusercontent.com/elastic/beats/7.6/deploy/docker/filebeat.docker.yml
filebeat.docker.yml文件内容,无需修改:
filebeat.config:
modules:
path: $