networking(hubble): deepen the event ring to 16383 flows and gate detection on loss (F10) #44

Merged
sirius merged 1 commit from netsec/hubble-event-loss into master 2026-11-27 05:17:26 +00:00
3 changed files with 119 additions and 0 deletions

View file

@ -59,6 +59,21 @@ prometheus:
trustCRDsExist: true
hubble:
# Ring depth, in flows. The chart default (4095) is only ~51 s of history on
# siriussec at its ~80 flows/s, and `getFlowRate()` — called by every
# `hubble status`, by the agent's own 5 s hubble health probe and by the UI —
# walks the ring backwards over a full minute. When the ring is shorter than
# that walk it reaches the read boundary, `Ring.read()` synthesises a
# HUBBLE_RING_BUFFER lost event and bumps `hubble_lost_events_total`
# (cilium#46584, fixed upstream only on forward reads). Result: a constant
# 12 increments/min on siriussec with nothing actually dropped.
# 16383 keeps >= 60 s at the 24 h peak on every node (linode 196 flows/s ->
# 83 s, siriussec 101 flows/s -> 161 s, rpi 38 flows/s -> 431 s), so the walk
# stops on the timestamp check before it can touch the boundary. Must be
# 2^n-1 (Cilium's ring only accepts 4095/8191/16383/32767/65535).
# Cost: see docs/hubble-event-loss.md — the ring retains *Event pointers, so
# the delta is bounded and measured, not assumed.
eventBufferCapacity: "16383"
# Flow/Forensics UI is reachable over WireGuard only, by bare IP on the
# dedicated `internal/hubble-ui` gateway: http://10.10.0.2:8084/ (port 8084,
# its own Gateway because Cilium merges hostname-less routes that share one).

View file

@ -0,0 +1,102 @@
# Hubble flow-loss gate (audit F10).
#
# The flow stream is the sensor input for every flow-shaped detector
# (first-seen egress, beaconing shape, east-west novelty). If the agent's ring
# buffer drops events, a "quiet" window is indistinguishable from a lossy one,
# and a detector built on it will happily report "all clear" from an incomplete
# 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.
#
# Thresholds:
# gate : increase over 30 m > 0 events -> warning, window tainted
# material : lost / processed Trace flows > 0.1 % -> critical, real loss
# 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.
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: hubble-event-loss
namespace: monitoring
labels:
release: kube-prometheus-stack
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.
- record: hubble:lost_events_increase_30m
expr: |
sum by (node) (increase(hubble_lost_events_total{source="hubble_ring_buffer"}[30m]))
# Denominator for the material-loss ratio. Trace is the total flow
# counter; L7/Drop/PolicyVerdict are subsets of it and would
# double-count.
- record: hubble:flows_processed_increase_30m
expr: |
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.
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"
description: |
hubble_lost_events_total{source="hubble_ring_buffer"} 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 <cilium-agent> -c cilium-agent --
hubble status` (Current/Max Flows) and the agent's flow rate against
hubble.eventBufferCapacity in infrastructure/networking/cilium/values.yaml.
- alert: HubbleFlowLossMaterial
# Escalation: 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.
expr: |
(
hubble:lost_events_increase_30m
/
(hubble:flows_processed_increase_30m > 0)
) > 0.001
for: 15m
labels:
severity: critical
component: hubble
annotations:
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 }}).
Treat every flow-based conclusion for this node as partial until
`hubble:lost_events_increase_30m` returns to 0.
- alert: HubbleFlowSensorMissing
# No series at all is worse than loss: the detector has no input and
# the gate cannot even evaluate. `absent()` on the recording rule.
expr: absent(hubble:flows_processed_increase_30m)
for: 15m
labels:
severity: critical
component: hubble
annotations:
summary: "No Hubble flow counters are being scraped"
description: |
No `hubble_flows_processed_total` series exist for 15 min. Either the
`hubble-metrics` scrape targets are down or the Cilium DaemonSet is not
running; flow-based detection is blind.

View file

@ -9,6 +9,8 @@ resources:
- gateway-probe.yaml
- garage.yaml
- prune-alerts.yaml
# Flow-loss gate + material-loss alerts for the Hubble sensor (audit F10).
- hubble-loss-gate.yaml
# Nightly consistent sqlite snapshot of Grafana's dashboards/alerts/users.
- grafana-backup.yaml
- dashboards