@@ -249,6 +249,7 @@ type Group struct {
249
249
interval time.Duration
250
250
evaluationDelay * time.Duration
251
251
limit int
252
+ alertLimit int
252
253
rules []Rule
253
254
sourceTenants []string
254
255
seriesInPreviousEval []map [string ]labels.Labels // One per Rule.
@@ -280,6 +281,7 @@ type GroupOptions struct {
280
281
Name , File string
281
282
Interval time.Duration
282
283
Limit int
284
+ AlertLimit int
283
285
Rules []Rule
284
286
SourceTenants []string
285
287
ShouldRestore bool
@@ -313,6 +315,7 @@ func NewGroup(o GroupOptions) *Group {
313
315
interval : o .Interval ,
314
316
evaluationDelay : o .EvaluationDelay ,
315
317
limit : o .Limit ,
318
+ alertLimit : o .AlertLimit ,
316
319
rules : o .Rules ,
317
320
shouldRestore : o .ShouldRestore ,
318
321
opts : o .Opts ,
@@ -348,6 +351,9 @@ func (g *Group) Interval() time.Duration { return g.interval }
348
351
// Limit returns the group's limit.
349
352
func (g * Group ) Limit () int { return g .limit }
350
353
354
+ // AlertLimit returns the group's alert limit.
355
+ func (g * Group ) AlertLimit () int { return g .alertLimit }
356
+
351
357
// SourceTenants returns the source tenants for the group.
352
358
// If it's empty or nil, then the owning user/tenant is considered to be the source tenant.
353
359
func (g * Group ) SourceTenants () []string { return g .sourceTenants }
@@ -637,7 +643,13 @@ func (g *Group) Eval(ctx context.Context, ts time.Time) {
637
643
638
644
g .metrics .EvalTotal .WithLabelValues (GroupKey (g .File (), g .Name ())).Inc ()
639
645
640
- vector , err := rule .Eval (ctx , evaluationDelay , ts , g .opts .QueryFunc , g .opts .ExternalURL , g .Limit ())
646
+ limit := g .Limit ()
647
+ if _ , ok := rule .(* AlertingRule ); ok {
648
+ if g .AlertLimit () > 0 {
649
+ limit = g .AlertLimit ()
650
+ }
651
+ }
652
+ vector , err := rule .Eval (ctx , evaluationDelay , ts , g .opts .QueryFunc , g .opts .ExternalURL , limit )
641
653
if err != nil {
642
654
rule .SetHealth (HealthBad )
643
655
rule .SetLastError (err )
@@ -894,6 +906,10 @@ func (g *Group) Equals(ng *Group) bool {
894
906
return false
895
907
}
896
908
909
+ if g .alertLimit != ng .alertLimit {
910
+ return false
911
+ }
912
+
897
913
if len (g .rules ) != len (ng .rules ) {
898
914
return false
899
915
}
@@ -1170,6 +1186,7 @@ func (m *Manager) LoadGroups(
1170
1186
File : fn ,
1171
1187
Interval : itv ,
1172
1188
Limit : rg .Limit ,
1189
+ AlertLimit : rg .AlertLimit ,
1173
1190
Rules : rules ,
1174
1191
SourceTenants : rg .SourceTenants ,
1175
1192
ShouldRestore : shouldRestore ,
0 commit comments