当前位置: 首页 > 知识库问答 >
问题:

由于EADDRNOTAVAIL,Fluent-bit无法在docker中将日志发送到Fluentd

佟和安
2023-03-14

我试图设置EFK堆栈与流利位在docker容器。虽然我可以将日志从Fluent-bit推送到elasticsearch,但当我试图集成Fluentd时,我遇到了问题。这是确切的错误msg:

意外错误\u class=Errno::EADDRNOTAVAIL error=“地址不可用-绑定(2)”端口24224的“流畅位”

我的docker中的服务组成文件

  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:${TAG}
    ports:
      - '9200:9200'
      - '9300:9300'
    volumes:
      - type: bind
        source: ./config/elasticsearch.yml
        target: /usr/share/elasticsearch/config/elasticsearch.yml
        read_only: true
      - type: volume
        source: elasticsearch
        target: /usr/share/elasticsearch/data
    networks:
      - efk_1
  fluentd:
    image: fluent/fluentd:${FLBV}
    ports:
      - '24224:24224'
    volumes:
      - type: bind
        source: ./config/fluent.conf
        target: /fluentd/etc/fluent.conf
        read_only: true
    networks:
      - efk_1
    depends_on:
      - elasticsearch
  fluent-bit:
    image: fluent/fluent-bit:${FBITV}
    ports:
      - '2020:2020'
    volumes:
      - type: bind
        source: ./config/fluent-bit.conf
        target: /fluent-bit/etc/fluent-bit.conf
        read_only: true
      - type: bind
        source: ./sample_logs
        target: /var/log
    networks:
      - efk_1
    depends_on:
      - fluentd

之前,我直接将日志从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,因此FluentBit将把日志发送到fluentd,fluentd随后将推送到elasticsearch。

流畅位配置:

[SERVICE]
    Flush   2
    Log_Level   debug

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

[OUTPUT]
    Name    forward
    Match   *
    Host    fluentd

Fluentd conf:

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

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

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

这些是我得到的错误:

fluent-bit_1|[2019/11/06 10:31:02][error][io]TCP连接失败:fluentd:24224(连接被拒绝)

fluentd_1 | 2019-11-06 10:31:02 0000[错误]:#0意外错误\u class=Errno::EADDRNOTAVAIL error=“地址不可用-绑定(2)用于\“流畅位\”端口24224”

有人能帮我知道我哪里出错了吗?

共有3个答案

湛功
2023-03-14

您的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位输出:

[OUTPUT]
    Name    forward
    Match   *
    Host    0.0.0.0
    Port    24224

如果您可以让它工作,那么可以调整设置以按名称和端口调用容器

花飞扬
2023-03-14

我认为您的fluentd配置应该如下所示:

<source>
  type forward
  bind 0.0.0.0
  port 24224
</source>

<match fluent_bit>
  type stdout
</match>

就像在文档中一样

可能fluentd应该在绑定字段中有清晰的IP,而不是主机名。

请参阅问题和错误描述。

华佐
2023-03-14

我创建了下一个配置:docker compose。亚马尔

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

流利形态

<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 run和fluent bit能够发送系统日志

 类似资料:
  • 问题内容: 我正在使用slf4j api进行记录的应用程序: (上面的代码显示了正在使用的类和程序包,但是很标准。) 我们使用配置如下的logback: 我们的某些代码利用了使用java.util.logging记录的第三方库- 特别是freemarker。从下面的控制台日志条目中可以看到,logback和jul都正在记录到控制台,但是它们没有使用相同的配置(logback条目使用我们的模式,ju

  • 问题内容: 我有一个测试的Kubernetes集群,我在AWS上创建了elasticsearch,其中包括用于日志管理的Kibana。 端点:https : //search-this-is-my-es- wuktx5la4txs7avvo6ypuuyri.ca-central-1.es.amazonaws.com 据我谷歌搜索,我必须从流利发送日志。然后,我尝试使用本文来实现DaemonSet

  • 我已在我的应用程序(ASP.NET Core)上使用elasticsearch将nlog配置为nlog.config,如下所示: 应用程序上的设置是: 当我通过dotnet-run运行应用程序时,我有一只麋鹿在这样的码头工人那里长大——https://github.com/deviantony/docker-elk 所有日志都会被保存。 但当我将我的应用程序添加到docker映像时,它就不起作用了

  • 我们在AWS ECS Fargate中部署了多个运行NodeJS服务(节点:11 alpine docker image)的容器。 我们已经有一个正在运行的ElasticSearch实例从非Fargate应用程序收集日志。我想将Fargate容器中的日志传递到这个ElasticSearch实例中,但我很难找出最好的方法。 1)似乎一种方法是从Cloudwatch流式传输日志- 2) 我希望我可以运

  • 我们正在使用REST保证来测试一些REST服务。我们需要将请求和响应日志重定向到Log4j日志。我们有以下代码来测试日志重定向: 我们将以下日志输出到log4j文件: 在system.out,我们看到请求和响应的REST保证输出。该输出没有重定向到Log4j文件。如何将控制台输出重定向到Log4j文件?

  • 问题内容: 我对Web服务世界还很陌生,但是具有相关知识。 我需要实现将日志消息发送到Web服务而不是使用 Web Service附加程序 发送到文件的功能。 我是通过在 Google 上搜索该类别之一来阅读的,但我无法验证这一点。 问题答案: 当您扩展该类时,我假设您应该使用应重写的方法来初始化您的webservice类。我已经编写了DatabaseAppender和JmsAppender lo