fluent-bit icon indicating copy to clipboard operation
fluent-bit copied to clipboard

[out_loki][net] TCP connection failed: hostname:80 (Connection refused)

Open BetaFold3 opened this issue 5 years ago • 2 comments

Bug Report

Describe the bug Failed to push to Loki when Host is set as a hostname, while succeeded to push if Host is set as IP address, resolved by that very hostname.

To Reproduce

Start server

docker run --name fluentbit --rm --net host -v /var/log/fluentbit.log:/var/log/fluentbit.log -v /root/fluentbit.d:/etc/fluentbit -d fluent/fluent-bit:1.8.2 /fluent-bit/bin/fluent-bit -c /etc/fluentbit/fluentbit.conf

Config file

[SERVICE]
    Flush        1
    Log_File     /var/log/fluentbit.log
    Log_Level    debug
    Parsers_File parsers.conf

[INPUT]
    Name              forward
    Listen            0.0.0.0
    Port              24224
    Buffer_Chunk_Size 1M
    Buffer_Max_Size   100M

[OUTPUT]
    Name   stdout
    Match  *

[OUTPUT]
    Name   loki
    Match  *
    Host   private-hostname
    Port   80
    Labels type=fluentbit

Successful Log when configured Loki plugin with Host as IP address

[2021/07/29 07:59:29] [debug] [task] created task=0x7f9a6bc371e0 id=0 OK
[2021/07/29 07:59:29] [debug] [out coro] cb_destroy coro_id=0
[2021/07/29 07:59:29] [debug] [http_client] not using http_proxy for header
[2021/07/29 07:59:29] [debug] [http_client] header=POST /loki/api/v1/push HTTP/1.1

Host: [censored]:80
Content-Length: 450
User-Agent: Fluent-Bit
Content-Type: application/json

Failed Log when configured Loki plugin with Host as Hostname (changed name due to privacy)

2021/07/29 07:44:52] [debug] [task] created task=0x7facc2e371e0 id=0 OK
[2021/07/29 07:44:52] [debug] [out coro] cb_destroy coro_id=0
[2021/07/29 07:44:52] [error] [net] TCP connection failed: private-hostname:80 (Connection refused)
[2021/07/29 07:44:52] [error] [net] socket #24 could not connect to private-hostname:80
[2021/07/29 07:44:52] [debug] [upstream] connection #-1 failed to private-hostname:80
[2021/07/29 07:44:52] [error] [output:loki:loki.1] no upstream connections available
[2021/07/29 07:44:52] [debug] [out coro] cb_destroy coro_id=0
[2021/07/29 07:44:52] [debug] [retry] new retry created for task_id=0 attempts=1
[2021/07/29 07:44:52] [ warn] [engine] failed to flush chunk '1-1627544691.532196803.flb', retry in 6 seconds: task_id=0, input=forward.0 > output=loki.1 (out_id=1)

nslookup worked for that hostname (changed name due to privacy)

$ docker run --net host --rm -it fluent/fluent-bit:1.8.2-debug nslookup -type=aaaa private-hostname
Server:         2001:4860:4860::8888
Address:        [2001:4860:4860::8888]:53

Non-authoritative answer:
Name:   private-hostname
Address: [censored]

$ docker run --net host --rm -it fluent/fluent-bit:1.8.2-debug nslookup -type=a private-hostname
Server:         2001:4860:4860::8888
Address:        [2001:4860:4860::8888]:53

Non-authoritative answer:
Name:   private-hostname
Address: [censored]

Expected behavior Successful push to Loki

Your Environment

  • Version used: 1.8.2 (tried 1.7.9, same problem)
  • Configuration: posted config file above
  • Server type and version:
  • Operating System and version: Ubuntu 18.04
  • Filters and plugins: Loki

BetaFold3 avatar Jul 29 '21 08:07 BetaFold3

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Aug 29 '21 01:08 github-actions[bot]

This issue was closed because it has been stalled for 5 days with no activity.

github-actions[bot] avatar Sep 04 '21 01:09 github-actions[bot]