diff --git a/CHANGELOG.md b/CHANGELOG.md index fb01005e0d..10d2ccbee1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * [CHANGE] Server: Instrument `cortex_request_duration_seconds` metric with native histogram. If `native-histograms` feature is enabled in monitoring Prometheus then the metric name needs to be updated in your dashboards. #6056 * [CHANGE] Distributor/Ingester: Change `cortex_distributor_ingester_appends_total`, `cortex_distributor_ingester_append_failures_total`, `cortex_distributor_ingester_queries_total`, and `cortex_distributor_ingester_query_failures_total` metrics to use the ingester ID instead of its IP as the label value. #6078 * [FEATURE] Ingester: Experimental: Enable native histogram ingestion via `-blocks-storage.tsdb.enable-native-histograms` flag. #5986 +* [FEATURE] Ruler: Add support for filtering out alerts in ListRules API. #6011 * [FEATURE] Query Frontend: Added a query rejection mechanism to block resource-intensive queries. #6005 * [FEATURE] OTLP: Support ingesting OTLP exponential metrics as native histograms. #6071 * [FEATURE] Ingester: Add `ingester.instance-limits.max-inflight-query-requests` to allow limiting ingester concurrent queries. #6081 diff --git a/integration/e2ecortex/client.go b/integration/e2ecortex/client.go index dbc626d6a5..5f45d6d59f 100644 --- a/integration/e2ecortex/client.go +++ b/integration/e2ecortex/client.go @@ -526,6 +526,7 @@ type RuleFilter struct { RuleGroupNames []string RuleNames []string RuleType string + ExcludeAlerts string } func addQueryParams(urlValues url.Values, paramName string, params ...string) { @@ -551,6 +552,7 @@ func (c *Client) GetPrometheusRules(filter RuleFilter) ([]*ruler.RuleGroup, erro addQueryParams(urlValues, "rule_name[]", filter.RuleNames...) addQueryParams(urlValues, "rule_group[]", filter.RuleGroupNames...) addQueryParams(urlValues, "type", filter.RuleType) + addQueryParams(urlValues, "exclude_alerts", filter.ExcludeAlerts) req.URL.RawQuery = urlValues.Encode() ctx, cancel := context.WithTimeout(context.Background(), c.timeout) diff --git a/integration/ruler_test.go b/integration/ruler_test.go index 37c086fe23..2da8db2e01 100644 --- a/integration/ruler_test.go +++ b/integration/ruler_test.go @@ -414,6 +414,7 @@ func testRulerAPIWithSharding(t *testing.T, enableRulesBackup bool) { ruleGroups := make([]rulefmt.RuleGroup, numRulesGroups) expectedNames := make([]string, numRulesGroups) alertCount := 0 + evalInterval, _ := model.ParseDuration("1s") for i := 0; i < numRulesGroups; i++ { num := random.Intn(100) var ruleNode yaml.Node @@ -428,7 +429,7 @@ func testRulerAPIWithSharding(t *testing.T, enableRulesBackup bool) { alertCount++ ruleGroups[i] = rulefmt.RuleGroup{ Name: ruleName, - Interval: 60, + Interval: evalInterval, Rules: []rulefmt.RuleNode{{ Alert: ruleNode, Expr: exprNode, @@ -437,7 +438,7 @@ func testRulerAPIWithSharding(t *testing.T, enableRulesBackup bool) { } else { ruleGroups[i] = rulefmt.RuleGroup{ Name: ruleName, - Interval: 60, + Interval: evalInterval, Rules: []rulefmt.RuleNode{{ Record: ruleNode, Expr: exprNode, @@ -458,6 +459,7 @@ func testRulerAPIWithSharding(t *testing.T, enableRulesBackup bool) { "-querier.store-gateway-addresses": "localhost:12345", // Enable the bucket index so we can skip the initial bucket scan. "-blocks-storage.bucket-store.bucket-index.enabled": "true", + "-ruler.poll-interval": "5s", } if enableRulesBackup { overrides["-ruler.ring.replication-factor"] = "3" @@ -553,6 +555,42 @@ func testRulerAPIWithSharding(t *testing.T, enableRulesBackup bool) { assert.Len(t, ruleNames, 3, "Expected %d rules but got %d", 3, len(ruleNames)) }, }, + "Exclude Alerts": { + filter: e2ecortex.RuleFilter{ + ExcludeAlerts: "true", + }, + resultCheckFn: func(t assert.TestingT, ruleGroups []*ruler.RuleGroup) { + alertsCount := 0 + for _, ruleGroup := range ruleGroups { + for _, rule := range ruleGroup.Rules { + r := rule.(map[string]interface{}) + if v, OK := r["alerts"]; OK { + alerts := v.([]interface{}) + alertsCount = alertsCount + len(alerts) + } + } + } + assert.Equal(t, 0, alertsCount, "Expected 0 alerts but got %d", alertsCount) + }, + }, + "Include Alerts": { + filter: e2ecortex.RuleFilter{ + ExcludeAlerts: "false", + }, + resultCheckFn: func(t assert.TestingT, ruleGroups []*ruler.RuleGroup) { + alertsCount := 0 + for _, ruleGroup := range ruleGroups { + for _, rule := range ruleGroup.Rules { + r := rule.(map[string]interface{}) + if v, OK := r["alerts"]; OK { + alerts := v.([]interface{}) + alertsCount = alertsCount + len(alerts) + } + } + } + assert.Greater(t, alertsCount, 0, "Expected greater than 0 alerts but got %d", alertsCount) + }, + }, } // For each test case, fetch the rules with configured filters, and ensure the results match. if enableRulesBackup { diff --git a/pkg/ruler/api.go b/pkg/ruler/api.go index 6c1a868966..0294a78c61 100644 --- a/pkg/ruler/api.go +++ b/pkg/ruler/api.go @@ -154,6 +154,12 @@ func (a *API) PrometheusRules(w http.ResponseWriter, req *http.Request) { return } + excludeAlerts, err := parseExcludeAlerts(req) + if err != nil { + util_api.RespondError(logger, w, v1.ErrBadData, fmt.Sprintf("invalid parameter %q: %s", "exclude_alerts", err.Error()), http.StatusBadRequest) + return + } + rulesRequest := RulesRequest{ RuleNames: req.Form["rule_name[]"], RuleGroupNames: req.Form["rule_group[]"], @@ -162,6 +168,7 @@ func (a *API) PrometheusRules(w http.ResponseWriter, req *http.Request) { State: state, Health: health, Matchers: req.Form["match[]"], + ExcludeAlerts: excludeAlerts, } w.Header().Set("Content-Type", "application/json") @@ -256,6 +263,20 @@ func (a *API) PrometheusRules(w http.ResponseWriter, req *http.Request) { } } +func parseExcludeAlerts(r *http.Request) (bool, error) { + excludeAlertsParam := strings.ToLower(r.URL.Query().Get("exclude_alerts")) + + if excludeAlertsParam == "" { + return false, nil + } + + excludeAlerts, err := strconv.ParseBool(excludeAlertsParam) + if err != nil { + return false, fmt.Errorf("error converting exclude_alerts: %w", err) + } + return excludeAlerts, nil +} + func (a *API) PrometheusAlerts(w http.ResponseWriter, req *http.Request) { logger := util_log.WithContext(req.Context(), a.logger) userID, err := tenant.TenantID(req.Context()) diff --git a/pkg/ruler/ruler.go b/pkg/ruler/ruler.go index f37bc3ce93..dfacb61d80 100644 --- a/pkg/ruler/ruler.go +++ b/pkg/ruler/ruler.go @@ -950,19 +950,21 @@ func (r *Ruler) getLocalRules(userID string, rulesRequest RulesRequest, includeB continue } alerts := []*AlertStateDesc{} - for _, a := range rule.ActiveAlerts() { - alerts = append(alerts, &AlertStateDesc{ - State: a.State.String(), - Labels: cortexpb.FromLabelsToLabelAdapters(a.Labels), - Annotations: cortexpb.FromLabelsToLabelAdapters(a.Annotations), - Value: a.Value, - ActiveAt: a.ActiveAt, - FiredAt: a.FiredAt, - ResolvedAt: a.ResolvedAt, - LastSentAt: a.LastSentAt, - ValidUntil: a.ValidUntil, - KeepFiringSince: a.KeepFiringSince, - }) + if !rulesRequest.ExcludeAlerts { + for _, a := range rule.ActiveAlerts() { + alerts = append(alerts, &AlertStateDesc{ + State: a.State.String(), + Labels: cortexpb.FromLabelsToLabelAdapters(a.Labels), + Annotations: cortexpb.FromLabelsToLabelAdapters(a.Annotations), + Value: a.Value, + ActiveAt: a.ActiveAt, + FiredAt: a.FiredAt, + ResolvedAt: a.ResolvedAt, + LastSentAt: a.LastSentAt, + ValidUntil: a.ValidUntil, + KeepFiringSince: a.KeepFiringSince, + }) + } } ruleDesc = &RuleStateDesc{ Rule: &rulespb.RuleDesc{ @@ -1174,6 +1176,7 @@ func (r *Ruler) getShardedRules(ctx context.Context, userID string, rulesRequest RuleGroupNames: rulesRequest.GetRuleGroupNames(), Files: rulesRequest.GetFiles(), Type: rulesRequest.GetType(), + ExcludeAlerts: rulesRequest.GetExcludeAlerts(), Matchers: rulesRequest.GetMatchers(), }) diff --git a/pkg/ruler/ruler.pb.go b/pkg/ruler/ruler.pb.go index 213c8ee827..5eb36c7a6a 100644 --- a/pkg/ruler/ruler.pb.go +++ b/pkg/ruler/ruler.pb.go @@ -46,6 +46,7 @@ type RulesRequest struct { State string `protobuf:"bytes,5,opt,name=state,proto3" json:"state,omitempty"` Health string `protobuf:"bytes,6,opt,name=health,proto3" json:"health,omitempty"` Matchers []string `protobuf:"bytes,7,rep,name=matchers,proto3" json:"matchers,omitempty"` + ExcludeAlerts bool `protobuf:"varint,8,opt,name=excludeAlerts,proto3" json:"excludeAlerts,omitempty"` } func (m *RulesRequest) Reset() { *m = RulesRequest{} } @@ -129,6 +130,13 @@ func (m *RulesRequest) GetMatchers() []string { return nil } +func (m *RulesRequest) GetExcludeAlerts() bool { + if m != nil { + return m.ExcludeAlerts + } + return false +} + type RulesResponse struct { Groups []*GroupStateDesc `protobuf:"bytes,1,rep,name=groups,proto3" json:"groups,omitempty"` } @@ -444,56 +452,57 @@ func init() { func init() { proto.RegisterFile("ruler.proto", fileDescriptor_9ecbec0a4cfddea6) } var fileDescriptor_9ecbec0a4cfddea6 = []byte{ - // 774 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0x4d, 0x4f, 0x13, 0x4f, - 0x18, 0xdf, 0x69, 0xe9, 0xdb, 0x94, 0x3f, 0xe4, 0x3f, 0x54, 0xb3, 0x36, 0x64, 0x4b, 0x6a, 0x62, - 0x88, 0x89, 0xdb, 0xa4, 0x92, 0x18, 0x0f, 0x68, 0x4a, 0x00, 0x2f, 0xc6, 0x90, 0xad, 0x7a, 0x6d, - 0xa6, 0xed, 0x74, 0xbb, 0xb2, 0xdd, 0x59, 0x67, 0x66, 0x1b, 0xbc, 0xf9, 0x11, 0x38, 0x7a, 0xf6, - 0xe4, 0x47, 0xe1, 0x48, 0x3c, 0x11, 0x63, 0x50, 0xca, 0xc5, 0x23, 0x1f, 0xc1, 0xcc, 0xcc, 0x2e, - 0xdb, 0x22, 0x26, 0x34, 0x86, 0x0b, 0xcc, 0xf3, 0xf2, 0x7b, 0x5e, 0x7e, 0xcf, 0xb3, 0x4f, 0x61, - 0x99, 0x45, 0x3e, 0x61, 0x76, 0xc8, 0xa8, 0xa0, 0x28, 0xa7, 0x84, 0x6a, 0xc5, 0xa5, 0x2e, 0x55, - 0x9a, 0x86, 0x7c, 0x69, 0x63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, 0xe6, 0x05, 0x6e, 0x87, 0x7b, 0x41, - 0x8f, 0x98, 0x70, 0x8e, 0x60, 0xcb, 0x12, 0xbe, 0xab, 0xd0, 0x6d, 0x09, 0x6e, 0x6e, 0xc2, 0x9c, - 0x3c, 0x07, 0x0c, 0x6d, 0xe8, 0x07, 0x47, 0x2b, 0x53, 0x57, 0x31, 0xf9, 0xe5, 0xa9, 0x56, 0x66, - 0x95, 0xfa, 0x88, 0xd7, 0x8d, 0xad, 0x8d, 0xe3, 0x33, 0xcb, 0x38, 0x39, 0xb3, 0x8c, 0x8b, 0x33, - 0x0b, 0x7c, 0x9c, 0x58, 0xe0, 0xcb, 0xc4, 0x02, 0x47, 0x13, 0x0b, 0x1c, 0x4f, 0x2c, 0xf0, 0x73, - 0x62, 0x81, 0x5f, 0x13, 0xcb, 0xb8, 0x98, 0x58, 0xe0, 0xf0, 0xdc, 0x32, 0x8e, 0xcf, 0x2d, 0xe3, - 0xe4, 0xdc, 0x32, 0xba, 0x79, 0x55, 0xe3, 0xe3, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xb1, 0xdb, - 0xbe, 0x81, 0xc6, 0x07, 0x00, 0x00, + // 793 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0x4d, 0x6b, 0x13, 0x41, + 0x18, 0xde, 0x49, 0x9a, 0xaf, 0x49, 0x3f, 0x70, 0x1a, 0x65, 0x0d, 0x65, 0x13, 0xa2, 0x48, 0x10, + 0xdc, 0x40, 0x2c, 0x88, 0x87, 0x2a, 0x29, 0x6d, 0xbd, 0x88, 0x94, 0x8d, 0x7a, 0x0d, 0x93, 0xcd, + 0x64, 0xb3, 0x76, 0xb3, 0xbb, 0xce, 0xcc, 0x86, 0x7a, 0xf3, 0x27, 0xf4, 0xe8, 0xd9, 0x93, 0x3f, + 0xa5, 0xc7, 0xe2, 0xa9, 0x88, 0x54, 0x9b, 0x5e, 0x3c, 0x49, 0x7f, 0x82, 0xcc, 0xcc, 0x6e, 0x93, + 0xd4, 0x0a, 0x0d, 0xd2, 0x4b, 0x3b, 0xef, 0xc7, 0xf3, 0xce, 0xfb, 0x3e, 0xf3, 0xec, 0x1b, 0x58, + 0xa4, 0x91, 0x47, 0xa8, 0x19, 0xd2, 0x80, 0x07, 0x28, 0x23, 0x8d, 0x72, 0xc9, 0x09, 0x9c, 0x40, + 0x7a, 0x1a, 0xe2, 0xa4, 0x82, 0x65, 0xc3, 0x09, 0x02, 0xc7, 0x23, 0x0d, 0x69, 0x75, 0xa3, 0x7e, + 0xa3, 0x17, 0x51, 0xcc, 0xdd, 0xc0, 0x8f, 0xe3, 0x95, 0xcb, 0x71, 0xee, 0x0e, 0x09, 0xe3, 0x78, + 0x18, 0xc6, 0x09, 0x4f, 0x1d, 0x97, 0x0f, 0xa2, 0xae, 0x69, 0x07, 0xc3, 0x86, 0x1d, 0x50, 0x4e, + 0xf6, 0x43, 0x1a, 0xbc, 0x23, 0x36, 0x8f, 0xad, 0x46, 0xb8, 0xe7, 0x24, 0x81, 0x6e, 0x7c, 0x88, + 0xa1, 0x1b, 0xd7, 0x81, 0xca, 0xe6, 0xe5, 0x5f, 0x16, 0x76, 0xd5, 0x7f, 0x05, 0xaf, 0xfd, 0x06, + 0x70, 0xd1, 0x12, 0xb6, 0x45, 0xde, 0x47, 0x84, 0x71, 0xb4, 0x06, 0x0b, 0x22, 0xfe, 0x0a, 0x0f, + 0x09, 0xd3, 0x41, 0x35, 0x5d, 0x2f, 0x58, 0x13, 0x07, 0x7a, 0x00, 0x97, 0x85, 0xf1, 0x82, 0x06, + 0x51, 0xa8, 0x52, 0x52, 0x32, 0xe5, 0x92, 0x17, 0x95, 0x60, 0xa6, 0xef, 0x7a, 0x84, 0xe9, 0x69, + 0x19, 0x56, 0x06, 0x42, 0x70, 0x81, 0x7f, 0x08, 0x89, 0xbe, 0x50, 0x05, 0xf5, 0x82, 0x25, 0x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86, 0x9c, 0x44, 0xb5, 0x38, + 0xda, 0x86, 0x45, 0x4a, 0x58, 0xe0, 0x8d, 0x54, 0x8d, 0xdc, 0x1c, 0x35, 0x60, 0x02, 0x6c, 0x71, + 0xb4, 0x03, 0x17, 0x85, 0xb8, 0x3b, 0x8c, 0xf8, 0x5c, 0xd4, 0xc9, 0xcf, 0x53, 0x47, 0x20, 0xdb, + 0xc4, 0xe7, 0xaa, 0x9d, 0x11, 0xf6, 0xdc, 0x5e, 0x27, 0xf2, 0xb9, 0xeb, 0xe9, 0x85, 0x79, 0xca, + 0x48, 0xe0, 0x1b, 0x81, 0x43, 0xbb, 0xf0, 0xd6, 0x1e, 0x21, 0x61, 0xa7, 0xef, 0x52, 0xd7, 0x77, + 0x3a, 0xcc, 0xf5, 0x6d, 0xa2, 0xc3, 0x39, 0x8a, 0xad, 0x08, 0xf8, 0x8e, 0x44, 0xb7, 0x05, 0xb8, + 0xb9, 0x01, 0x33, 0x62, 0x1d, 0x50, 0xb4, 0xae, 0x0e, 0x0c, 0xad, 0x4e, 0x6d, 0xc5, 0xe4, 0xf7, + 0xa9, 0x5c, 0x9a, 0x75, 0xaa, 0x25, 0x5e, 0xd3, 0x36, 0xd7, 0x8f, 0x4e, 0x0d, 0xed, 0xf8, 0xd4, + 0xd0, 0xce, 0x4f, 0x0d, 0xf0, 0x71, 0x6c, 0x80, 0x2f, 0x63, 0x03, 0x1c, 0x8e, 0x0d, 0x70, 0x34, + 0x36, 0xc0, 0xcf, 0xb1, 0x01, 0x7e, 0x8d, 0x0d, 0xed, 0x7c, 0x6c, 0x80, 0x83, 0x33, 0x43, 0x3b, + 0x3a, 0x33, 0xb4, 0xe3, 0x33, 0x43, 0xeb, 0x66, 0x65, 0x8f, 0x8f, 0xff, 0x04, 0x00, 0x00, 0xff, + 0xff, 0x3a, 0xeb, 0x6f, 0xc9, 0xec, 0x07, 0x00, 0x00, } func (this *RulesRequest) Equal(that interface{}) bool { @@ -556,6 +565,9 @@ func (this *RulesRequest) Equal(that interface{}) bool { return false } } + if this.ExcludeAlerts != that1.ExcludeAlerts { + return false + } return true } func (this *RulesResponse) Equal(that interface{}) bool { @@ -737,7 +749,7 @@ func (this *RulesRequest) GoString() string { if this == nil { return "nil" } - s := make([]string, 0, 11) + s := make([]string, 0, 12) s = append(s, "&ruler.RulesRequest{") s = append(s, "RuleNames: "+fmt.Sprintf("%#v", this.RuleNames)+",\n") s = append(s, "RuleGroupNames: "+fmt.Sprintf("%#v", this.RuleGroupNames)+",\n") @@ -746,6 +758,7 @@ func (this *RulesRequest) GoString() string { s = append(s, "State: "+fmt.Sprintf("%#v", this.State)+",\n") s = append(s, "Health: "+fmt.Sprintf("%#v", this.Health)+",\n") s = append(s, "Matchers: "+fmt.Sprintf("%#v", this.Matchers)+",\n") + s = append(s, "ExcludeAlerts: "+fmt.Sprintf("%#v", this.ExcludeAlerts)+",\n") s = append(s, "}") return strings.Join(s, "") } @@ -926,6 +939,16 @@ func (m *RulesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.ExcludeAlerts { + i-- + if m.ExcludeAlerts { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x40 + } if len(m.Matchers) > 0 { for iNdEx := len(m.Matchers) - 1; iNdEx >= 0; iNdEx-- { i -= len(m.Matchers[iNdEx]) @@ -1339,6 +1362,9 @@ func (m *RulesRequest) Size() (n int) { n += 1 + l + sovRuler(uint64(l)) } } + if m.ExcludeAlerts { + n += 2 + } return n } @@ -1473,6 +1499,7 @@ func (this *RulesRequest) String() string { `State:` + fmt.Sprintf("%v", this.State) + `,`, `Health:` + fmt.Sprintf("%v", this.Health) + `,`, `Matchers:` + fmt.Sprintf("%v", this.Matchers) + `,`, + `ExcludeAlerts:` + fmt.Sprintf("%v", this.ExcludeAlerts) + `,`, `}`, }, "") return s @@ -1811,6 +1838,26 @@ func (m *RulesRequest) Unmarshal(dAtA []byte) error { } m.Matchers = append(m.Matchers, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ExcludeAlerts", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRuler + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.ExcludeAlerts = bool(v != 0) default: iNdEx = preIndex skippy, err := skipRuler(dAtA[iNdEx:]) diff --git a/pkg/ruler/ruler.proto b/pkg/ruler/ruler.proto index 0d1aa45525..42828f7352 100644 --- a/pkg/ruler/ruler.proto +++ b/pkg/ruler/ruler.proto @@ -27,6 +27,7 @@ message RulesRequest { string state = 5; string health = 6; repeated string matchers = 7; + bool excludeAlerts = 8; } message RulesResponse {