From 3010c980ecf2cd41c0fde9e8b05162130ee369ae Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Fri, 27 Nov 2026 18:46:35 -0500 Subject: [PATCH] monitoring(hubble): split ring-buffer reads out of the flow-loss gate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit HubbleFlowWindowIncomplete was paging on all three nodes with perf_event_ring_buffer and observer_events_queue at 0: the gate recorder was increase(hubble_lost_events_total{source="hubble_ring_buffer"}[30m]), and that counter also counts *reads* that fall outside the ring's retained window (cilium#46584, still open in 1.20.1). Two Hubble UI/status reads an hour (18:27, 18:35, same minutes on every node) moved it +1 each, which kept the recorder at ~2.01 and the alert true forever. HubbleFlowLossMaterial used the same recorder, so a handful of reads could also read as 0.03% "loss" on the quiet Pi node. - hubble:lost_events_increase_30m is now real loss only, per (node, source): increase(hubble_lost_events_total{source=~"perf_event_ring_buffer|observer_events_queue"}[30m]). HubbleFlowWindowIncomplete and HubbleFlowLossMaterial read it with unchanged thresholds, so they fire only when something was actually dropped. - hubble_ring_buffer gets hubble:ring_buffer_read_rate_15m and the new HubbleRingBufferReadChurn warning at > 0.05 events/s (15m rate, 10m for). Current churn is ~0.001/s; the F10 health-probe storm was ~0.2/s. - Both summaries name the source, so a read is never reported as a dropped flow. HubbleFlowSensorMissing unchanged. No change to hubble.eventBufferCapacity and no Cilium roll. Docs (docs/hubble-event-loss.md §"The gate") updated with the split and the measured reason. Task: t_397d180a --- docs/hubble-event-loss.md | 44 ++++++- .../controllers/home/hubble-loss-gate.yaml | 108 ++++++++++++++---- 2 files changed, 122 insertions(+), 30 deletions(-) diff --git a/docs/hubble-event-loss.md b/docs/hubble-event-loss.md index e29eab0..38156a8 100644 --- a/docs/hubble-event-loss.md +++ b/docs/hubble-event-loss.md @@ -129,17 +129,26 @@ silent. So the sensor contract is: > **A 30-minute window with any lost event may not be reported as clean.** +The counter carries two different signals and the gate must not treat them +alike: `perf_event_ring_buffer` / `observer_events_queue` are real loss on the +way in, while `hubble_ring_buffer` also counts *reads* that fall outside the +ring's retained window (the artefact above). A read is not a lost event, so the +gate value is built from the two real-loss sources only, and read churn gets its +own rate-based regression guard. + 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:lost_events_increase_30m` (recorder) | `sum by (node, source) (increase(hubble_lost_events_total{source=~"perf_event_ring_buffer\|observer_events_queue"}[30m]))` | the gate value: any non-zero **real** loss → window incomplete; `source` is kept so the alert can name it | +| `hubble:ring_buffer_read_rate_15m` (recorder) | `sum by (node) (rate(hubble_lost_events_total{source="hubble_ring_buffer"}[15m]))` | read churn on the ring, events/s | | `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 | +| `HubbleFlowWindowIncomplete` (warning) | `hubble:lost_events_increase_30m > 0` for 10 m | a flow-shaped detector may not call this window clean — real loss only | +| `HubbleRingBufferReadChurn` (warning) | `hubble:ring_buffer_read_rate_15m > 0.05` for 10 m | status-call storm / ring under a minute of flows; **reads, not drops** | +| `HubbleFlowLossMaterial` (critical) | `sum by (node) (hubble:lost_events_increase_30m) / flows > 0.001` for 15 m | real 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` +All five 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. @@ -147,7 +156,32 @@ Prometheus the detectors read and route to Alertmanager. 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. +window produces false silence, not false noise. `hubble_ring_buffer` alone is +never grounds for `incomplete`: it is a read counter. + +### Follow-up 2026-11-27: the gate as first written paged on reads + +The first version of these rules recorded +`increase(hubble_lost_events_total{source="hubble_ring_buffer"}[30m])` and alerted +at `> 0`. That reproduced the artefact the deeper ring was meant to remove and +paged on it: measured at 18:39Z, `HubbleFlowWindowIncomplete` was firing on all +three nodes with `hubble:lost_events_increase_30m` ≈ 2.01, while +`perf_event_ring_buffer` and `observer_events_queue` were 0 everywhere and the +ring-buffer counter stepped +1 twice in an hour (18:27, 18:35 — identical +timestamps on all three nodes) with the Hubble UI open from the admin laptop. A +`for: 10m` cannot fix that: two status reads an hour keep `increase() > 0` true +for the whole hour, and the same recorder fed `HubbleFlowLossMaterial`, where a +couple of extra counts out of ~7 k flows on the quiet Pi node is 0.03 %. + +Split applied: the gate recorder now covers `perf_event_ring_buffer` + +`observer_events_queue` only, `HubbleFlowWindowIncomplete` and +`HubbleFlowLossMaterial` read that (unchanged thresholds), and +`hubble_ring_buffer` gets rate-based `HubbleRingBufferReadChurn` at **0.05 +events/s over 15 m** — ~45 reads per window, versus the F10 probe storm's +~0.2/s (12/min) and the current ~0.001/s (2 reads/hour). Both firing conditions +name the source in the summary so a read is never described as a dropped flow. +`hubble.eventBufferCapacity` was not touched and the agents were not rolled. + ## Verification (live, 2026-11-27) diff --git a/monitoring/controllers/home/hubble-loss-gate.yaml b/monitoring/controllers/home/hubble-loss-gate.yaml index 078b49b..7e2c200 100644 --- a/monitoring/controllers/home/hubble-loss-gate.yaml +++ b/monitoring/controllers/home/hubble-loss-gate.yaml @@ -7,14 +7,28 @@ # sample. These rules make the loss visible and define the gate: a window whose # lost-event count is non-zero is NOT clean and must not be reported as such. # -# Measured loss here is `hubble_lost_events_total{source="hubble_ring_buffer"}`, -# the only source that has ever been non-zero on this cluster -# (`perf_event_ring_buffer` and `observer_events_queue` are 0). It is a plain -# counter on each agent's :9965, scraped by the `hubble-metrics` job. +# Two very different things share the `hubble_lost_events_total` counter and they +# must not share a threshold: # -# Thresholds: -# gate : increase over 30 m > 0 events -> warning, window tainted -# material : lost / processed Trace flows > 0.1 % -> critical, real loss +# perf_event_ring_buffer / observer_events_queue +# Real loss on the way in — the BPF perf ring dropped an event, or the +# metrics exporter fell behind. Steady state is 0 on every node. Any +# increase over the window taints that window. +# +# hubble_ring_buffer +# NOT a drop. `Ring.read()` synthesises a LostEvent and bumps this counter +# whenever a read falls outside the ring's retained window, which the +# agent's own 5 s health probe and every `hubble status` / Hubble UI status +# request do on a ring holding < 60 s of flows (cilium#46584, still open in +# the deployed 1.20.1). A couple of UI reads per hour is ~0.001 events/s and +# means nothing; the 12/min probe storm measured in F10 was ~0.2 events/s. +# So this source is alerted on a *rate*, never on `increase() > 0`. +# +# Recorders: +# hubble:lost_events_increase_30m real loss only, per (node, source), so the +# alert can name which source lost events. +# hubble:ring_buffer_read_rate_15m read churn on the ring, events/s per node. +# hubble:flows_processed_increase_30m denominator for the material ratio. # The detector contract (docs/hubble-event-loss.md §"Gate") is: read # `hubble:lost_events_increase_30m` with the same window as the traffic it is # judging; if it is > 0, label the window incomplete instead of clean. @@ -29,11 +43,21 @@ spec: groups: - name: hubble-event-loss rules: - # One number for the gate. `increase()` absorbs the counter reset that - # an agent restart causes, so a rolled DaemonSet does not look like loss. + # One number for the gate, from the two sources that mean real loss. + # `increase()` absorbs the counter reset that an agent restart causes, + # so a rolled DaemonSet does not look like loss. Empty source filter out + # of scope: a source that starts reporting is a loss, not a read. - record: hubble:lost_events_increase_30m expr: | - sum by (node) (increase(hubble_lost_events_total{source="hubble_ring_buffer"}[30m])) + sum by (node, source) ( + increase(hubble_lost_events_total{source=~"perf_event_ring_buffer|observer_events_queue"}[30m]) + ) + # Ring-buffer read churn, kept separate and rate-based. 0.05 events/s = + # 45 reads per 15 min; the F10 probe storm was ~0.2/s, two UI reads an + # hour is ~0.001/s. + - record: hubble:ring_buffer_read_rate_15m + expr: | + sum by (node) (rate(hubble_lost_events_total{source="hubble_ring_buffer"}[15m])) # Denominator for the material-loss ratio. Trace is the total flow # counter; L7/Drop/PolicyVerdict are subsets of it and would # double-count. @@ -42,35 +66,68 @@ spec: sum by (node) (increase(hubble_flows_processed_total{type="Trace"}[30m])) - alert: HubbleFlowWindowIncomplete - # The gate from F10. Any lost event in the window means a flow-shaped - # detector may have missed something; the window must not be reported - # as clean. Steady state is 0 on all three nodes after the ring-depth - # fix (16383) — this firing means either a regression of that fix or a - # genuinely overloaded agent, both of which invalidate flow-only - # silence. + # The gate from F10: any event lost on the way in during the window + # means a flow-shaped detector may have missed something, so the window + # must not be reported as clean. Steady state is 0 on all three nodes. + # Ring-buffer read artefacts are deliberately NOT in this expression — + # they are not loss and are covered by HubbleRingBufferReadChurn. expr: hubble:lost_events_increase_30m > 0 for: 10m labels: severity: warning component: hubble annotations: - summary: "Hubble dropped flow events on {{ $labels.node }} — flow windows are not clean" + summary: "Hubble lost flow events on {{ $labels.node }} (source: {{ $labels.source }}) — flow windows are not clean" description: | - hubble_lost_events_total{source="hubble_ring_buffer"} on {{ $labels.node }} + hubble_lost_events_total{source="{{ $labels.source }}"} on {{ $labels.node }} increased by {{ $value | printf "%.0f" }} events over the last 30 min. - A flow-based detector cannot claim "no anomalous traffic" for this window. - Check `kubectl -n kube-system exec -c cilium-agent -- - hubble status` (Current/Max Flows) and the agent's flow rate against + That source is real loss: `perf_event_ring_buffer` means the BPF perf + ring dropped an event on the way in, `observer_events_queue` means the + metrics exporter fell behind. A flow-based detector cannot claim + "no anomalous traffic" for this window. + Check the agent's flow rate against hubble.eventBufferCapacity in + infrastructure/networking/cilium/values.yaml, and look for an + overloaded node. + + - alert: HubbleRingBufferReadChurn + # Regression guard for the artefact described in F10, not evidence of + # loss. The 5 s health probe / `hubble status` / Hubble UI status walk + # the ring backwards over a full minute; on a ring holding < 60 s of + # flows each walk increments hubble_lost_events_total + # {source="hubble_ring_buffer"} by 1. A handful of reads is normal; the + # old probe storm (12/min = 0.2/s) and an agent whose ring no longer + # holds a minute of flows are not. Rate, not increase: `increase() > 0` + # fires forever on two UI reads an hour. + expr: hubble:ring_buffer_read_rate_15m > 0.05 + for: 10m + labels: + severity: warning + component: hubble + annotations: + summary: "Hubble ring-buffer read churn on {{ $labels.node }} (source: hubble_ring_buffer) — reads, not dropped flows" + description: | + hubble_lost_events_total{source="hubble_ring_buffer"} is increasing at + {{ $value | printf "%.3f" }}/s on {{ $labels.node }} (threshold 0.05/s, + 15 min rate, sustained 10 min). This counter also counts reads that + fall outside the ring's retained window (cilium#46584), so a burst of + `hubble status` / Hubble UI / relay calls can move it without anything + being dropped. A sustained rate this high means either a status-call + storm or a ring holding less than one minute of flows — check + `hubble status` (Current/Max Flows) against the agent's flow rate and hubble.eventBufferCapacity in infrastructure/networking/cilium/values.yaml. + Confirm whether it is real loss by checking + HubbleFlowWindowIncomplete (perf/observer sources), which stays 0 for + read churn alone. - alert: HubbleFlowLossMaterial - # Escalation: loss that is large relative to the traffic, not a + # Escalation: real loss that is large relative to the traffic, not a # boundary artefact. 0.1 % of 30 min of flows on siriussec (~180 k # events) is ~180 events — small enough to catch a real gap, large - # enough that a handful of stray increments do not page. + # enough that a handful of stray increments do not page. Uses the + # real-loss recorder only; ring-buffer reads never make this ratio. expr: | ( - hubble:lost_events_increase_30m + sum by (node) (hubble:lost_events_increase_30m) / (hubble:flows_processed_increase_30m > 0) ) > 0.001 @@ -82,7 +139,8 @@ spec: summary: "Hubble is losing a material share of flows on {{ $labels.node }}" description: | {{ $labels.node }} has lost more than 0.1% of the flows it processed - over the last 30 min (ratio {{ $value | humanizePercentage }}). + over the last 30 min (ratio {{ $value | humanizePercentage }}), from the + real-loss sources (`perf_event_ring_buffer` / `observer_events_queue`). Treat every flow-based conclusion for this node as partial until `hubble:lost_events_increase_30m` returns to 0.