CNV-80608: k8s: add alert listing/query and filter primitives#832
CNV-80608: k8s: add alert listing/query and filter primitives#832sradco wants to merge 1 commit intoopenshift:alerts-management-apifrom
Conversation
|
@sradco: This pull request references CNV-80608 which is a valid jira issue. DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: sradco The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository: openshift/coderabbit/.coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@sradco: This pull request references CNV-80608 which is a valid jira issue. DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
Add PrometheusAlerts implementation with: - Alert fetching from platform and user-workload Prometheus/Thanos - Rule group fetching with namespace-scoped Thanos tenancy queries - State-based filtering (firing, pending, silenced) - Label-based flat filtering with key=value matching - TLS transport with service CA for in-cluster communication Signed-off-by: Shirly Radco <sradco@redhat.com> Signed-off-by: João Vilaça <jvilaca@redhat.com> Signed-off-by: Aviv Litman <alitman@redhat.com> Co-authored-by: AI Assistant <noreply@cursor.com>
08289c7 to
ffe8541
Compare
|
Hi @jgbernalp , @jan--f , @simonpasquier, Will appreciate your review of this pr. Thank you. |
simonpasquier
left a comment
There was a problem hiding this comment.
I've made a few comments but overall the PR is hard to review because the added code is often not used. I'd rather have one API endpoint implemented at a time (even if not witha ll the functionality).
| return pa.executeRequest(ctx, client, requestURL) | ||
| } | ||
|
|
||
| func (pa *prometheusAlerts) resolveThanosTenancyRulesPort(ctx context.Context) int32 { |
There was a problem hiding this comment.
why do we need to resolve the port? it's a fixed value (and part of the CMO contract somehow).
| if sel == "" { | ||
| continue | ||
| } | ||
| if !strings.Contains(sel, "{") { |
There was a problem hiding this comment.
what if we have a "{" in the label value?
| func compileRuleLabelMatchers(req GetRulesRequest) ([]*labels.Matcher, error) { | ||
| var out []*labels.Matcher | ||
|
|
||
| for k, v := range req.Labels { |
There was a problem hiding this comment.
I don't understand why we need 2 ways (Labels and Matchers) for matching rules...
| return groups, nil | ||
| } | ||
|
|
||
| return filterRuleGroupsByLabelMatchers(groups, matchers), nil |
There was a problem hiding this comment.
why don't we apply label matchers directly in the requests querying the backends?
| return nil, fmt.Errorf("failed to create PrometheusRule manager: %w", err) | ||
| } | ||
|
|
||
| c.prometheusAlerts = newPrometheusAlerts(routeClientset, clientset.CoreV1(), config, c.prometheusRuleManager) |
There was a problem hiding this comment.
why going through the route?
| token := BearerTokenFromContext(ctx) | ||
| if token == "" { | ||
| var err error | ||
| token, err = pa.loadBearerToken() |
There was a problem hiding this comment.
does it mean that we use the service account's token?
| return filterRuleGroupsByLabelMatchers(groups, matchers), nil | ||
| } | ||
|
|
||
| func (pa *prometheusAlerts) alertingHealth(ctx context.Context) AlertingHealth { |
There was a problem hiding this comment.
I don't understand what the purpose of this method?
|
There are also very few tests compared to the number of lines being added. |
|
@simonpasquier let me address your concern of the split first to hopefully make it easier to review |
|
Closing this PR in favor of #841 |
Alert Management API — Part 2/15: alert listing, query & filter primitives
Summary
PrometheusAlertsimplementation: fetches alerts and rule groups from both platform and user-workload Prometheus/Thanos endpointskey=value) with special handling fornamespace(used for tenancy selection, not rule filtering)match[]semantics) supporting full selectors and selector bodiesDependencies
This PR is part of a stacked series. Please review in order.
3–15. Pending — relabel config, alerting health, management foundation, CRUD endpoints, classification, bulk update, docs/CI/e2e, single-rule API, orphan GC, effective metric
Made with Cursor