fix(metrics): cap label cardinality — drop per-user views, *_created, raw-path leak - #179
Merged
Conversation
… raw-path leak Grafana Cloud free tier (10k series) was blown out at 14.5k+: - user_page_views_total + its _created twin were 12.9k series (88%) — username(286) x path. Dropped entirely along with the three dashboard panels that read it. - disable_created_metrics(): the OpenMetrics *_created companions doubled every counter/histogram and nothing read them (all "Unused" in the cardinality dashboard). - http_request_duration_seconds: method label removed (no dashboard queried it) + buckets 10 -> 6; ~1,260 series -> ~450. - Hardening: unmatched routes (bot POST probes) collapse to "(unmatched)" instead of minting a permanent series per raw URL; garbage verbs (PROPFIND, ...) collapse to OTHER; /class-icons/ joins the skip-list. Expected steady state ~1.5-2k active series. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Grafana Cloud free tier (10k active series) was blown out at 14.5k+. Cardinality dashboard breakdown:
user_page_views_total+_createdtwin = 12,905 series (88%) —username(286 values) × path. Dropped entirely (metric, middleware, and the three dashboard panels that read it).disable_created_metrics()— the OpenMetrics*_createdcompanion series doubled every counter/histogram and nothing read them (all flagged "Unused").http_request_duration_seconds:methodlabel removed (no dashboard query used it) + buckets 10 → 6 — ~1,260 series → ~450.http_requests_totalunchanged.(unmatched)path label instead of minting a permanent series per raw URL; scanner verbs (PROPFIND, …) collapse toOTHER;/class-icons/added to the metrics skip-list.Expected steady state: ~1.5–2k active series (~15–20% of free tier) with growth vectors capped.
Test plan
tests/server/test_metrics.py: label normalisation (templates kept, unmatched/garbage collapsed), histogram has no method label, no*_createdin scrape output, static-mount skip-list.ops/grafana/dashboards/frontend.jsonvalidated as JSON (6 panels remain).🤖 Generated with Claude Code