Merge pull request 'infra(logging): drop osint scrapy item payloads so 8 days fits the PVC' (#56) from wt/t_34ddaa83 into master

This commit is contained in:
sirius 2026-11-27 05:45:51 +00:00
commit 35610c8d13
2 changed files with 50 additions and 12 deletions

View file

@ -27,6 +27,15 @@ Sources (all in `infrastructure/logging/alloy/config.alloy`):
cluster. Label is `container_id` (12 hex), not a name: the file path has no
name.
One **drop rule**, deliberately narrow: `osint`/`news-scraper` lines starting
with `{'title':` are scrapy *item payload dumps* (one per crawled article, up to
4.7 kB, ~88 % of that namespace's volume; the same rows are in the osint
Postgres DB). They are not operational log lines, and keeping them would push
8 days of retention past the 8Gi PVC. Counter:
`loki_process_dropped_lines_total{reason="osint_article_payload"}`. Everything
else from that container — INFO/WARNING/ERROR, tracebacks, the duplicate-URL
warnings — still ships.
`tail_from_end = false` + `stage.timestamp` on both file sources is deliberate.
The nodes already held history when this was deployed (the linode's
`cilium-agent` file reaches back 18 days, the Pi's registry log 31 days, the Pi's
@ -71,23 +80,35 @@ du -sh …/pvc-…_logging_loki-data 64M (37M chunks + 27M WAL + <1M i
=> ~5.6x compression
```
Projection with the *higher* of the two observed rates (an earlier 181 s window
measured 502 MB/day raw, before backfill fully drained — used as the bound):
Projection, with the *worst measured* window instead of the quiet one. Two
distinct regimes showed up on 2026-11-27:
- quiet: ~4 kB/s ≈ 360 MB/day raw (`osint` idle);
- **during an osint news-scraper crawl: 155 MB/h ≈ 3.7 GB/day raw**, of which
~88 % was the scrapy item payload dumps now dropped — that regime is what
forced the drop rule, because ~3 GB/day at the observed ~2.9x compression
(JSON-heavy lines compress worse than plain text) is ~10 GB over 8 days and
would not fit the PVC.
After the drop rule the `osint` container keeps only operational lines
(~22 MB/30 min ≈ 44 MB/h ≈ 1 GB/day raw at crawl rate, ~350 MB/day
compressed):
| | |
|---|---|
| raw ingest | ≤ 502 MB/day |
| compressed chunks | ≤ 90 MB/day (5.6x) |
| + TSDB index / cache | ~10 % → ≤ 100 MB/day |
| 192h retained window | **≤ 0.8 GiB** |
| PVC budget | 8 GiB (≈8x headroom) |
| node free before / after deploy | 103 GiB → 101 GiB (`/dev/nvme0n1p3`, 214 GiB) |
| raw ingest, drop rule applied | ~1 GB/day (crawl) / ~0.4 GB/day (quiet) |
| compression | 2.9–5.6x depending on mix |
| compressed chunks | ≤ 350 MB/day |
| + TSDB index / cache / WAL | ~10 % → **≤ 2.5 GiB over 192h** |
| PVC budget | 8 GiB (≈3x headroom at crawl rate) |
| node free before / after deploy | 103 GiB → 100 GiB (`/dev/nvme0n1p3`, 214 GiB) |
| house floor | 32 GiB free — untouched |
So the answer to "does it fit": yes, with an order of magnitude to spare; it uses
~1 % of the free space on `siriussec` and does not approach the floor. If the
volume ever grows 10x, the documented lever is `retention_period` (168h still
satisfies the 7-day floor) before anything touches the PVC size.
So the answer to "does it fit": yes, but the margin is set by the osint crawl,
not by the rest of the cluster. The levers, in order, if that changes:
`retention_period` 192h → 168h (still the 7-day floor), then widen the osint
drop rule, then raise the PVC. The ingest-rate alert
(`LokiIngestRateAboveBudget`, >12 MiB/s sustained) is the early warning.
## Querying

View file

@ -97,6 +97,23 @@ loki.process "pod_logs" {
}
}
// osint/news-scraper prints one JSON-ish *item* dump per crawled article
// (`{'title': ..., 'url': ..., ... }`, up to 4.7 kB each). That is scraped
// payload, not an operational log line — the same rows are written to the
// osint Postgres DB — and it is ~88 % of the namespace's volume (measured
// ~150 MB/h during a crawl). Keeping it would push 8 days of retention past
// the 8Gi PVC, so it is dropped here, by exact prefix, for that one
// container. Every operational line (scrapy INFO/WARNING/ERROR, tracebacks,
// duplicate-URL warnings) still ships.
stage.match {
selector = "{namespace=\"osint\", container=\"news-scraper\"}"
stage.drop {
expression = "^\\{'title':"
drop_counter_reason = "osint_article_payload"
}
}
forward_to = [loki.write.local.receiver]
}