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 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