feat(backend): approximate distinct-source count for Sentinel rejections #29

Merged
starkSV merged 2 commits from feat/sentinel-distinct-sources into main 2026-07-13 12:46:06 +05:30

2 commits

Author SHA1 Message Date
Shekhar Vaidya
327c5e195d simplify(backend): drop date-scoping for Sentinel stats, use flat all-time fields
Matches the shape actually asked for and how every other telemetry
counter in this file already works (all-time cumulative via HIncrBy,
no expiry, no per-day key rotation): /metrics now exposes flat
sentinel_errors and sentinel_distinct_sources_est fields instead of a
nested, date-scoped sentinel_today object.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-13 12:43:31 +05:30
Shekhar Vaidya
b252ba1c30 feat(backend): approximate distinct-source count for Sentinel rejections
CLI telemetry showed a growing count of Sentinel rejections but no way
to tell whether they come from one user retrying repeatedly or many
distinct users independently getting blocked.

Adds a per-day Redis HyperLogLog (msdl:telemetry:sentinel_hll:<date>)
seeded from the reporting IP whenever a CLI error contains "Sentinel",
plus a parallel daily counter. /metrics now exposes sentinel_today:
{date, errors_today, distinct_sources_est}. No raw IPs are stored --
HLL is a one-way cardinality estimator, and both keys expire after 48h.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-13 12:37:01 +05:30