@@ -246,6 +246,7 @@ type Group struct {
246
246
interval time.Duration
247
247
evaluationDelay * time.Duration
248
248
limit int
249
+ alertLimit int
249
250
rules []Rule
250
251
sourceTenants []string
251
252
seriesInPreviousEval []map [string ]labels.Labels // One per Rule.
@@ -277,6 +278,7 @@ type GroupOptions struct {
277
278
Name , File string
278
279
Interval time.Duration
279
280
Limit int
281
+ AlertLimit int
280
282
Rules []Rule
281
283
SourceTenants []string
282
284
ShouldRestore bool
@@ -310,6 +312,7 @@ func NewGroup(o GroupOptions) *Group {
310
312
interval : o .Interval ,
311
313
evaluationDelay : o .EvaluationDelay ,
312
314
limit : o .Limit ,
315
+ alertLimit : o .AlertLimit ,
313
316
rules : o .Rules ,
314
317
shouldRestore : o .ShouldRestore ,
315
318
opts : o .Opts ,
@@ -345,6 +348,9 @@ func (g *Group) Interval() time.Duration { return g.interval }
345
348
// Limit returns the group's limit.
346
349
func (g * Group ) Limit () int { return g .limit }
347
350
351
+ // AlertLimit returns the group's alert limit.
352
+ func (g * Group ) AlertLimit () int { return g .alertLimit }
353
+
348
354
// SourceTenants returns the source tenants for the group.
349
355
// If it's empty or nil, then the owning user/tenant is considered to be the source tenant.
350
356
func (g * Group ) SourceTenants () []string { return g .sourceTenants }
@@ -634,7 +640,13 @@ func (g *Group) Eval(ctx context.Context, ts time.Time) {
634
640
635
641
g .metrics .EvalTotal .WithLabelValues (GroupKey (g .File (), g .Name ())).Inc ()
636
642
637
- vector , err := rule .Eval (ctx , evaluationDelay , ts , g .opts .QueryFunc , g .opts .ExternalURL , g .Limit ())
643
+ limit := g .Limit ()
644
+ if _ , ok := rule .(* AlertingRule ); ok {
645
+ if g .AlertLimit () > 0 {
646
+ limit = g .AlertLimit ()
647
+ }
648
+ }
649
+ vector , err := rule .Eval (ctx , evaluationDelay , ts , g .opts .QueryFunc , g .opts .ExternalURL , limit )
638
650
if err != nil {
639
651
rule .SetHealth (HealthBad )
640
652
rule .SetLastError (err )
@@ -891,6 +903,10 @@ func (g *Group) Equals(ng *Group) bool {
891
903
return false
892
904
}
893
905
906
+ if g .alertLimit != ng .alertLimit {
907
+ return false
908
+ }
909
+
894
910
if len (g .rules ) != len (ng .rules ) {
895
911
return false
896
912
}
@@ -1163,6 +1179,7 @@ func (m *Manager) LoadGroups(
1163
1179
File : fn ,
1164
1180
Interval : itv ,
1165
1181
Limit : rg .Limit ,
1182
+ AlertLimit : rg .AlertLimit ,
1166
1183
Rules : rules ,
1167
1184
SourceTenants : rg .SourceTenants ,
1168
1185
ShouldRestore : shouldRestore ,
0 commit comments