Skip to content

Commit

Permalink
feat(config): set rule version record limit by default, bump grafana …
Browse files Browse the repository at this point in the history
…to 11.3.0 (#1763)

* feat(config): set unified_alerting.rule_version_record_limit = 5 by default

* chore(grafana): bump default version to 11.3.0

* chore(manager): regenerate manager.yaml

* chore(examples): reformat comments

* chore(e2e-tests): bump grafana version
  • Loading branch information
weisdd authored Nov 18, 2024
1 parent 1ac8d8d commit f12bbc4
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 24 deletions.
2 changes: 1 addition & 1 deletion config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ spec:
memory: 20Mi
env:
- name: RELATED_IMAGE_GRAFANA
value: "docker.io/grafana/grafana:10.4.3"
value: "docker.io/grafana/grafana:11.3.0"
- name: WATCH_NAMESPACE
valueFrom:
fieldRef:
Expand Down
8 changes: 8 additions & 0 deletions controllers/config/grafana_ini.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ func WriteIni(cfg map[string]map[string]string) (string, string) {
cfg["dashboards"]["versions_to_keep"] = "20"
}

if cfg["unified_alerting"] == nil {
cfg["unified_alerting"] = make(map[string]string)
}

if cfg["unified_alerting"]["rule_version_record_limit"] == "" {
cfg["unified_alerting"]["rule_version_record_limit"] = "5"
}

sections := make([]string, 0, len(cfg))
for key := range cfg {
sections = append(sections, key)
Expand Down
2 changes: 1 addition & 1 deletion controllers/config/operator_constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package config
const (
// Grafana
GrafanaImage = "docker.io/grafana/grafana"
GrafanaVersion = "10.4.3"
GrafanaVersion = "11.3.0"

// Paths
GrafanaDataPath = "/var/lib/grafana"
Expand Down
43 changes: 26 additions & 17 deletions examples/alertrulegroups/resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ spec:
security:
admin_user: root
admin_password: secret

## Starting from Grafana 11.3.0, it is possible to enforce
## a limit on how many alert rule versions should be stored
## in a database (including the current version of the rule).
## The default value in Grafana is "0", which means no limit.
## To mitigate that behaviour, the operator sets it to 5
## by default starting from v5.16.0
# unified_alerting:
# rule_version_record_limit: "5"
---
apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaFolder
Expand All @@ -40,8 +49,8 @@ spec:
- datasourceUid: grafanacloud-demoinfra-prom
model:
datasource:
type: prometheus
uid: grafanacloud-demoinfra-prom
type: prometheus
uid: grafanacloud-demoinfra-prom
editorMode: code
expr: weather_temp_c{}
instant: true
Expand All @@ -56,22 +65,22 @@ spec:
- datasourceUid: __expr__
model:
conditions:
- evaluator:
params:
- 0
type: lt
operator:
type: and
query:
params:
- C
reducer:
params: []
type: last
type: query
- evaluator:
params:
- 0
type: lt
operator:
type: and
query:
params:
- C
reducer:
params: []
type: last
type: query
datasource:
type: __expr__
uid: __expr__
type: __expr__
uid: __expr__
expression: A
intervalMs: 1000
maxDataPoints: 43200
Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/example-test/00-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ kind: Grafana
metadata:
name: grafana
spec:
version: 10.4.3
version: 11.3.0
status:
(wildcard('http://grafana-service.*:3000', adminUrl || '')): true
stage: complete
stageStatus: success
version: 10.4.3
version: 11.3.0
---
apiVersion: grafana.integreatly.org/v1beta1
kind: Grafana
Expand All @@ -18,7 +18,7 @@ status:
adminUrl: (join('',['http://grafana-internal-service.',$namespace,':3000']))
stage: complete
stageStatus: success
version: 10.4.3
version: 11.3.0
---
apiVersion: grafana.integreatly.org/v1beta1
kind: Grafana
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/example-test/11-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ kind: Grafana
metadata:
name: grafana-tls
spec:
version: 10.4.3
version: 11.3.0
status:
(wildcard('https://grafana-tls-service.*:3000', adminUrl || '')): true
stage: complete
stageStatus: success
version: 10.4.3
version: 11.3.0

0 comments on commit f12bbc4

Please sign in to comment.