Filter metric names with regex in list_metrics call#32
Filter metric names with regex in list_metrics call#32saswatamcode wants to merge 4 commits intorhobs:mainfrom
Conversation
Signed-off-by: Saswata Mukherjee <[email protected]>
Signed-off-by: Saswata Mukherjee <[email protected]>
Signed-off-by: Saswata Mukherjee <[email protected]>
pkg/prometheus/loader.go
Outdated
|
|
||
| // 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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
with this fix, we don't need the additional if anymore, right?
There was a problem hiding this comment.
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"}
There was a problem hiding this comment.
You are absolutely correct :)
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
@saswatamcode: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions 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. |
No description provided.