From 2ec3622ccb0fa1ebd70ab8f1d3ef0176c89a0a39 Mon Sep 17 00:00:00 2001 From: Werner van der Merwe Date: Tue, 8 Jul 2025 11:24:11 +0000 Subject: [PATCH 1/2] Extend template to specify directories where .json dashboard files should be added as configmaps Signed-off-by: Werner van der Merwe --- charts/grafana/templates/dashboards-json-configmap.yaml | 8 ++++++++ charts/grafana/values.yaml | 2 ++ 2 files changed, 10 insertions(+) diff --git a/charts/grafana/templates/dashboards-json-configmap.yaml b/charts/grafana/templates/dashboards-json-configmap.yaml index df0ed0d8c5..7218d80fa0 100644 --- a/charts/grafana/templates/dashboards-json-configmap.yaml +++ b/charts/grafana/templates/dashboards-json-configmap.yaml @@ -24,6 +24,14 @@ data: {{- toYaml ( $files.Get $value.file ) | nindent 4}} {{- end }} {{- end }} + {{- if hasKey $value "directory" }} + {{- $globPath := printf "%s/*.json" (trimSuffix "/" $value.directory) }} + {{- range $path, $fileContents := $files.Glob $globPath }} + {{- $dashboardFound = true }} + {{base $path}}: + {{- toYaml ($files.Get $path ) | nindent 4 }} + {{- end }} + {{- end }} {{- end }} {{- if not $dashboardFound }} {} diff --git a/charts/grafana/values.yaml b/charts/grafana/values.yaml index 196fbeb2e3..bf41d398ac 100644 --- a/charts/grafana/values.yaml +++ b/charts/grafana/values.yaml @@ -835,6 +835,8 @@ dashboards: {} # $RAW_JSON # custom-dashboard: # file: dashboards/custom-dashboard.json + # dashboard-directory: + # directory: dashboards/ # prometheus-stats: # gnetId: 2 # revision: 2 From 3947c37b4c1cea7a3989a1284657294059b6bb2a Mon Sep 17 00:00:00 2001 From: Werner van der Merwe Date: Tue, 8 Jul 2025 12:02:05 +0000 Subject: [PATCH 2/2] Add notes to README.md on directory method Signed-off-by: Werner van der Merwe --- charts/grafana/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/charts/grafana/README.md b/charts/grafana/README.md index 444b87a74c..b033bee3fb 100644 --- a/charts/grafana/README.md +++ b/charts/grafana/README.md @@ -383,6 +383,9 @@ dashboards: custom-dashboard: # This is a path to a file inside the dashboards directory inside the chart directory file: dashboards/custom-dashboard.json + more-dashboards: + # This imports all dashboard .json files in a directory + directory: dashboards/ prometheus-stats: # Ref: https://grafana.com/dashboards/2 gnetId: 2