I am deploying the helm chart stable/grafana 4.3.0 onto a k8s cluster. I am using Helm 3. From a previous grafana installation, I have exported the json of a dashboard and saved it as my-dashboard.json. I want to have helm take care of uploading this file, so in my values.yaml I have
dashboardProviders:
dashboardproviders.yaml:
apiVersion: 1
providers:
- name: 'default'
orgId: 1
folder: ''
type: file
disableDeletion: false
editable: true
options:
path: /var/lib/grafana/dashboards
dashboards:
default:
my-dashboard:
file: my-dashboard.json
prometheus-stats:
gnetId: 2
revision: 2
datasource: Prometheus
I already have my Prometheus datasource (from the prometheus helm chart) defined as
datasources:
datasources.yaml:
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
url: http://my-prometheus-release-server.default.svc.cluster.local
access: proxy
isDefault: true
And I've verified that the datasource works correctly.
If I run helm upgrade my-grafana-release stable/grafana --values values.yaml
however, in the logs on the pod it repeats:
t=2020-01-17T21:33:35+0000 lvl=eror msg="failed to load dashboard from " logger=provisioning.dashboard type=file name=default file=/var/lib/grafana/dashboards/default/my-dashboard.json error=EOF
Seeing EOF
makes me think the file isn't uploading. I have my-dashboard.json saved in the same folder as values.yaml, and I'm running the helm command from that folder. Do I need to store it somewhere else? I have searched all the documentation and it's not clear to me how it gets uploaded.
Where did you put the my-dashboard.json
file ? It should be on the same level as values.yaml
Also check the grafana-dashboards-default
configmap, it should contain the dashboard.
I found another way to handle this.
I am using Terraform to accomplish this, and I made values.yaml as a template file. This is the relevant section in values.yaml now:
dashboards:
default:
dashbaord1:
json: |
${my-dashboard-1}
dashboard2:
json: |
${my-dashboard-2}
And the templatefile block looks like this:
resource "helm_release" "grafana" {
name = "grafana-release"
repository = data.helm_repository.stable.metadata[0].name
chart = "grafana"
version = "4.3.0"
values = [
"${templatefile(
"${path.module}/values.yaml.tpl",
{
my-dashboard-1 = "${indent(8, data.template_file.my-dashboard-1.rendered)}}",
my-dashboard-2 = "${indent(8, data.template_file.my-dashboard-2.rendered)}}"
}
)}"
]
}
The indent
is very important!