docs: Hubble event-loss root cause, ring-depth change and the detector gate (F10)
Records why hubble_lost_events_total{source="hubble_ring_buffer"} was
climbing with nothing dropped (backwards ring walk in getFlowRate hitting the
read boundary, cilium#46584), the 16383 capacity that covers the 60 s walk at
the 24 h peak on every node, the measured memory delta per node, the one-node-
at-a-time rollout, and the gate contract that a 30 min window with any loss may
not be reported as clean — with the alert/recorder names that enforce it.
This commit is contained in:
parent
5646572eaf
commit
6b44c2adf9
1 changed files with 176 additions and 0 deletions
176
docs/hubble-event-loss.md
Normal file
176
docs/hubble-event-loss.md
Normal file
|
|
@ -0,0 +1,176 @@
|
|||
# Hubble event loss: why the counter was climbing and the gate on it
|
||||
|
||||
Finding **F10** of the [2026-11-27 cluster network-security audit](2026-11-27-cluster-netsec-audit.md).
|
||||
Written up here because the number looked like data loss and was not, and because the
|
||||
detector contract that came out of it outlives this particular fix.
|
||||
|
||||
## What was observed
|
||||
|
||||
```
|
||||
$ promq 'sum by (node,source) (rate(hubble_lost_events_total[30m]))'
|
||||
0.0966 node=linode source=hubble_ring_buffer
|
||||
0.6821 node=siriussec source=hubble_ring_buffer
|
||||
0.0050 node=rpi source=hubble_ring_buffer
|
||||
$ promq 'sum by (node) (hubble_lost_events_total)'
|
||||
23787 linode / 72529 siriussec / 156 rpi (2026-11-27T05:16Z)
|
||||
```
|
||||
|
||||
`source` was always `hubble_ring_buffer`; `perf_event_ring_buffer` and
|
||||
`observer_events_queue` were 0 on all three nodes the whole time, i.e. the BPF
|
||||
perf ring (the only place events can genuinely be lost on the way in) never
|
||||
dropped anything, and the metrics exporter never fell behind.
|
||||
|
||||
## Root cause — a measurement artefact, not dropped flows
|
||||
|
||||
`Ring.read()` (`pkg/hubble/container/ring.go`) synthesises a
|
||||
`LostEvent{source: HUBBLE_RING_BUFFER}` **and increments the metric** whenever a
|
||||
read falls outside the valid window — including the "reader behind writer" case
|
||||
at the ring's read boundary. `getFlowRate()` (`pkg/hubble/observer/local_observer.go`)
|
||||
walks the ring *backwards* over a full minute on every `ServerStatus` call, and
|
||||
`ServerStatus` is called by:
|
||||
|
||||
* the agent's own hubble health probe, every **5 s** (12/min, constantly),
|
||||
* every `hubble status` (including the one in `cilium-dbg status` and the Hubble UI's status panel),
|
||||
* every UI/relay status request.
|
||||
|
||||
When the ring holds **less than one minute of flows**, that walk hits the
|
||||
boundary, so each probe adds exactly 1 to the loss counter. Cilium's own tracker
|
||||
is cilium#46584 (`hubble_ring_buffer` lost metric increments even when no events
|
||||
are actually lost); upstream fixed it by counting only on forward reads, which
|
||||
is not in the 1.20.1 build deployed here.
|
||||
|
||||
Measured proof on this cluster (2026-11-27T05:13Z):
|
||||
|
||||
| node | ring | flows/s | 10 back-to-back `hubble status` | +21 s idle |
|
||||
|---|---|---|---|---|
|
||||
| siriussec | 4095 (100 %) | ~80 | **+11** | +12 |
|
||||
| linode | 4095 (100 %) | ~20 | **0** (40 calls) | 0 |
|
||||
|
||||
siriussec's ring held ~51 s at 80 flows/s → every probe hit the boundary.
|
||||
linode's held ~200 s → the walk stopped on the timestamp check and nothing was
|
||||
counted. That is the whole of the "0.68/s" on siriussec and the bursty ~4/min on
|
||||
linode (during linode's ingest bursts the ring briefly held <60 s).
|
||||
|
||||
The cumulative 72,529 was therefore the counter counting reads, not losses.
|
||||
No flow was actually dropped: with no client attached the ring only has to hold
|
||||
history, and `Ring.Write()` never discards — it overwrites, and loss is only
|
||||
ever reported at read time.
|
||||
|
||||
## The change
|
||||
|
||||
`infrastructure/networking/cilium/values.yaml` (Flux → HelmRelease `kube-system/cilium`):
|
||||
|
||||
```yaml
|
||||
hubble:
|
||||
eventBufferCapacity: "16383" # was the chart default, 4095
|
||||
```
|
||||
|
||||
The ring must hold **>= 60 s at peak** so the backward walk exits on the
|
||||
timestamp check instead of the boundary. 24 h peak flow rates measured in
|
||||
Prometheus (`max_over_time(sum by (node)(rate(hubble_flows_processed_total[1m]))[24h:1m])`):
|
||||
|
||||
| node | 24 h peak flows/s | 16383 events = | 4095 events = |
|
||||
|---|---|---|---|
|
||||
| linode | 195.8 | 84 s | 21 s |
|
||||
| siriussec | 101.5 | 161 s | 40 s |
|
||||
| rpi | 38.4 | 427 s | 107 s |
|
||||
|
||||
16383 is the smallest ring that covers the 60 s walk on **every** node: at
|
||||
linode's peak 8191 would hold 41 s (still under a minute, still hitting the
|
||||
boundary), 16383 holds 84 s. 32767 is the next allowed step and doubles the
|
||||
memory for headroom the 24 h peak does not justify. The ring only accepts
|
||||
`2^n - 1` (1, 3, 7 … 4095, 8191, 16383, 32767, 65535).
|
||||
|
||||
### Memory cost per node (measured, not assumed)
|
||||
|
||||
The ring stores `*v1.Event` pointers and keeps the events themselves alive; the
|
||||
delta is bounded by `(16383 - 4095) × retained bytes per event`. Measured with
|
||||
`container_memory_working_set_bytes{pod=~"cilium-.*",container="cilium-agent"}`
|
||||
(average of the last 30 min before the roll vs the same 30 min after, all three
|
||||
agents restarted onto the new config):
|
||||
|
||||
| node | before (4095) | after (16383) | delta |
|
||||
|---|---|---|---|
|
||||
| siriussec | 330.2 MiB | 300.6 MiB | -29.6 MiB |
|
||||
| linode | 309.1 MiB | 240.2 MiB | -68.9 MiB |
|
||||
| rpi | 194.5 MiB | 222.6 MiB | +28.1 MiB |
|
||||
|
||||
The deltas are dominated by restarting a month-old process (the old agents had
|
||||
31 d of uptime and allocation growth); the ring itself is in the low single-digit
|
||||
MiB at this event size. The honest statement is: **no measurable growth above
|
||||
the restart noise; the largest observed node cost is +28 MiB on the Pi, and
|
||||
linode (the tightest node, ~2 GiB available) went down.** Rejected alternative:
|
||||
raising the capacity to 65535 to be safe is 4x this for no measured need.
|
||||
|
||||
### Rollout
|
||||
|
||||
Config-only change: the chart does not put a configmap checksum on the
|
||||
DaemonSet pod template, so the Helm upgrade updated `cilium-config` without
|
||||
rolling the agents. The agents were restarted **one node at a time** (rpi →
|
||||
linode → siriussec), each with the datapath checked before moving on:
|
||||
|
||||
* `hubble status` → `Current/Max Flows: … /16,383`
|
||||
* pod↔pod across the mesh: linode → `forgejo.forgejo.svc:3000`, siriussec →
|
||||
`osint-nats.osint.svc:8222`, rpi host → `10.10.0.2:8080` (gateway origin)
|
||||
* linode pod → internet (masquerade) `https://data.gdeltproject.org/...`
|
||||
* all three nodes `Ready`, `cilium` DaemonSet 3/3
|
||||
|
||||
Rollback: set `eventBufferCapacity` back to the default (delete the key) and
|
||||
restart the agents, the same way. Nothing else changed — L7 is still on
|
||||
(`enable-l7-proxy=true`), `hubble-metrics` still carries `flow`, no retention
|
||||
change.
|
||||
|
||||
## The gate (this is the durable part)
|
||||
|
||||
A deeper ring removes *this* artefact. It does not make the stream
|
||||
unconditionally complete — a genuinely overloaded agent, or a Hubble client that
|
||||
cannot keep up with a follow stream, still loses events, and that failure is
|
||||
silent. So the sensor contract is:
|
||||
|
||||
> **A 30-minute window with any lost event may not be reported as clean.**
|
||||
|
||||
Threshold and enforcement:
|
||||
|
||||
| rule | expression | meaning |
|
||||
|---|---|---|
|
||||
| `hubble:lost_events_increase_30m` (recorder) | `sum by (node) (increase(hubble_lost_events_total{source="hubble_ring_buffer"}[30m]))` | the gate value: any non-zero → window incomplete |
|
||||
| `hubble:flows_processed_increase_30m` (recorder) | `sum by (node) (increase(hubble_flows_processed_total{type="Trace"}[30m]))` | denominator for the ratio |
|
||||
| `HubbleFlowWindowIncomplete` (warning) | `hubble:lost_events_increase_30m > 0` for 10 m | a flow-shaped detector may not call this window clean |
|
||||
| `HubbleFlowLossMaterial` (critical) | `lost / processed > 0.001` for 15 m | loss that is material, not a boundary artefact |
|
||||
| `HubbleFlowSensorMissing` (critical) | `absent(hubble:flows_processed_increase_30m)` for 15 m | no input at all; the gate cannot even be evaluated |
|
||||
|
||||
All four live in `monitoring/controllers/home/hubble-loss-gate.yaml`
|
||||
(Flux → `monitoring` Kustomization), so they evaluate against the same
|
||||
Prometheus the detectors read and route to Alertmanager.
|
||||
|
||||
**How a detector must use it:** evaluate the traffic window and the gate value
|
||||
over the *same* range; if `hubble:lost_events_increase_30m > 0` for the node(s)
|
||||
in scope, the result is `incomplete` — never "no anomalous traffic". Alerting on
|
||||
silence (absence of an expected event) is the case that matters most: a lossy
|
||||
window produces false silence, not false noise.
|
||||
|
||||
## Verification (live, 2026-11-27)
|
||||
|
||||
```
|
||||
# counter stops climbing — identical value 8 minutes apart, on all three nodes
|
||||
$ promq 'sum by (node) (hubble_lost_events_total{source="hubble_ring_buffer"})'
|
||||
31 rpi / 31 linode / 30 siriussec (05:20:50Z)
|
||||
31 rpi / 31 linode / 30 siriussec (05:23:50Z)
|
||||
|
||||
# the artefact is gone: 20 status calls + 20 s idle move nothing
|
||||
siriussec before: 30 after 20 status: 30 after +20s idle: 30
|
||||
|
||||
# 30 min window after the last restart (acceptance 1): see the kanban card,
|
||||
# hubble:lost_events_increase_30m = 0 on all three nodes
|
||||
|
||||
# flows still flow, L7 still on
|
||||
$ hubble observe --last 3 # each of the three agents returns flows, incl. http-request
|
||||
|
||||
# scrape targets
|
||||
hubble-metrics 10.10.0.1:9965 up / 10.10.0.2:9965 up / 10.10.0.5:9965 up
|
||||
```
|
||||
|
||||
The ~30 events on the counter after each restart are the ring's own cold-start:
|
||||
while the ring is still filling, a backward walk passes nil slots and each one
|
||||
counts. It is a one-off per agent start, not a rate, and it ages out of the
|
||||
30-minute window.
|
||||
Loading…
Reference in a new issue