Commit graph homek8s/infrastructure/logging/alloy
Author SHA1 Message Date
Lance Walters
78f94ab85e fix(logging): build the audit line from a JMESPath allowlist, never pack the raw record
stage.pack embeds the original line under `_entry`, so the first cut wrote
responseObject.data (plaintext secrets) into Loki anyway. Replace pack with a
single JMESPath multi-select hash + stage.output: the emitted line contains
exactly the allowlisted keys and nothing else, with proper JSON escaping.
Verified end-to-end against a synthetic record carrying data.password using
loki.echo: 0 occurrences of the value, labels resource/verb still present.
2026-11-27 00:56:07 -05:00
Lance Walters
d65296c92a fix(logging): sourceIPs[0] in the audit JMESPath (Alloy stage.json uses JMESPath, not GJSON) 2026-11-27 00:52:02 -05:00
Lance Walters
fef71a280a infra(logging): ship kube-apiserver audit log with secret bodies stripped
t_104f62a6 made the apiserver audit log live on siriussec:
/var/log/kubernetes/audit/audit.log, mode 600 root, ~2.2 GB/day, rotated by the
apiserver itself (100 MB x 48, compressed). A pod-log collector never sees a
host file, so Alloy gets a read-only hostPath mount for that directory.

The file MUST NOT be shipped verbatim: at level=RequestResponse every
'get secrets' record carries responseObject.data — the plaintext secret.
The shipper therefore parses each record and re-emits a packed allowlist
(level, stage, verb, user, objectRef.*, responseStatus.code, sourceIPs[0],
userAgent, auditID, requestURI, requestReceivedTimestamp). requestObject and
responseObject never reach Loki; unparseable lines are dropped by stage.json
rather than passed through.

Nothing in that directory is written or pruned by the collector: the
apiserver's own 4.8 GB / 7-day rotation stays the only thing pruning it.
2026-11-27 00:49:07 -05:00
Lance Walters
4a933a0403 infra(logging): drop osint scrapy item payloads so 8 days fits the PVC
Measured during a crawl (2026-11-27 04:45-05:45Z): osint/news-scraper produced
~150 MB/h, 88 % of it one JSON item dump per crawled article (up to 4.7 kB per
line, the same rows are in the osint Postgres DB). At the observed 2.9x
compression that is ~10 GB over 192h and would not fit the 8Gi PVC, so drop
exactly those lines by prefix for that one container. Operational lines
(INFO/WARNING/ERROR, tracebacks, duplicate-URL warnings) still ship.

docs/logging.md: document the drop rule and the two measured regimes.
2026-11-27 00:45:42 -05:00
Lance Walters
179257d8fb infra(logging): Loki single-binary + Alloy DaemonSet, 192h bounded retention (F4)
No log store existed: pod logs were kubelet files on the node and died with the
pod (~8h deepest history for a busy workload). Adds:

- Loki 3.7.1 single-binary (1 Deployment + 8Gi local-path PVC on siriussec),
  retention_period 192h with the compactor deleting on filesystem, ingest rate
  limits, so the store is time- and rate-bounded.
- Alloy 1.13.0 DaemonSet (all nodes, no RBAC, no API access) shipping
  /var/log/pods, /var/log/journal and the Pi's docker json logs. File sources
  read from byte 0 and stamp the timestamp from the line, so the history the
  nodes already held (18d cilium on linode, 31d registry on rpi) landed on day
  one instead of starting the 7-day clock at deploy time.
- Grafana datasource (uid loki) via the existing sidecar, ServiceMonitor,
  ingest-rate guard rule.
- docs/logging.md with the measured bytes/day, the 8-day projection and the
  runbook.

Measured: ~360-502 MB/day raw -> ~90 MB/day compressed, 192h -> <=0.8GiB, on a
node with 103GiB free (house floor 32GiB). Verified 7-day-old lines return for
kube-system cilium-agent and for the siriussec/linode journals, and survive a
Loki pod restart (PVC).
2026-11-27 00:36:56 -05:00