Skip to content

Filter metric names with regex in list_metrics call#32

Open
saswatamcode wants to merge 4 commits intorhobs:mainfrom
saswatamcode:filterlist
Open

Filter metric names with regex in list_metrics call#32
saswatamcode wants to merge 4 commits intorhobs:mainfrom
saswatamcode:filterlist

Conversation

@saswatamcode
Copy link
Member

No description provided.

@saswatamcode saswatamcode requested a review from a team February 13, 2026 11:41
@openshift-ci openshift-ci bot requested review from iNecas and xiormeesh February 13, 2026 11:41
Signed-off-by: Saswata Mukherjee <[email protected]>
iNecas
iNecas previously approved these changes Feb 13, 2026
Signed-off-by: Saswata Mukherjee <[email protected]>

// For blanket regex patterns like ".*", use empty matcher to get all metrics to not get 4xx.
if nameRegex != ".*" && nameRegex != ".+" && nameRegex != "" {
matcher := fmt.Sprintf("{__name__=~\"%q\"}", nameRegex)
Copy link
Contributor

@iNecas iNecas Feb 13, 2026

Choose a reason for hiding this comment

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

This is probably not the right fix. Still fails for other regexps, worked with:

matcher := fmt.Sprintf("{__name__=~%q}", nameRegex)

#sarcasm you're prompting it wrong #/sarcasm

Signed-off-by: Saswata Mukherjee <[email protected]>
// For blanket regex patterns like ".*", use empty matcher to get all metrics to not get 4xx.
if nameRegex != ".*" && nameRegex != ".+" && nameRegex != "" {
matcher := fmt.Sprintf("{__name__=~\"%q\"}", nameRegex)
matcher := fmt.Sprintf("{__name__=~\"%s\"}", nameRegex) //nolint:gocritic
Copy link
Contributor

Choose a reason for hiding this comment

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

with this fix, we don't need the additional if anymore, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

We do, as prometheus treats .* as an empty matcher, and fails the request with {"status":"error","errorType":"bad_data","error":"match[] must contain at least one non-empty matcher"}

Copy link
Contributor

Choose a reason for hiding this comment

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

You are absolutely correct :)

@openshift-ci openshift-ci bot added the lgtm label Feb 13, 2026
@openshift-ci
Copy link

openshift-ci bot commented Feb 13, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: iNecas, saswatamcode

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [iNecas,saswatamcode]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci
Copy link

openshift-ci bot commented Feb 13, 2026

@saswatamcode: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-obs-mcp-gcp cabbc51 link false /test e2e-obs-mcp-gcp

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants