File tree Expand file tree Collapse file tree 8 files changed +56
-0
lines changed
prometheus-postgresql-alerts Expand file tree Collapse file tree 8 files changed +56
-0
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,7 @@ Render Prometheus rule
71
71
{ {- $name := .name -} }
72
72
{ {- $pintComments := default dict .pintComments -} }
73
73
{ {- $for := .for -} }
74
+ { {- $keepFiringFor := default .defaultKeepFiringFor .keepFiringFor -} }
74
75
{ {- $ruleLabels := .labels -} }
75
76
{ {- $record := .record -} }
76
77
{ {- $annotations := default dict .annotations -} }
@@ -112,6 +113,9 @@ Render Prometheus rule
112
113
{ {- if $for } }
113
114
for: { { $for } }
114
115
{ {- end } }
116
+ { {- if $keepFiringFor } }
117
+ keep_firing_for: { { $keepFiringFor } }
118
+ { {- end } }
115
119
{ {- if $labels } }
116
120
labels:
117
121
{ { $labels | toYaml | indent 4 } }
Original file line number Diff line number Diff line change 7
7
{{- $_ := set . "globalAdditionalExprLabels" $.Values.global.additionalExprLabels }}
8
8
{{- $_ := set . "globalAdditionalRuleLabels" $.Values.global.additionalRuleLabels }}
9
9
{{- $_ := set . "defaultRunbookUrl" $.Values.defaultRunbookUrl }}
10
+ {{- $_ := set . "defaultKeepFiringFor" $.Values.defaultKeepFiringFor }}
10
11
{{- $_ := set . "chartVersion" $.Chart.Version }}
11
12
12
13
{{- include "chart.renderPrometheusRule" . | indent 8 -}}
Original file line number Diff line number Diff line change 19
19
{{- $_ := set . "globalAdditionalExprLabels" $.Values.global.additionalExprLabels }}
20
20
{{- $_ := set . "globalAdditionalRuleLabels" $.Values.global.additionalRuleLabels }}
21
21
{{- $_ := set . "defaultRunbookUrl" $.Values.defaultRunbookUrl }}
22
+ {{- $_ := set . "defaultKeepFiringFor" $.Values.defaultKeepFiringFor }}
22
23
{{- $_ := set . "chartVersion" $.Chart.Version }}
23
24
24
25
{{- include "chart.renderPrometheusRule" . | indent 8 -}}
Original file line number Diff line number Diff line change @@ -109,3 +109,23 @@ tests:
109
109
- equal :
110
110
path : metadata.labels.prometheus
111
111
value : main
112
+ - it : render with additional additionalPrometheusRuleLabels
113
+ templates :
114
+ - prometheusRules.yaml
115
+ values :
116
+ - ./values/with_keepFiringFor.yaml
117
+ asserts :
118
+ - equal :
119
+ path : spec.groups[0].rules[0].expr
120
+ value : |
121
+ metric2{} > 100
122
+ - equal :
123
+ path : spec.groups[0].rules[0].keep_firing_for
124
+ value : 2s
125
+ - equal :
126
+ path : spec.groups[0].rules[1].expr
127
+ value : |
128
+ metric1{} > 42
129
+ - equal :
130
+ path : spec.groups[0].rules[1].keep_firing_for
131
+ value : 1s
Original file line number Diff line number Diff line change
1
+ defaultKeepFiringFor : 1s
2
+
3
+ rulesGroupName : unittest
4
+
5
+ rules :
6
+
7
+ RuleWithDefaultKeepFiringFor :
8
+ expr : metric1{} > 42
9
+ for : 10m
10
+ labels :
11
+ priority : P1
12
+ annotations :
13
+ summary : " Metric 1 is over 42"
14
+ description : " Metric1 is {{ $value }}"
15
+
16
+ RuleWithCustomKeepFiringFor :
17
+ expr : metric2{} > 100
18
+ for : 10m
19
+ keepFiringFor : 2s
20
+ labels :
21
+ priority : P1
22
+ annotations :
23
+ summary : " Metric 1 is over 100"
24
+ description : " Metric2 is {{ $value }}"
Original file line number Diff line number Diff line change 2
2
additionalExprLabels : []
3
3
additionalRuleLabels : {}
4
4
5
+ defaultKeepFiringFor : " "
6
+
5
7
format : PrometheusRuleCRD
6
8
7
9
rulesGroupName : default
Original file line number Diff line number Diff line change 3
3
4
4
format : PrometheusRuleCRD
5
5
6
+ defaultKeepFiringFor : " "
6
7
defaultRunbookUrl : https://qonto.github.io/database-monitoring-framework/{{chartVersion}}/runbooks/postgresql/{{alertName}}
8
+
7
9
rulesGroupName : postgresql.rules
8
10
9
11
rules :
Original file line number Diff line number Diff line change 3
3
4
4
format : PrometheusRuleCRD
5
5
6
+ defaultKeepFiringFor : " "
6
7
defaultRunbookUrl : https://qonto.github.io/database-monitoring-framework/{{chartVersion}}/runbooks/rds/{{alertName}}
8
+
7
9
rulesGroupName : rds.rules
8
10
9
11
additionalPrometheusRuleLabels : {}
You can’t perform that action at this time.
0 commit comments