Skip to content

admin: add invert_filter query param to /stats#46073

Open
aakugan wants to merge 2 commits into
envoyproxy:mainfrom
aakugan:neg-rule-stats
Open

admin: add invert_filter query param to /stats#46073
aakugan wants to merge 2 commits into
envoyproxy:mainfrom
aakugan:neg-rule-stats

Conversation

@aakugan

@aakugan aakugan commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Commit Message

admin: add invert_filter query param to /stats

Additional Description

Adds an invert_filter query parameter to the admin /stats endpoint (text, json, and prometheus formats). When present alongside filter, the RE2 regex is inverted: stats whose names match the filter are excluded, and non-matching stats are returned.
Example: /stats?filter=server&invert_filter returns all stats except those matching server.
invert_filter without filter returns HTTP 400.

Needed because the re2 engine is not great at handling inversions like these.

Testing:

  • stats_params_test: parse validation (invert_filter requires filter), shouldShowMetric positive/negative cases
  • stats_handler_test: invert filter for text, json, and prometheus output
  • stats_request_test: prometheus stat-map filtering with inverted filter
  • admin_test: admin integration coverage

Risk Level

Low

Signed-off-by: aakugan <aakashganapathy2@gmail.com>
@repokitteh-read-only

Copy link
Copy Markdown

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #46073 was opened by aakugan.

see: more, trace.

@aakugan aakugan marked this pull request as ready for review July 14, 2026 15:33
@basundhara-c

Copy link
Copy Markdown
Contributor

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces an invert_filter query parameter to the /stats and /stats/prometheus admin endpoints, allowing users to exclude stats matching the specified regular expression. The changes include parameter parsing, logic to invert the regex matching results, updated documentation, and comprehensive unit tests. The review feedback suggests two improvements: using the more idiomatic query_.has() method to check for the presence of the query parameter, and defensively handling null filters within shouldShowMetricName to simplify callers and prevent potential null pointer dereferences.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread source/server/admin/stats_params.cc Outdated
Comment thread source/server/admin/stats_params.h
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: aakugan <164153358+aakugan@users.noreply.github.com>
Signed-off-by: aakugan <aakashganapathy2@gmail.com>
@aakugan aakugan requested a review from basundhara-c July 15, 2026 05:48
@basundhara-c

Copy link
Copy Markdown
Contributor

@agrawroh could you TAL?

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