Skip to content

Commit 2a32c4f

Browse files
authored
feat: add keepFiringFor to alert rule group (#2117)
1 parent e99f622 commit 2a32c4f

File tree

7 files changed

+35
-0
lines changed

7 files changed

+35
-0
lines changed

api/v1beta1/grafanaalertrulegroup_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ type AlertRule struct {
8989
// The number of missing series evaluations that must occur before the rule is considered to be resolved.
9090
MissingSeriesEvalsToResolve *int64 `json:"missingSeriesEvalsToResolve,omitempty"`
9191

92+
// +kubebuilder:validation:Type=string
93+
// +kubebuilder:validation:Format=duration
94+
// +kubebuilder:validation:Pattern="^([0-9]+(\\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$"
95+
KeepFiringFor *metav1.Duration `json:"keepFiringFor,omitempty"`
96+
9297
Record *Record `json:"record,omitempty"`
9398

9499
// +kubebuilder:validation:MinLength=1

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/grafana.integreatly.org_grafanaalertrulegroups.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ spec:
199199
type: string
200200
isPaused:
201201
type: boolean
202+
keepFiringFor:
203+
format: duration
204+
pattern: ^([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$
205+
type: string
202206
labels:
203207
additionalProperties:
204208
type: string

controllers/alertrulegroup_controller.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ func crToModel(cr *grafanav1beta1.GrafanaAlertRuleGroup, folderUID string) model
199199
}
200200
}
201201

202+
if r.KeepFiringFor != nil {
203+
apiRule.KeepFiringFor = (strfmt.Duration)(r.KeepFiringFor.Duration)
204+
}
205+
202206
mRules = append(mRules, apiRule)
203207
}
204208

deploy/helm/grafana-operator/crds/grafana.integreatly.org_grafanaalertrulegroups.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ spec:
199199
type: string
200200
isPaused:
201201
type: boolean
202+
keepFiringFor:
203+
format: duration
204+
pattern: ^([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$
205+
type: string
202206
labels:
203207
additionalProperties:
204208
type: string

deploy/kustomize/base/crds.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,10 @@ spec:
198198
type: string
199199
isPaused:
200200
type: boolean
201+
keepFiringFor:
202+
format: duration
203+
pattern: ^([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$
204+
type: string
201205
labels:
202206
additionalProperties:
203207
type: string

docs/docs/api.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,15 @@ AlertRule defines a specific rule to be evaluated. It is based on the upstream m
365365
<br/>
366366
</td>
367367
<td>false</td>
368+
</tr><tr>
369+
<td><b>keepFiringFor</b></td>
370+
<td>string</td>
371+
<td>
372+
<br/>
373+
<br/>
374+
<i>Format</i>: duration<br/>
375+
</td>
376+
<td>false</td>
368377
</tr><tr>
369378
<td><b>labels</b></td>
370379
<td>map[string]string</td>

0 commit comments

Comments
 (0)