【问题标题】:Fluent-bit unable to ship logs to fluentd in docker due to EADDRNOTAVAIL由于 EADDRNOTAVAIL,Fluent-bit 无法将日志发送到 docker 中的 fluentd
【发布时间】:2019-11-06 10:59:31
【问题描述】:

我正在尝试在 docker 容器上使用 fluent-bit 设置 EFK 堆栈。虽然我可以将日志从 fluent-bit 推送到 elasticsearch,但当我尝试集成 fluentd 时,我遇到了问题。这是确切的错误消息:

意外错误error_class=Errno::EADDRNOTAVAIL error="地址不可用 - bind(2) for \"fluent-bit\" 端口 24224"

我的 docker-compose 文件中的服务

弹性搜索: 图片:docker.elastic.co/elasticsearch/elasticsearch:${TAG} 端口: - '9200:9200' - '9300:9300' 卷: - 类型:绑定 来源:./config/elasticsearch.yml 目标:/usr/share/elasticsearch/config/elasticsearch.yml 只读:真 - 类型:体积 来源:弹性搜索 目标:/usr/share/elasticsearch/data 网络: - efk_1 流利的: 图片:流利/流利:${FLBV} 端口: - '24224:24224' 卷: - 类型:绑定 来源:./config/fluent.conf 目标:/fluentd/etc/fluent.conf 只读:真 网络: - efk_1 取决于: - 弹性搜索 流利位: 图片:流利/流利位:${FBITV} 端口: - '2020:2020' 卷: - 类型:绑定 来源:./config/fluent-bit.conf 目标:/fluent-bit/etc/fluent-bit.conf 只读:真 - 类型:绑定 来源:./sample_logs 目标:/var/log 网络: - efk_1 取决于: - 流利

以前我像这样直接将日志从 fluent-bit 推送到 elasticsearch,而无需在任何地方进行 fluentd 配置:

[SERVICE]
    Flush   2
    Log_Level   debug

[INPUT]
    Name    tail
    Path    /var/log/log.txt

[OUTPUT]
    Name    es
    Match   *
    Host    elasticsearch
    Port    9200

这成功将日志推送到elasticsearch,但是现在我在中间添加了fluentd,所以fluent-bit会将日志发送到fluentd,然后再推送到elasticsearch。

流利的位配置:

[SERVICE]
    Flush   2
    Log_Level   debug

[INPUT]
    Name    tail
    Path    /var/log/log.txt

[OUTPUT]
    Name    forward
    Match   *
    Host    fluentd

流利的配置:

<source>
    @type forward
    bind fluent-bit
</source>

<match **>
    @type stdout
</match>

这给了我错误,因为即使它们是同一个 docker 网络的一部分,它们也无法检测到地址。

这些是我遇到的错误:

流利位_1 | [2019/11/06 10:31:02] [error] [io] TCP 连接失败:fluentd:24224(连接被拒绝)

fluentd_1 | 2019-11-06 10:31:02 +0000 [错误]:#0 意外错误 error_class=Errno::EADDRNOTAVAIL 错误="地址不可用 - 绑定 (2) 用于 \"fluent-bit\" 端口 24224"

有人可以帮我知道我在哪里犯了错误吗?

【问题讨论】:

    标签: docker docker-compose fluentd fluent-bit


    【解决方案1】:

    我创建了下一个配置: docker-compose.yaml

    version: "3.7"
    
    services:
      fluentd:
        image: fluent/fluentd:v1.7.4-1.0
        ports:
          - '24224:24224'
        volumes:
          - type: bind
            source: ./config/fluent.conf
            target: /fluentd/etc/fluent.conf
            read_only: true
      fluent-bit:
        image: fluent/fluent-bit:0.14
        ports:
          - '2020:2020'
        volumes:
          - type: bind
            source: ./config/fluent-bit.conf
            target: /fluent-bit/etc/fluent-bit.conf
            read_only: true
          - type: bind
            source: /var/log/
            target: /var/log/
        depends_on:
          - fluentd
    

    fluent.conf

    <source>
      @type forward
      bind 0.0.0.0
      port 24224
    </source>
    
    <match test>
      @type stdout
    </match>
    

    fluent-bit.conf

    [SERVICE]
        Flush   2
        Log_Level   debug
    
    [INPUT]
        Name    tail
        Path    /var/log/syslog
        Tag     test
    
    [OUTPUT]
        Name    forward
        Match   *
        Host    fluentd
    

    在这些配置中,fluentd 运行和 fluent-bit 能够发送 syslog

    【讨论】:

    • 我该如何测试这个?
    • 运行 docker-compose
    【解决方案2】:

    我认为您的流利配置应该是这样的:

    <source>
      type forward
      bind 0.0.0.0
      port 24224
    </source>
    
    <match fluent_bit>
      type stdout
    </match>
    

    As in docs

    可能 fluentd 应该有明确的 IP 而不是绑定字段中的主机名。

    请参阅issuethe error description

    【讨论】:

    • 但是由于我在docker-compose文件中添加了两者,如果我添加服务名称,它不会自动绑定正确的ip吗?
    • 并更改绑定地址给出了此错误:>fluent-bit_1 | [2019/11/07 05:17:11] [错误] [io] TCP 连接失败:0.0.0.0:24224(连接被拒绝)>fluent-bit_1 | [2019/11/07 05:17:11] [错误] [out_fw] 没有可用的上游连接
    【解决方案3】:

    您的 fluentd 配置需要在输入时绑定到 0.0.0.0,并将输出发送到 ES:

    <source>
        @type forward
        port 24224
        bind 0.0.0.0
    </source>
    
    <match **>
        @type copy
        <store>
          @type               elasticsearch
          host                ${ELASTICSEARCH_URL}
          port                9200
        </store>
    </match>
    

    甚至可以更改您的 Fluent Bit 输出:

    [OUTPUT]
        Name    forward
        Match   *
        Host    0.0.0.0
        Port    24224
    

    如果你可以让它工作,那么也许可以调整设置以通过名称和端口调用容器

    【讨论】:

      猜你喜欢
      • 2022-07-07
      • 2020-11-08
      • 1970-01-01
      • 2022-08-19
      • 1970-01-01
      • 1970-01-01
      • 2015-12-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多