Reputation: 112
I am able to install and import Grafana dashboards in an Azure Kubernetes Service using Pulumi through a HelmRelease Custom Resource Definition of the kube-prometheus-stack
.
I was able to do some ConfigMaps
to import dashboards that I previously stored as JSON files.
What I am now trying to do is to put those imported dashboards inside custom folders in Grafana.
How can I create such folders (first problem) and how do I state the folder for each dashboard I am importing?
Example of the way I import a dashboard (actually landing in the root folder in Grafana):
const myDashboard = fs.readFileSync(
'dashboards/myDashboard.json',
'utf-8'
);
new k8s.core.v1.ConfigMap(
'my-dashboard-cm',
{
metadata: {
name: 'my-dashboard',
namespace: args.namespace,
labels: { grafana_dashboard: '1' },
},
data: { 'my-dashboard.json': JSON.stringify(JSON.parse(myDashboard)) },
},
{ parent: this }
);
Thank you for any help!
Upvotes: 0
Views: 748
Reputation: 511
You can set the directory of your dashboard by setting the folder annotation called k8s-sidecar-target-directory
.
It should look like below on a Pulumi object.
new k8s.core.v1.ConfigMap(
'my-dashboard-cm',
{
metadata: {
name: 'my-dashboard',
namespace: args.namespace,
labels: { grafana_dashboard: '1' },
annotations : { "k8s-sidecar-target-directory" : "/tmp/dashboards/yourfolder" }
},
data: { 'my-dashboard.json': JSON.stringify(JSON.parse(myDashboard)) },
},
{ parent: this }
);
You might want to set sidecar.dashboards.provider.foldersFromFilesStructure:true
on your main chart values so you'd have the same folder name in Grafana menu.
Upvotes: 1