In the documentation for Import dashboards it gives this example for importing a file from local filesystem (near the values.yaml file, I would assume).
dashboards:
default:
custom-dashboard:
# This is a path to a file inside the dashboards directory inside the chart directory
file: dashboards/custom-dashboard.json
When trying this myself with helm2 and helm3, it results in a ConfigMap with empty values.
Below are the steps I took when trying to use this feature of the helmchart.
dashboards:
default:
Prometheus:
datasource: default
gnetId: 2
revision: 2
empty-dashboard:
file: dashboards/empty-dashboard.json
prometheus-alerts-firing:
file: dashboards/prometheus-alerts-firing.json
empty-dashboard.json is just {}
which is a copy of the example "dashboards/custom-dashboard.json" already in this git repository.
$ wc -c values.yaml dashboards/empty-dashboard.json dashboards/prometheus-alerts-firing.json
6852 values.yaml
3 dashboards/empty-dashboard.json
24251 dashboards/prometheus-alerts-firing.json
Launching helm install --dry-run grafana grafana/grafana -f values.yaml --debug
shows the ConfigMap that would be sent to the cluster would have empty values for the dashboards, instead of the file contents.
---
# Source: grafana/templates/dashboards-json-configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: grafana-dashboards-default
namespace: default
labels:
helm.sh/chart: grafana-5.6.7
app.kubernetes.io/name: grafana
app.kubernetes.io/instance: grafana
app.kubernetes.io/version: "7.1.5"
app.kubernetes.io/managed-by: Helm
dashboard-provider: default
data:
empty-dashboard.json:
""
prometheus-alerts-firing.json:
""
If I install this without the --dry-run
the ConfigMap I find is indeed empty, and grafana complains about being unable to load these dashboards.
Bizarrely, if I add custom-dashboard: {file: dashboards/custom-dashboard.json}
exactly as it appears in the example documentation, this results in a non-empty ConfigMap, even though there is no such file "dashboards/custom-dashboard.json" on my local filesystem.
Maybe the {{.Files.Get "filename"}}
in the template cannot access files outside of the helmchart package itself?