Skip to content

Pass all name[] values to the Django metrics view - #1250

Merged
csmarchbanks merged 1 commit into
prometheus:masterfrom
sarankumar1325:fix/django-name-filter
Nov 12, 2026
Merged

csmarchbanks merged 1 commit into
prometheus:masterfrom
sarankumar1325:fix/django-name-filter

Conversation

@sarankumar1325

Copy link
Copy Markdown
Contributor

PrometheusDjangoView passes request.GET (a QueryDict) to _bake_output as params. _bake_output then does registry.restricted_registry(params['name[]']), but QueryDict.__getitem__ returns only the last value as a plain string. restricted_registry turns that into a set of characters, so /metrics?name[]=cc_total returns an empty body instead of the cc_total metric, and repeating name[] only keeps the last one.

The fix converts the query to a dict of lists (dict(request.GET.lists())), which is the same shape parse_qs gives the WSGI app.

Tests: two new cases in tests/test_django.py (single and multiple name[] values). Both fail on master and pass with the change. Full suite: 441 passed, 13 skipped. flake8 and isort are clean on the changed files.

PrometheusDjangoView passed request.GET straight to _bake_output.
QueryDict['name[]'] returns only the last value as a string, so
restricted_registry() built a set of its characters and
/metrics?name[]=foo returned no metrics. Convert the QueryDict to a
dict of lists, matching what parse_qs gives the WSGI app.

Signed-off-by: sarankumar1325 <120080287+sarankumar1325@users.noreply.github.com>

@csmarchbanks csmarchbanks left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@csmarchbanks
csmarchbanks merged commit c3c6ed6 into prometheus:master Nov 12, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants