Skip to content

Error writing to outputs.amqp after reconnect, started around 1.38Β #19676

Closed

Description

@pstadt

Relevant telegraf.conf

[[outputs.amqp]]
  brokers = ["amqps://mq01:5671/%2f", "amqps://mq02:5671/%2f", "amqps://mq:5671/%2f"]
  username = "telegraf"
  password = "*************"
  auth_method = "PLAIN"
  tls_ca = "/etc/telegraf/telegraf-ca.pem"
  tls_cert = "/etc/telegraf/telegraf-cert.pem"
  tls_key = "/etc/telegraf/telegraf-key.pem"

Logs from Telegraf

Sep 11 11:16:39 client01 telegraf[510936]: 2026-09-11T09:16:39Z D! [agent] Attempting connection to [outputs.amqp]
Sep 11 11:16:39 client01 telegraf[510936]: 2026-09-11T09:16:39Z D! [outputs.amqp] Connecting to "amqps://mq01:5671/%2f"
Sep 11 11:16:40 client01 telegraf[510936]: 2026-09-11T09:16:40Z D! [outputs.amqp] Connected to "amqps://mq01:5671/%2f"
Sep 11 11:16:40 client01 telegraf[510936]: 2026-09-11T09:16:40Z D! [agent] Successfully connected to outputs.amqp
Sep 11 11:16:50 client01 telegraf[510936]: 2026-09-11T09:16:50Z D! [outputs.amqp] Wrote batch of 38 metrics in 2.883056ms
Sep 11 11:16:50 client01 telegraf[510936]: 2026-09-11T09:16:50Z D! [outputs.amqp] Buffer fullness: 0 / 10000 metrics
Sep 11 11:17:00 client01 telegraf[510936]: 2026-09-11T09:17:00Z D! [outputs.amqp] Wrote batch of 21 metrics in 1.94754ms
Sep 11 11:17:00 client01 telegraf[510936]: 2026-09-11T09:17:00Z D! [outputs.amqp] Buffer fullness: 0 / 10000 metrics
Sep 11 11:17:10 client01 telegraf[510936]: 2026-09-11T09:17:10Z D! [outputs.amqp] Wrote batch of 22 metrics in 2.084154ms


Sep 11 11:27:10 client01 telegraf[510936]: 2026-09-11T09:27:10Z D! [outputs.amqp] Buffer fullness: 0 / 10000 metrics
Sep 11 11:27:20 client01 telegraf[510936]: 2026-09-11T09:27:20Z D! [outputs.amqp] Wrote batch of 22 metrics in 1.193013ms
Sep 11 11:27:20 client01 telegraf[510936]: 2026-09-11T09:27:20Z D! [outputs.amqp] Buffer fullness: 0 / 10000 metrics
Sep 11 11:27:30 client01 telegraf[510936]: 2026-09-11T09:27:30Z D! [outputs.amqp] Wrote batch of 21 metrics in 782.756Β΅s
Sep 11 11:27:30 client01 telegraf[510936]: 2026-09-11T09:27:30Z D! [outputs.amqp] Buffer fullness: 0 / 10000 metrics
Sep 11 11:27:40 client01 telegraf[510936]: 2026-09-11T09:27:40Z D! [outputs.amqp] Connecting to "amqps://mq:5671/%2f"
Sep 11 11:27:45 client01 telegraf[510936]: 2026-09-11T09:27:45Z D! [outputs.amqp] Error connecting to "amqps://mq:5671/%2f" - dial tcp: lookup mq: i/o timeout
Sep 11 11:27:45 client01 telegraf[510936]: 2026-09-11T09:27:45Z D! [outputs.amqp] Connecting to "amqps://mq01:5671/%2f"
Sep 11 11:27:50 client01 telegraf[510936]: 2026-09-11T09:27:50Z W! [agent] ["outputs.amqp"] did not complete within its flush interval
Sep 11 11:27:50 client01 telegraf[510936]: 2026-09-11T09:27:50Z D! [outputs.amqp] Buffer fullness: 43 / 10000 metrics
Sep 11 11:27:59 client01 telegraf[510936]: 2026-09-11T09:27:59Z D! [outputs.amqp] Error connecting to "amqps://mq01:5671/%2f" - Exception (501) Reason: "EOF"
Sep 11 11:27:59 client01 telegraf[510936]: 2026-09-11T09:27:59Z D! [outputs.amqp] Connecting to "amqps://mq02:5671/%2f"
Sep 11 11:28:00 client01 telegraf[510936]: 2026-09-11T09:28:00Z W! [agent] ["outputs.amqp"] did not complete within its flush interval
Sep 11 11:28:00 client01 telegraf[510936]: 2026-09-11T09:28:00Z D! [outputs.amqp] Buffer fullness: 65 / 10000 metrics
Sep 11 11:28:04 client01 telegraf[510936]: 2026-09-11T09:28:04Z D! [outputs.amqp] Error connecting to "amqps://mq02:5671/%2f" - dial tcp: lookup mq02: i/o timeout
Sep 11 11:28:04 client01 telegraf[510936]: 2026-09-11T09:28:04Z D! [outputs.amqp] Buffer fullness: 65 / 10000 metrics
Sep 11 11:28:04 client01 telegraf[510936]: 2026-09-11T09:28:04Z E! [agent] Error writing to outputs.amqp: could not connect to any broker
Sep 11 11:28:10 client01 telegraf[510936]: 2026-09-11T09:28:10Z D! [outputs.amqp] Connecting to "amqps://mq01:5671/%2f"
Sep 11 11:28:13 client01 telegraf[510936]: 2026-09-11T09:28:13Z D! [outputs.amqp] Error connecting to "amqps://mq01:5671/%2f" - Exception (403) Reason: "username or password not allowed"
Sep 11 11:28:13 client01 telegraf[510936]: 2026-09-11T09:28:13Z D! [outputs.amqp] Connecting to "amqps://mq02:5671/%2f"
Sep 11 11:28:18 client01 telegraf[510936]: 2026-09-11T09:28:18Z D! [outputs.amqp] Error connecting to "amqps://mq02:5671/%2f" - dial tcp: lookup mq02: i/o timeout
Sep 11 11:28:18 client01 telegraf[510936]: 2026-09-11T09:28:18Z D! [outputs.amqp] Connecting to "amqps://mq:5671/%2f"
Sep 11 11:28:20 client01 telegraf[510936]: 2026-09-11T09:28:20Z W! [agent] ["outputs.amqp"] did not complete within its flush interval
Sep 11 11:28:20 client01 telegraf[510936]: 2026-09-11T09:28:20Z D! [outputs.amqp] Buffer fullness: 108 / 10000 metrics
Sep 11 11:28:26 client01 telegraf[510936]: 2026-09-11T09:28:26Z D! [outputs.amqp] Error connecting to "amqps://mq:5671/%2f" - Exception (403) Reason: "username or password not allowed"
Sep 11 11:28:26 client01 telegraf[510936]: 2026-09-11T09:28:26Z D! [outputs.amqp] Buffer fullness: 108 / 10000 metrics
Sep 11 11:28:26 client01 telegraf[510936]: 2026-09-11T09:28:26Z E! [agent] Error writing to outputs.amqp: could not connect to any broker
Sep 11 11:28:30 client01 telegraf[510936]: 2026-09-11T09:28:30Z D! [outputs.amqp] Connecting to "amqps://mq02:5671/%2f"

System info

Telegraf 1.40.0-1 from yum/apt-repos on various arm64 (debian/ubuntu) and x86_64 (debian/ubuntu/alma)

Docker

No response

Steps to reproduce

The initial connection after startup or systemctl restart ist fine.
But for me it looks like any network hickup leads to the state described. I see it most often on a flappy powerline connection.

Rabbitmq reports

PLAIN login refused: user 'telegraf' attempted to log in with a blank password, which is prohibited by the internal authN backend. To use TLS/x509 certificate-based authentication, see the rabbitmq_auth_mechanism_ssl plugin and configure the client to use the EXTERNAL authentication mechanism. Alternatively change the password for the user to be non-blank.

Telegraf runs into

telegraf[2273142]: 2026-09-11T08:50:36Z E! [agent] Error writing to outputs.amqp: could not connect to any broker
telegraf[2273142]: 2026-09-11T08:50:51Z W! [agent] ["outputs.amqp"] did not complete within its flush interval

The initial connection after startup or systemctl restart ist fine.
But for me it looks like any network hickup leads to the state described. I see it most often on a flappy powerline connection.

My Setup works like this: I use a custom CA certificate to allow the connection to rabbitmq, but I have a password/login for the identity on rabbitmq, the identity is not derived from the certificate. If the reconnect claims "empty password", this remindes me of a similar bug in amqp.input: #19571

Expected behavior

Smooth reconnect, no data loss.

Actual behavior

Unpublished data, thrown away during restart.

Additional info

Activity

  1. added
    bug
    on Sep 11, 2026
  2. FlHinrichsen commented on Sep 14, 2026

    @FlHinrichsen

    Same issue for me.
    After a connection lost it does not reconnect.
    Using Version 1.40.0

    It seams that the password is not provided on a reconnect.

    Thats really annoying, as all data after a connection lost are gone.

    As workaround I actual testing the Disk persistance:

    [agent]
    buffer_strategy = "disk"
    buffer_directory = "/var/lib/telegraf/buffer"
    buffer_disk_sync = true

  3. srebhan commented on Sep 14, 2026

    @srebhan
    Member

    This should have been fixed with PR #19575. Are you sure you tested with v1.40.0?

  4. pstadt commented on Sep 14, 2026

    @pstadt
    Author

    Yes, I am pretty sure and I use the official builds distributed via apt and yum repositories.

    # dpkg -l | grep telegraf
    ii  telegraf                          1.40.0-1                                        arm64        Plugin-driven server agent for reporting metrics into InfluxDB.
    
    
    # rpm -qi telegraf
    Name        : telegraf
    Version     : 1.40.0
    Release     : 1
    Architecture: x86_64
    Install Date: Wed 09 Sep 2026 07:45:53 AM CEST
    Group       : default
    Size        : 327153918
    License     : MIT
    Signature   :
                  RSA/SHA512, Mon 07 Sep 2026 09:24:15 PM CEST, Key ID da61c26a0585bd3b
    Source RPM  : telegraf-1.40.0-1.src.rpm
    Build Date  : Mon 07 Sep 2026 08:49:39 PM CEST
    Build Host  : c842270fb325
    Relocations : / 
    Packager    : support@influxdb.com
    Vendor      : InfluxData
    URL         : https://github.com/influxdata/telegraf
    Summary     : Plugin-driven server agent for reporting metrics into InfluxDB.
    Description :
    Plugin-driven server agent for reporting metrics into InfluxDB.
    
  5. FlHinrichsen commented on Sep 14, 2026

    @FlHinrichsen

    Same for me:

    Telegraf 1.40.0 (git: HEAD@e9017dc3)

    Only difference to the mentioned pullrequest is, that we use "outputs.amqp"

  6. pstadt commented on Sep 14, 2026

    @pstadt
    Author

    As far as I can see there were fixes on plugins/outputs/amqp two weeks ago (#19464) on unavailable brokers.
    Looks like the fix Restore configuration to successfully reconnect (#19575) on plugins/inputs/amqp_consumer needs to be ported to plugins/outputs/amqp as well.

  7. self-assigned this
    on Sep 16, 2026
  8. skartikey commented on Sep 16, 2026

    @skartikey
    Contributor

    Confirmed, it's the same bug as #19571 but in the output. The AMQP library blanks the password after the first connect and outputs.amqp reuses that config on reconnect, while #19575 only fixed the consumer. #19734 fixes it for the output.

  9. pstadt commented on Sep 17, 2026

    @pstadt
    Author

    I installed the artifacts from #19734 on more than 30 boxes and they all transmit data for >12h.
    I still see some repetitions off

    Sep 17 06:56:15 client01 telegraf[714652]: 2026-09-17T04:56:15Z W! [agent] ["outputs.amqp"] did not complete within its flush interval
    Sep 17 06:56:20 client01 telegraf[714652]: 2026-09-17T04:56:20Z E! [agent] Error writing to outputs.amqp: could not connect to any broker
    

    but after a few occurrences, things settle down, the connection is created and the data is transmitted reliably again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions