I have a helm chart that deploys a kube-prometheus stack (prometheus, grafana, node-exporter), there are some json files (dashboards) in the grafana configuration, they are transferred to the grafana pod via configMap (common practice). I have a task to optimize this configuration to add grafana dashboards via their id from grafana.com and not to use json files (as they are very big). I know how to create a folder in grafana and specify the prometheus resource, but I don't understand how to export dashboards by id.
To create a folder I have a file (yaml) which is added via configmap to the directory /etc/grafana/provisioning/dashboards
- name: 'default'
org_id: 1
folder: 'my-dashboards'
type: 'file'
options:
folder: '/var/lib/grafana/dashboards'
How to do it and in which file I need to insert this configuration to make it work. I will be grateful for help.
I tried to create configurations I found on github (dashboardProviders), but it only creates a folder (the code I specified), without dashboards
UPD: what i have now
apiVersion: 1
providers:
# <string> an unique provider name. Required
- name: 'prometheus'
# <int> Org id. Default to 1
orgId: 1
# <string> name of the dashboard folder.
folder: 'my-dashboards'
# <string> folder UID. will be automatically generated if not specified
folderUid: ''
# <string> provider type. Default to 'file'
type: file
# <bool> disable dashboard deletion
disableDeletion: false
# <int> how often Grafana will scan for changed dashboards
updateIntervalSeconds: 10
# <bool> allow updating provisioned dashboards from the UI
allowUiUpdates: false
options:
# <string, required> path to dashboard files on disk. Required when using the 'file' type
path: /var/lib/grafana/dashboards
# <bool> use folder names from filesystem to create folders in Grafana
foldersFromFilesStructure: true
dashboards:
default:
MinIO:
gnetId: 13502
revision: 2
datasource: prometheus
but it still doesn't work...why?
It is (or can be) a part of the grafana helm chart, from what I remember when used it in the past. That configuration needs to go into the values.yaml
when using that helm chart.
Specifically here to enable/configure dashboardProviders
and here to provision the dashboard
using dashboard id
from the grafana website.
Can also refer to some documentation here.
Hope it helps.
Update:
Using the below config I was able to import the MinIO Dashboard (the one OP tried to import):
dashboardProviders:
dashboardproviders.yaml:
apiVersion: 1
providers:
- name: 'default'
orgId: 1
folder: 'default'
type: file
disableDeletion: true
editable: true
options:
path: /var/lib/grafana/dashboards/standard
dashboards:
default:
MinIO:
gnetId: 13502
revision: 2
datasource: prometheus
Ofcourse I don't have the prometheus data source, hence the warning sign(s).