【问题标题】:Using fluentd in docker to get nginx logs在docker中使用fluentd获取nginx日志
【发布时间】:2017-10-09 14:20:31
【问题描述】:

我有一个场景,其中nginx 在一个容器中运行,fluentd 在另一个容器中,我将nginx 日志映射到var/logs/nginx 目录,但我无法使用@987654325 将日志检索到弹性搜索@,请帮我解决这个问题:

fluentd.conf

<source>
  @type forward
  port 24224
  bind 0.0.0.0
</source>
<source>
  @type tail
  path /var/log/nginx/access_in_log
  #pos_file /var/log/td-agent/nginx-access.log.pos
  tag nginx.access
  format nginx
</source>


<match nginx.access>
  @type elasticsearch
  logstash_format true
  host elasticsearchkibana
  port 9200
  index_name nginxindex
  type_name nginxlogtype
</match>

请让我知道我错过了什么。

【问题讨论】:

    标签: docker nginx kibana fluentd


    【解决方案1】:

    我通过使用 nginx syslog 驱动程序 (http://nginx.org/en/docs/syslog.html) 解决了这个问题。

    在我的 nginx 容器内的 nginx.conf 中,我有以下设置:

    http {
    ...
    access_log syslog:server=<FLUENTD_HOST>:<FLUENTD_PORT>,tag=nginx_access;    
    error_log syslog:server=<FLUENTD_HOST>:<FLUENTD_PORT>,tag=nginx_error info;  
    

    在我的 Fluentd 容器内的 fluent.conf 中,我有以下配置:

    <source>
        @type syslog
        port 5141
        tag "syslog"
    </source>
    

    日志如下所示:

    【讨论】:

    • 您好,您能否为您的整个应用程序提供 docker-compose yaml?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-02-06
    • 1970-01-01
    • 1970-01-01
    • 2018-06-19
    • 2018-07-18
    • 1970-01-01
    • 2021-01-04
    相关资源
    最近更新 更多