yeti labs

field note 015 · 2026-08-11 · observability, loki

every service looked dead for 16.5 hours, and the only thing broken was a batch size

one evening every service in the fleet stopped logging at once. the services were fine. the log pipeline had wedged itself on a single batch that had grown past what loki would accept, and it was never going to recover on its own.

logs missing
~16.5h
loki's limit
4 MiB
refused batch
8.8 MB
services down
0

the setup

we run infrastructure for a blockchain data-indexing company, and the fleet ships its logs over otlp (the opentelemetry protocol) to one monitoring box running loki and grafana. two collectors sit in a chain on that box: our front collector takes logs from every service and batches them, and a second collector inside the loki/grafana container forwards them to loki.

at 21:31 utc on august 11, alerts started firing: a "backlog growth" alert on the inner collector's queue, and "no data in the last 5 minutes" for 12 services at once. that pattern had fooled us before.

the lookalike

three weeks earlier, on july 21, every service's newest log in loki read the same timestamp, and queries for anything later came back empty. we called it a fleet-wide blackout. it was ingestion lag. loki had fallen about 90 minutes behind, and when we looked again about an hour later it had caught up and backfilled the whole gap with nobody touching it.

so the obvious read this time was "it'll catch up." this one never would.

what was actually happening

loki's distributor hands each batch to its ingester over grpc (a remote procedure call protocol), and the default size cap on that hop is 4 MiB (4,194,304 bytes). our front collector batched every 5 seconds with a target of 16,384 records, which by then meant about 5,000 records, or roughly 6 MB, per batch. loki answered with a 503 that named the problem exactly: received message larger than max (8818934 vs. 4194304).

a 503 reads as "try again later," so the collector did, with the same oversized batch, forever. nothing about the batch changed between retries, so nothing about the answer did either. zero logs landed until we fixed it at 14:10 utc the next day.

the batch was twice the size loki would take

size of one grpc push from the distributor to the ingester, in MB, against loki's limit before and after the fix

051015 MBloki's limit, before4.19 · 4 MiBthe batch it refused8.82 · 503new batch, worst case~2.4loki's limit, after16.78 · 16 MiBsame payload, replayed9.1 · 204, acceptedretried, unchanged, forabout 16.5 hours
source: loki's own error message, our collector config, and a replay after the fixyeti labs · field note 015

why it worked for weeks and then didn't

per-record size had been creeping up. structured metadata (the attributes attached to each log line) was 542 GB of the 895 GB loki had ingested, about 60%. each record carried around 900 bytes of attributes on top of a body of about 290, so roughly 1.2 KB a record. as it grew, a 5-second batch crossed 4 MiB, and once one did, the retry loop meant it never came back under.

the labels outweighed the log line

average bytes per log record, by part

02505007501,000 Battributes~900 Blog body~290 B
source: loki ingestion stats, 542 of 895 GB ingested was structured metadata

telling a wedge from a lag in 30 seconds

the confusing part is that everything small worked. a native loki push returned 204 and showed up in queries right away, and so did a small otlp post. the read path and the ingester looked healthy. what settled it was pushing one otlp body over 4 MB by hand and reading the error, which named itself.

the faster tell is loki's own request counter for the otlp logs endpoint. in a lag, the 204s keep climbing, just late. in a wedge, the 204s are frozen and the 503s climb. two more metrics agreed: successful pushes to the ingester had stopped while lines received at the distributor kept going up, which puts the failure on the hop between them.

july 21august 11
what grafana showedevery service stoppedevery service stopped
causeingestion lagbatch over 4 MiB
204s from lokistill climbingfrozen
how it endedcaught up in ~90 minfixed by hand
logs in the gapbackfilledlost

fwiw, the counter that tells them apart lives only inside the loki container. prometheus doesn't scrape loki's own metrics on this box, so no grafana panel or alert could have shown it.

the fix

we shrank the batches: a 1-second timeout instead of 5, a target of 1,000 records instead of 16,384, and a hard max of 2,000 instead of 20,000. that puts the worst case around 2.4 MB. then we restarted both collectors. the inner one had to go too, because its retry queue was still holding the wedged batches, and restarting it took that process from 10.7 GB of memory to 215 MB (and the whole box from 11 GB to 2 GB). all 18 services were reporting again within a minute.

the next day we raised loki's grpc cap to 16 MiB and replayed the same 9.1 MB payload that had been refused. it came back 204. that turned out to be a config file and a container restart, since the config and the 28 GB of loki, grafana, and prometheus data were already mounted from the host. checking the mounts first turned a planned maintenance window into a 30-second change.

we did talk about trimming the attributes, since they were most of the bytes. the detail is worth keeping, so the bigger cap is the guard instead.

the 16.5 hours of logs are gone from loki. each box's local process logs still have them, which is where we'd go for anything in that window.

what we'd do instead

  1. alert on the cause. we added one that fires when the collector's failed-send counter has been above zero for 10 minutes, so the page names the cause within 10 minutes instead of 12 symptoms.
  2. size batches in bytes with headroom under the receiver's limit, and revisit it whenever what you log per record changes.
  3. wire up the checks you already have. our health check had a loki ingestion probe that would have flagged this as a failure, and it sat inert for want of one api token. once it had the token it read 18 services and 578,623 lines in 10 minutes.
  4. when a lookalike healed itself last time, run the 30-second test before deciding to wait.
got a dashboard that's ever gone quiet all at once?

we'll find out which kind of quiet it is.

talk to the agent →