Open tringuyen-yw opened 3 years ago
I had the same issue. In my values.yaml I added
sidecar:
dashboards:
label: grafana_dashboard
folderAnnotation: grafana_folder
provider:
foldersFromFilesStructure: true
Then i can add
apiVersion: v1
kind: ConfigMap
metadata:
name: blackbox-dashboard
namespace: monitoring
labels:
grafana_dashboard: "1"
annotations:
grafana_folder: "common"
@joeyenfield-verint That's cool thanks. Just to clarify.
Q1. is grafana_folder: "common"
the name of the dashboard folder in the Grafana UI?
Q2. For the dashboards in common
folder, What is the physical path where the *.json
files are stored?
Q3. Can you confirm you don't define any dashboardProviders
value for the Grafana helm value?
@joeyenfield-verint fantastic your solution works perfectly. Answering my own question hopefully to help future readers
Q1. is
grafana_folder: "WhateverNameYouWant"
the name of the dashboard folder in the Grafana UI? Q2. For the dashboards incommon
folder, What is the physical path where the*.json
files are stored?
Yes, the grafana-sc-dashboard
sidecar container will process the ConfigMap. It will store all the dashboards defined in the ConfigMap in a Grafana dashboard folder named in the value of the grafana_folder
label key. There is no need to create that folder in advance. The Grafana helm values bebome much simpler! In the example below, the sidecar will create a subdir named WhateverNameYouWant
(configured in ConfigMap) within the dashboard dir /tmp/dashboards
(configured in sidecar.dashboards.folder). The
*.json` of the dashboards defined in the ConfigMap are stored in this subdir.
In the Grafana UI, the dashboards in /tmp/dashboards/WhateverNameYouWant
are provisioned in the dashboard folder named WhateverNameYouWant
(instead of the General
dashboard folder).
sidecar:
dashboards:
enabled: true
label: grafana_dashboard
folder: /tmp/dashboards
folderAnnotation: grafana_folder
provider:
allowUiUpdates: true
foldersFromFilesStructure: true
Q3. Can you confirm you don't define any
dashboardProviders
value for the Grafana helm value?
Confirmed. There is no need. the Grafan helm values I use above doesn't have dashboardProviders
. For completeness, here is my updated ConfigMap which just mirror the solution you suggested. The important point is the annotation k8s-sidecar-target-directory
is replaced by grafana_folder
label.
apiVersion: v1
kind: ConfigMap
metadata:
name: cm-strimzi-dashboards
labels:
app: strimzi
grafana_dashboard: "1"
annotations:
grafana_folder: "WhateverNameYouWant"
data:
dashboard1.json: |-
{
json code of the Grafana dashboard
}
dashboard2.json: |-
{
json code
}
Overall the comments in grafana/values.yaml are confusing (or outdated). So far I am unclear as why there are two different ways to provision dashboard in custom folders. One of those (using dashboardProviders
and k8s-sidecar-target-directory
annotation) is clearly buggy.
And for completeness, make helm (parent / umbrella chart for grafana) iterate and create a configmap per dashboard...
{{ if .Values.dashboardsConfigmap.enable }}
{{ $root := . }}
{{- range $path, $_ := .Files.Glob "dashboards/cluster-monitoring/**.json" }}
---
apiVersion: v1
kind: ConfigMap
metadata:
labels:
grafana_dashboard: "1"
annotations:
grafana_folder: "Cluster"
name: {{ base $path }}
data:
{{ base $path }}:
{{ $root.Files.Get $path | toJson | indent 4 }}
{{ end }}
{{ end }}
and the indentation for "providers" is under sidecar.dashboard:
sidecar:
dashboards:
...
provider:
I have a similar problem but in my case the dashboards are created in their corresponding folders, and everytime I make a change in the json files/configmap and re-deploy my changes are applied correctly, but the dashboards are moved to the "General" folder until I manually restart the pod.
Anyone knows how to make changes to the provisioned dashboards WITHOUT restarting the Grafana pod every time?
Using Grafana helm chart version 6.13.2, which is an upstream dependency from kube-prometheus-stack.
I would like to import some dashboards created in a configmap (created in the same namespace as the
kube-prometheus-stack
Customize
my-helm-values.yaml
. Please note: here the helm values is written for Grafana helm chart. Forkube-prometheus-stack
helm chart, I have to nest the content under the root elementgrafana:
Then deploy by
What happenned?
*.json
files are correctly saved in/tmp/dashboards/strimzi
. Thestrimzi-provider.yaml
correctly created in/etc/grafana/provisioning/dashboards
.KAFKA
is created but has zero dashboards.KAFKA
folder are visible in theGeneral
folder.What is the expected results
Would prefer the custom dashboards specified in the configmap to be created in the custom dashboard folder as specified in the
dashboardProviders.providers
helm value.