Docker filebeat 自动发现未检测到 nginx 日志

Docker filebeat autodiscover not detecting nginx logs

在我的 mac 上,我 运行 在 docker 文件中使用 nginx,在 docker 文件中使用 filebeat。

docker run -p 80:80 nginx

以上命令成功运行我可以在浏览器中访问的nginx,输出打印到控制台。

这是我正在构建的 docker 文件,然后 运行ning:

FROM docker.elastic.co/beats/filebeat:7.8.0
COPY filebeat.yml /usr/share/filebeat/filebeat.yml
USER root

这是我在上面提到的filebeat.yml:

  filebeat.autodiscover:
    providers:
      - type: docker
        templates:
          - condition:
              contains:
                docker.container.image: nginx
            config:
              - type: docker
                containers.ids:
                    - "${data.docker.container.id}"
              - module: nginx
                access:
                  enabled: true
                  containers:
                      stream: "stdout"
                error:
                  enabled: true
                  containers:
                      stream: "stderr"
output.console:
    pretty: true  

我运行 filebeat docker 图像使用:

 sudo docker run -it  -v /var/run/docker.sock:/var/run/docker.sock filebeat

docker.sock 问题是因为无法连接到 docker 套接字错误(我认为是某种 docker 用户错误权限)。

以上所有内容都在 docker 容器中获取 filebeat 运行ning。

INFO    [autodiscover]  autodiscover/autodiscover.go:113    Starting autodiscover manager

然而,当我在浏览器中访问 localhost 并触发 nginx 日志时,唯一的输出是偶尔 docker 每 30 秒一次的系统指标:

{"monitoring": {"metrics": {"beat":{"cpu":{"system":{"ticks":40,"time":{"ms":43}},"total":{"ticks":100,"time":{"ms":109},"value":100},"user":{"ticks":60,"time":{"ms":66}}},"handles":{"limit":{"hard":1048576,"soft":1048576},"open":8},"info":{"ephemeral_id":"d3e79d62-6949-4d79-89e8-c595332c18ed","uptime":{"ms":30054}},"memstats":{"gc_next":10249440,"memory_alloc":5520104,"memory_total":17591608,"rss":55390208},"runtime":{"goroutines":23}},"filebeat":{"harvester":{"open_files":0,"running":0}},"libbeat":{"config":{"module":{"running":0}},"output":{"type":"console"},"pipeline":{"clients":0,"events":{"active":0}}},"registrar":{"states":{"current":0},"writes":{"success":1,"total":1}},"system":{"cpu":{"cores":2},"load":{"1":0,"15":0,"5":0,"norm":{"1":0,"15":0,"5":0}}}}}}

未检测到 nginx 日志。

这是我收到的可能相关的警告:

Filebeat is unable to load the Ingest Node pipelines for the configured modules because the Elasticsearch output is not configured/enabled

编辑:我认为这是问题的症结所在,收割机没有找到任何日志:

filebeat":{"harvester":{"open_files":0,"running":0}}

Edit2:问题的根本原因似乎是 Mac 终端无法访问日志文件:/var/lib/docker/containers/${data.docker.container.id}/* .log 因为这不是它们存储在 Mac... =19=]

Mac 上的 Filebeat 不支持收集 docker 日志:

https://github.com/elastic/beats/issues/17310