From c1b1dc1a29031001759633f699998ffc143f3927 Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Sun, 2 May 2021 17:49:40 +0200 Subject: [PATCH] bundles/grafana: add support for custom managed dashboards --- bundles/grafana/items.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/bundles/grafana/items.py b/bundles/grafana/items.py index 9031f85..6b2afed 100644 --- a/bundles/grafana/items.py +++ b/bundles/grafana/items.py @@ -1,5 +1,6 @@ from itertools import count -from os.path import join +from os import listdir +from os.path import isdir, isfile, join from pathlib import Path from uuid import UUID @@ -113,3 +114,17 @@ for rnode in repo.nodes: 'svc_systemd:grafana-server:restart', }, } + + +additional_path = join(repo.path, 'data', 'grafana', 'files', node.name, 'dashboards') +if isdir(additional_path): + for file in listdir(additional_path): + if not isfile(join(additional_path, file)) or file.startswith('.') or file.startswith('_'): + continue + + files[f'/var/lib/grafana/dashboards/{file}'] = { + 'source': join(node.name, 'dashboards', file), + 'triggers': { + 'svc_systemd:grafana-server:restart', + }, + }