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; + }; + }; +}