feat(grafana): plug jsonnet-based dashboards in provisioning
Add the gerrit dashboards as an example. Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
This commit is contained in:
parent
d1ffce9336
commit
024b431cbc
|
@ -1,4 +1,8 @@
|
|||
{ stdenv, jsonnet, fetchFromGitHub, lib, ... }:
|
||||
{ gerrit-dashboard, stdenv, symlinkJoin, jsonnet, fetchFromGitHub, lib, ... }:
|
||||
let
|
||||
inherit (lib) concatMapStringsSep;
|
||||
datasource-id = "mimir";
|
||||
in
|
||||
rec {
|
||||
grafonnet = fetchFromGitHub {
|
||||
owner = "grafana";
|
||||
|
@ -8,14 +12,32 @@ rec {
|
|||
rev = "a1d61cce1da59c71409b99b5c7568511fec661ea";
|
||||
hash = "sha256-fs5JZJbcL6sQXBjYhp5eeRtjTFw0J1O/BcwBC8Vm9EM=";
|
||||
};
|
||||
buildJsonnetDashboards = dashboardSrc: target: stdenv.mkDerivation {
|
||||
name = "jsonnet-grafana-dashboard-${baseNameOf target}";
|
||||
buildJsonnetDashboards = dashboardSrc: targets: stdenv.mkDerivation {
|
||||
name = "jsonnet-grafana-dashboards";
|
||||
src = dashboardSrc;
|
||||
buildInputs = [ jsonnet ];
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
jsonnet -J ${grafonnet} --ext-code publish=false ${target} > $out
|
||||
mkdir -p $out
|
||||
${concatMapStringsSep "\n" (target: "jsonnet -J ${grafonnet} --ext-str datasource=${datasource-id} --ext-code publish=true $src/${target} > $out/${baseNameOf target}.json") targets}
|
||||
runHook postBuild
|
||||
'';
|
||||
};
|
||||
|
||||
allDashboards = symlinkJoin {
|
||||
name = "all-jsonnet-dashboards";
|
||||
paths = [
|
||||
(buildJsonnetDashboards gerrit-dashboard [
|
||||
"dashboards/gerrit/caches/gerrit-caches.jsonnet"
|
||||
"dashboards/gerrit/fetch-clone/gerrit-fetch-clone.jsonnet"
|
||||
"dashboards/gerrit/fetch-clone/gerrit-phases.jsonnet"
|
||||
"dashboards/gerrit/healthcheck/gerrit-healthcheck.jsonnet"
|
||||
"dashboards/gerrit/latency/gerrit-push-latency.jsonnet"
|
||||
"dashboards/gerrit/latency/gerrit-ui-actions-latency.jsonnet"
|
||||
"dashboards/gerrit/overview/gerrit-overview.jsonnet"
|
||||
"dashboards/gerrit/process/gerrit-process.jsonnet"
|
||||
"dashboards/gerrit/queues/gerrit-queues.jsonnet"
|
||||
])
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -388,11 +388,11 @@
|
|||
"gerrit-dashboard": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1724491526,
|
||||
"narHash": "sha256-iBI8Rkcv3CYdZHz5hDI0104C+DgPZRh5K6Zcqz9iUWw=",
|
||||
"lastModified": 1724509518,
|
||||
"narHash": "sha256-fwYXZVddxfzrlDa3QnFCwHqrbEX+3PrWy0QOlbO+8jk=",
|
||||
"ref": "refs/heads/master",
|
||||
"rev": "d6badc64723b888a4cfa0cf966aec8b91dcb8a2b",
|
||||
"revCount": 74,
|
||||
"rev": "e544abac81c581558d68abb2a8dd583049073939",
|
||||
"revCount": 75,
|
||||
"type": "git",
|
||||
"url": "https://git.lix.systems/the-distro/gerrit-monitoring.git"
|
||||
},
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
inputs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.bagel.services.grafana;
|
||||
inherit (lib) mkEnableOption mkIf;
|
||||
generatedJsonnetDashboards = (pkgs.callPackage ../../../dashboards {
|
||||
inherit (inputs) gerrit-dashboard;
|
||||
}).allDashboards;
|
||||
in
|
||||
{
|
||||
options.bagel.services.grafana.enable = mkEnableOption "Grafana frontend";
|
||||
|
@ -84,6 +89,10 @@ in
|
|||
name = "default";
|
||||
options.path = ./dashboards;
|
||||
}
|
||||
{
|
||||
name = "jsonnet";
|
||||
options.path = generatedJsonnetDashboards;
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue