From 68c13cac94b1094e83bba6efc4ef2f33afa5a5d7 Mon Sep 17 00:00:00 2001 From: Krishna Teja Puttagunta Date: Tue, 22 Aug 2023 19:07:44 -0700 Subject: [PATCH] Add support for Limit field on RuleGroup which got introduced in https://github.com/prometheus/prometheus/pull/9260 Signed-off-by: Krishna Teja Puttagunta --- CHANGELOG.md | 1 + pkg/ruler/api.go | 2 + pkg/ruler/api_test.go | 55 ++++++++++++++++- pkg/ruler/ruler.go | 1 + pkg/ruler/rulespb/compat.go | 2 + pkg/ruler/rulespb/rules.pb.go | 107 +++++++++++++++++++++++----------- pkg/ruler/rulespb/rules.proto | 1 + pkg/ruler/store_mock_test.go | 21 +++++++ 8 files changed, 156 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aed97427c16..117ac06c8d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog ## master / unreleased +* [FEATURE] Ruler: Add support for Limit field on RuleGroup. #5528 * [FEATURE] AlertManager: Add support for Webex, Discord and Telegram Receiver. #5493 * [FEATURE] Ingester: added `-admin-limit-message` to customize the message contained in limit errors.#5460 * [CHANGE] AlertManager: include reason label in cortex_alertmanager_notifications_failed_total.#5409 diff --git a/pkg/ruler/api.go b/pkg/ruler/api.go index 8781f44364d..ecbbc94d585 100644 --- a/pkg/ruler/api.go +++ b/pkg/ruler/api.go @@ -69,6 +69,7 @@ type RuleGroup struct { Interval float64 `json:"interval"` LastEvaluation time.Time `json:"lastEvaluation"` EvaluationTime float64 `json:"evaluationTime"` + Limit int64 `json:"limit"` } type rule interface{} @@ -203,6 +204,7 @@ func (a *API) PrometheusRules(w http.ResponseWriter, req *http.Request) { Interval: g.Group.Interval.Seconds(), LastEvaluation: g.GetEvaluationTimestamp(), EvaluationTime: g.GetEvaluationDuration().Seconds(), + Limit: g.Group.Limit, } for i, rl := range g.ActiveRules { diff --git a/pkg/ruler/api_test.go b/pkg/ruler/api_test.go index 3085653d451..24fbe0b8327 100644 --- a/pkg/ruler/api_test.go +++ b/pkg/ruler/api_test.go @@ -127,10 +127,63 @@ func TestRuler_rules_special_characters(t *testing.T) { }, }, }) - require.Equal(t, string(expectedResponse), string(body)) } +func TestRuler_rules_limit(t *testing.T) { + store := newMockRuleStore(mockRulesLimit) + cfg := defaultRulerConfig(t) + + r := newTestRuler(t, cfg, store, nil) + defer services.StopAndAwaitTerminated(context.Background(), r) //nolint:errcheck + + a := NewAPI(r, r.store, log.NewNopLogger()) + + req := requestFor(t, http.MethodGet, "https://localhost:8080/api/prom/api/v1/rules", nil, "user1") + w := httptest.NewRecorder() + a.PrometheusRules(w, req) + + resp := w.Result() + body, _ := io.ReadAll(resp.Body) + // Check status code and status response + responseJSON := response{} + err := json.Unmarshal(body, &responseJSON) + require.NoError(t, err) + require.Equal(t, http.StatusOK, resp.StatusCode) + require.Equal(t, responseJSON.Status, "success") + + // Testing the running rules for user1 in the mock store + expectedResponse, _ := json.Marshal(response{ + Status: "success", + Data: &RuleDiscovery{ + RuleGroups: []*RuleGroup{ + { + Name: "group1", + File: "namespace1", + Limit: 5, + Rules: []rule{ + &recordingRule{ + Name: "UP_RULE", + Query: "up", + Health: "unknown", + Type: "recording", + }, + &alertingRule{ + Name: "UP_ALERT", + Query: "up < 1", + State: "inactive", + Health: "unknown", + Type: "alerting", + Alerts: []*Alert{}, + }, + }, + Interval: 60, + }, + }, + }, + }) + require.Equal(t, string(expectedResponse), string(body)) +} func TestRuler_alerts(t *testing.T) { store := newMockRuleStore(mockRules) cfg := defaultRulerConfig(t) diff --git a/pkg/ruler/ruler.go b/pkg/ruler/ruler.go index 2215c41faa2..ae5089a1b41 100644 --- a/pkg/ruler/ruler.go +++ b/pkg/ruler/ruler.go @@ -708,6 +708,7 @@ func (r *Ruler) getLocalRules(userID string, rulesRequest RulesRequest) ([]*Grou Namespace: string(decodedNamespace), Interval: interval, User: userID, + Limit: int64(group.Limit()), }, EvaluationTimestamp: group.GetLastEvaluation(), diff --git a/pkg/ruler/rulespb/compat.go b/pkg/ruler/rulespb/compat.go index 9c2524c04e4..e385051d7ed 100644 --- a/pkg/ruler/rulespb/compat.go +++ b/pkg/ruler/rulespb/compat.go @@ -19,6 +19,7 @@ func ToProto(user string, namespace string, rl rulefmt.RuleGroup) *RuleGroupDesc Interval: time.Duration(rl.Interval), Rules: formattedRuleToProto(rl.Rules), User: user, + Limit: int64(rl.Limit), } return &rg } @@ -45,6 +46,7 @@ func FromProto(rg *RuleGroupDesc) rulefmt.RuleGroup { Name: rg.GetName(), Interval: model.Duration(rg.Interval), Rules: make([]rulefmt.RuleNode, len(rg.GetRules())), + Limit: int(rg.Limit), } for i, rl := range rg.GetRules() { diff --git a/pkg/ruler/rulespb/rules.pb.go b/pkg/ruler/rulespb/rules.pb.go index b6081b637a8..aa8675c9e09 100644 --- a/pkg/ruler/rulespb/rules.pb.go +++ b/pkg/ruler/rulespb/rules.pb.go @@ -44,6 +44,7 @@ type RuleGroupDesc struct { // to create custom `ManagerOpts` based on rule configs which can then be passed // to the Prometheus Manager. Options []*types.Any `protobuf:"bytes,9,rep,name=options,proto3" json:"options,omitempty"` + Limit int64 `protobuf:"varint,10,opt,name=limit,proto3" json:"limit,omitempty"` } func (m *RuleGroupDesc) Reset() { *m = RuleGroupDesc{} } @@ -120,6 +121,13 @@ func (m *RuleGroupDesc) GetOptions() []*types.Any { return nil } +func (m *RuleGroupDesc) GetLimit() int64 { + if m != nil { + return m.Limit + } + return 0 +} + // RuleDesc is a proto representation of a Prometheus Rule type RuleDesc struct { Expr string `protobuf:"bytes,1,opt,name=expr,proto3" json:"expr,omitempty"` @@ -206,39 +214,40 @@ func init() { func init() { proto.RegisterFile("rules.proto", fileDescriptor_8e722d3e922f0937) } var fileDescriptor_8e722d3e922f0937 = []byte{ - // 511 bytes of a gzipped FileDescriptorProto + // 524 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 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 0x4f, 0xb8, 0xc0, 0xbd, + 0x3f, 0x55, 0x75, 0x4b, 0x25, 0xf8, 0xb2, 0x1e, 0xee, 0x29, 0xdd, 0xe9, 0x42, 0x0b, 0x4f, 0x17, + 0x5c, 0xe8, 0xf6, 0x7e, 0xde, 0x4c, 0xdf, 0x6c, 0x6f, 0xfa, 0x60, 0xb5, 0x21, 0xd6, 0xd5, 0x86, + 0x58, 0xd7, 0x1b, 0x02, 0x5e, 0x55, 0x04, 0xbc, 0xab, 0x08, 0xb8, 0xac, 0x08, 0x58, 0x55, 0x04, + 0x7c, 0xaa, 0x08, 0xf8, 0x5c, 0x11, 0xeb, 0xba, 0x22, 0xe0, 0xf5, 0x96, 0x58, 0xab, 0x2d, 0xb1, + 0xae, 0xb6, 0xc4, 0x7a, 0xba, 0xab, 0x1f, 0x5f, 0x1e, 0x86, 0x8e, 0xce, 0x70, 0xf7, 0x6b, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x77, 0x8c, 0xa0, 0x4e, 0xd3, 0x03, 0x00, 0x00, } func (this *RuleGroupDesc) Equal(that interface{}) bool { @@ -288,6 +297,9 @@ func (this *RuleGroupDesc) Equal(that interface{}) bool { return false } } + if this.Limit != that1.Limit { + return false + } return true } func (this *RuleDesc) Equal(that interface{}) bool { @@ -346,7 +358,7 @@ func (this *RuleGroupDesc) GoString() string { if this == nil { return "nil" } - s := make([]string, 0, 10) + s := make([]string, 0, 11) s = append(s, "&rulespb.RuleGroupDesc{") s = append(s, "Name: "+fmt.Sprintf("%#v", this.Name)+",\n") s = append(s, "Namespace: "+fmt.Sprintf("%#v", this.Namespace)+",\n") @@ -358,6 +370,7 @@ func (this *RuleGroupDesc) GoString() string { if this.Options != nil { s = append(s, "Options: "+fmt.Sprintf("%#v", this.Options)+",\n") } + s = append(s, "Limit: "+fmt.Sprintf("%#v", this.Limit)+",\n") s = append(s, "}") return strings.Join(s, "") } @@ -405,6 +418,11 @@ func (m *RuleGroupDesc) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.Limit != 0 { + i = encodeVarintRules(dAtA, i, uint64(m.Limit)) + i-- + dAtA[i] = 0x50 + } if len(m.Options) > 0 { for iNdEx := len(m.Options) - 1; iNdEx >= 0; iNdEx-- { { @@ -596,6 +614,9 @@ func (m *RuleGroupDesc) Size() (n int) { n += 1 + l + sovRules(uint64(l)) } } + if m.Limit != 0 { + n += 1 + sovRules(uint64(m.Limit)) + } return n } @@ -663,6 +684,7 @@ func (this *RuleGroupDesc) String() string { `Rules:` + repeatedStringForRules + `,`, `User:` + fmt.Sprintf("%v", this.User) + `,`, `Options:` + repeatedStringForOptions + `,`, + `Limit:` + fmt.Sprintf("%v", this.Limit) + `,`, `}`, }, "") return s @@ -917,6 +939,25 @@ func (m *RuleGroupDesc) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 10: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Limit", wireType) + } + m.Limit = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRules + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Limit |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipRules(dAtA[iNdEx:]) diff --git a/pkg/ruler/rulespb/rules.proto b/pkg/ruler/rulespb/rules.proto index cb48572f0dc..1a6f4182ec5 100644 --- a/pkg/ruler/rulespb/rules.proto +++ b/pkg/ruler/rulespb/rules.proto @@ -27,6 +27,7 @@ message RuleGroupDesc { // to create custom `ManagerOpts` based on rule configs which can then be passed // to the Prometheus Manager. repeated google.protobuf.Any options = 9; + int64 limit =10; } // RuleDesc is a proto representation of a Prometheus Rule diff --git a/pkg/ruler/store_mock_test.go b/pkg/ruler/store_mock_test.go index 965e072fab0..2f1ad78a3f7 100644 --- a/pkg/ruler/store_mock_test.go +++ b/pkg/ruler/store_mock_test.go @@ -110,6 +110,27 @@ var ( }, }, } + mockRulesLimit = map[string]rulespb.RuleGroupList{ + "user1": { + &rulespb.RuleGroupDesc{ + Name: "group1", + Namespace: "namespace1", + User: "user1", + Limit: 5, + Rules: []*rulespb.RuleDesc{ + { + Record: "UP_RULE", + Expr: "up", + }, + { + Alert: "UP_ALERT", + Expr: "up < 1", + }, + }, + Interval: interval, + }, + }, + } ) func newMockRuleStore(rules map[string]rulespb.RuleGroupList) *mockRuleStore {