netsec(collector): gzip on rotate so 960 MiB holds ~72-100 h of flows

The collector wrote 150 MiB plaintext files into a directory capped at 960 MiB,
which bought only ~4-5 h of retention at the measured 4.5-6.2 GB/day
(3380-4280 kB/min) of filtered Hubble JSONL — the cap was sized for a forensic
window, not for hours.

Compress on rotate; no schema change, no filter change, no DS argument change:

* the file being appended stays plain `flows-<ts>-<n>.jsonl` (one file for a
  reader to tail);
* on rotation the closed file is gzip'd to `.jsonl.gz` through a temp name +
  atomic rename, in the background, so a reader never sees a partial archive and
  the flow reader never stalls (stalling it makes the agent drop events);
* prune bounds the WHOLE directory at MAX_TOTAL_BYTES = 960 MiB — archives and
  in-flight `.gz.tmp` included — deleting oldest first, and never reaps the live
  file nor a file whose gzip is still running (that would discard the archive
  and lose the entire file);
* MAX_FILES now bounds plain files only. Applying it to the archives is exactly
  what would keep retention at a few hours.

Measured on this node's live data 2026-11-27: 18.53x ratio at gzip -9
(17.85x at -6), i.e. 960 MiB holds 72.6 h at the 6.16 GB/day burst sample,
92 h at 4.87 GB/day and ~100 h at the 4.48 GB/day 55-minute average.

Verified offline against a replaying fake `hubble` (rotation->archive parity,
gzip -t on every archive, atomicity, oldest-first prune, live-file and in-flight
protection) and inside the real cilium image under dash (23 rotations -> 23
valid archives, no loss).
This commit is contained in:
Lance Walters 2026-11-27 01:09:57 -05:00
commit 7e42ad6d1c
2 changed files with 135 additions and 25 deletions

View file

@ -55,8 +55,10 @@ spec:
value: /data
- name: SOCK
value: /var/run/cilium/hubble.sock
# 6 files x 150 MiB = 900 MiB ceiling, inside the 1 GiB spec cap;
# MAX_TOTAL_BYTES is the second, independent bound.
# MAX_FILES bounds PLAIN .jsonl files (the live one plus leftovers
# from a restart). Rotated files are gzip'd (~17.9x measured) and
# bounded by MAX_TOTAL_BYTES, the whole-directory ceiling (archives
# included) that stays inside the 1 GiB spec cap.
- name: MAX_FILE_BYTES
value: "157286400"
- name: MAX_FILES