From 4dbfb3b6ab1155fb2201b1a7289b10c2bbb40429 Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 1 Jun 2023 00:12:31 +0200 Subject: [PATCH] cluster/services/monitoring: provision dashboards --- cluster/services/monitoring/default.nix | 1 + .../monitoring/provisioning/dashboards.nix | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 cluster/services/monitoring/provisioning/dashboards.nix diff --git a/cluster/services/monitoring/default.nix b/cluster/services/monitoring/default.nix index 56cc0ed..ae74c6e 100644 --- a/cluster/services/monitoring/default.nix +++ b/cluster/services/monitoring/default.nix @@ -35,6 +35,7 @@ in server = [ ./server.nix ./tracing.nix + ./provisioning/dashboards.nix ]; }; }; diff --git a/cluster/services/monitoring/provisioning/dashboards.nix b/cluster/services/monitoring/provisioning/dashboards.nix new file mode 100644 index 0000000..277a345 --- /dev/null +++ b/cluster/services/monitoring/provisioning/dashboards.nix @@ -0,0 +1,24 @@ +{ lib, pkgs, ... }: + +let + loadDashboard = file: lib.pipe file [ + lib.importJSON + ({ dashboard, ... }: rec { + name = "provision-dashboard-${dashboard.uid}.json"; + path = builtins.toFile name (builtins.toJSON dashboard); + }) + ]; + + dashboardsDir = pkgs.linkFarm + "grafana-provisioning-dashboards" + (map loadDashboard (lib.filesystem.listFilesRecursive ./objects/dashboards)); +in + +{ + services.grafana.provision.dashboards.settings = { + providers = lib.singleton { + options.path = dashboardsDir; + allowUiUpdates = true; + }; + }; +}