Skip to content

Commit 43cde6d

Browse files
Merge pull request #3891 from waterdrag0n/enable_tpl_processing_alert_files
[grafana] Enable helm tpl for alert files
2 parents d73a322 + 38c977b commit 43cde6d

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

charts/grafana/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
apiVersion: v2
22
name: grafana
3-
version: 9.4.5
3+
version: 10.0.0
44
appVersion: 12.1.1
55
kubeVersion: "^1.8.0-0"
66
description: The leading tool for querying and visualizing time series and metrics.

charts/grafana/README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@ to `global.imageRegistry`. If you were not previously setting `global.image.regi
5353
is required on upgrade. If you were previously setting `global.image.registry`, you will
5454
need to instead set `global.imageRegistry`.
5555

56+
### To 10.0.0
57+
58+
Static alerting resources now support Helm templating. This means that alerting resources loaded from external files (`alerting.*.files`) are now processed by the Helm template engine.
59+
60+
If you already use template expressions intended for Alertmanager (for example, `{{ $labels.instance }}`), these must now be escaped to avoid unintended Helm evaluation. To escape them, wrap the braces with an extra layer like this:
61+
62+
`{{ "{{" }} $labels.instance {{ "}}" }}`
63+
64+
This ensures the expressions are preserved for Alertmanager instead of being rendered by Helm.
65+
5666
## Configuration
5767

5868
| Parameter | Description | Default |
@@ -681,7 +691,7 @@ The two possibilities for static alerting resource provisioning are:
681691
* The format of the files is defined in the [Grafana documentation](https://grafana.com/docs/grafana/next/alerting/set-up/provision-alerting-resources/file-provisioning/) on file provisioning.
682692
* The chart supports importing YAML and JSON files.
683693
* The filename must be unique, otherwise one volume mount will overwrite the other.
684-
* In case of inlining, double curly braces that arise from the Grafana configuration format and are not intended as templates for the chart must be escaped.
694+
* Alerting configurations support Helm templating. Double curly braces that arise from the Grafana configuration format and are not intended as templates for the chart must be escaped.
685695
* The number of total files under `alerting:` is not limited. Each file will end up as a volume mount in the corresponding provisioning folder of the deployed Grafana instance.
686696
* The file size for each import is limited by what the function `.Files.Get` can handle, which suffices for most cases.
687697

charts/grafana/templates/_config.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ grafana.ini: |
5555

5656
{{- range $key, $value := .Values.alerting }}
5757
{{- if (hasKey $value "file") }}
58-
{{ $key }}:
59-
{{- toYaml ( $files.Get $value.file ) | nindent 2 }}
58+
{{ $key }}: |
59+
{{- tpl ($files.Get $value.file) $root | nindent 2 }}
6060
{{- else if (or (hasKey $value "secret") (hasKey $value "secretFile"))}}
6161
{{/* will be stored inside secret generated by "configSecret.yaml"*/}}
6262
{{- else }}

0 commit comments

Comments
 (0)