Nur*_*yev 3 nginx docker elastic-stack filebeat
我使用默认的 nginx 镜像和 Filebeat 来读取日志并将其发送到 ELK。两个容器(nginx 容器和 Filebeat 容器)都位于同一主机上。
这是 nginx 镜像的 Dockerfile
FROM nginx
COPY . /usr/share/nginx/html/
EXPOSE 80
Run Code Online (Sandbox Code Playgroud)
在我的 nginx 容器中,访问日志转到STDOUT,错误日志转到STDERR。
当我从主机提示时,docker logs <nginx-containter-id>我可以看到来自 nginx 容器的日志。但主机上容器的文件夹中没有任何内容 ( /var/lib/docker/containers/nginx-container-id)
如何设置filebeat读取日志?
每个容器都有自己的日志文件,您可以通过以下方式知道它在哪里:
docker inspect --format='{{.LogPath}}' <nginx-containter-id>
Run Code Online (Sandbox Code Playgroud)
它会告诉您日志文件的路径。
参考资料:
https://docs.docker.com/config/containers/logging/json-file/
https://docs.docker.com/config/containers/logging/configure/#configure-the-default-logging-driver
| 归档时间: |
|
| 查看次数: |
9248 次 |
| 最近记录: |