Skip to content

Alloy re-sends a quiet container's last log line every 10 minutes through the socket proxy #1552

Closed

Description

@Gerrrt

What happens

Every 10 minutes, loki.source.docker re-sends the last log line of any container that has written nothing in those 10 minutes. Loki stores each copy as a duplicate for 7 days. After that, Loki rejects each copy as too old, and Alloy counts it in loki_write_dropped_entries_total{reason="ingester_error"}. The re-sends never stop until the container writes a new line or is recreated.

Evidence (fenrir, 2026-11-17, read-only)

  • sensor-zeek last wrote to stdout on 2026-11-09 06:26:34: Zeek's GeoIP error from the SSH geo-data policy, explained in docs(sensor): record fenrir's 18-day blind spot, explain the GeoIP error, fix the checkout path #1523.
  • In the last 26 hours, Alloy logged could not transfer logs ... written=0 155 times for that container, about once every 10 minutes. The two busy containers on the host logged it at most 5 times.
  • From 2026-11-16 06:26, exactly 7 days after that line was written, every reconnect ends in final error sending batch, no retries left, dropping data: Loki returns 400, timestamp too old: 2026-11-09T06:26:34Z. All 126 drops in 30 hours are that one stream, {log_type="docker", service_name="sensor-zeek"}, and that one timestamp.
  • loki_write_dropped_entries_total{reason="ingester_error"} stands at 1363 on fenrir. The audit of 2026-11-13 read 0.
  • Zeek's protocol logs (job="zeek", loki.source.file) are not affected: 1.5M entries sent, and none dropped.

Why

stacks/observability/docker-socket-proxy/haproxy.cfg sets timeout client 10m and timeout server 10m in defaults. /containers/<id>/logs?follow=1 goes to dockerbackend, which inherits those timeouts. Only /events has its own backend with timeout server 0. A follow stream with nothing to send for 10 minutes is therefore idle, and HAProxy closes it. Alloy then reconnects with since set to the last saved position. Docker appears to treat since as inclusive, so it returns the last line again, and Alloy ships it again. This is inferred from the same 06:26:34 timestamp coming back on every reconnect; Docker's behaviour was not checked separately.

The 10-minute rhythm matches the timeout to within seconds. Busy containers write within any 10-minute window, so they never reach it.

Who is affected

Every host that runs docker.alloy through this proxy. That is every stack that mounts haproxy.cfg: observability (the monitoring host), lab (alexander), soc (odin), sensor (fenrir), analyst (garuda) and bloodhound (eden). oracle reads the socket directly (DOCKER_API unset), so it should be unaffected, though that is unverified.

On the estate, stack.rules.yaml's loki_write_dropped_entries_total rule (for: 1h) would fire once a quiet container's last line turns 7 days old. The lab's Prometheus has no such rule, so on the lab guests the drops are silent. That is how fenrir has been dropping since 11-16 with no alert.

Proposed fix

  1. Send /containers/<id>/logs to a backend with no idle timeout, as /events already has. That could be the existing docker-events backend, or a new docker-logs backend with timeout server 0. The frontend also needs timeout client lifted for those requests (http-request set-timeout client 0 / set-timeout server 0, or a dedicated frontend path). Either way it stays inside the BEGIN homelab block, with the reason stated.
  2. Carry the dropped-entries rule into the lab's Prometheus, so that a lab guest losing log lines alerts, as an estate host's does.
  3. Verify on fenrir: after make up STACK=sensor, could not transfer logs stops recurring for sensor-zeek, and loki_write_dropped_entries_total stops rising. Check the same on one estate host.

Recreating the container clears today's instance on fenrir. It does not fix the cause.

Refs #836, the proxy's introduction to the agents.

Activity

  1. Gerrrt commented on Nov 18, 2026

    @Gerrrt
    OwnerAuthor

    Verified on fenrir after #1560 (merged as a7270d9).

    • make up STACK=sensor ran from main at e980420 at 00:05 UTC on 2026-11-18. The running proxy has the set-timeout client 24d line and the use_backend docker-events line for /logs. All three services are healthy.
    • Before: 10 could not transfer logs in the hour before the deploy.
    • After: 0 between 00:07 and 00:31 UTC. In that window sensor-zeek's follow ran idle past the old 10-minute timeout more than twice; its last stdout line is from 2026-11-17 22:33. The old proxy cut it every 10 minutes.
    • Every loki_write_dropped_entries_total series on fenrir reads 0 (reset by the 2026-11-17 reboot, and still flat).
    • The proxy logs missing timeouts for backend 'docker-events'. That comes from upstream's own timeout server 0 on that backend, which the original config already carried; it is not new behaviour.

    Not checked: the same on an estate host.

    🤖 Closed by Claude Code

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions