2024-08-24 09:19:33 +00:00
|
|
|
|
{ gerrit-dashboard, stdenv, symlinkJoin, jsonnet, fetchFromGitHub, lib, ... }:
|
|
|
|
|
let
|
|
|
|
|
inherit (lib) concatMapStringsSep;
|
|
|
|
|
datasource-id = "mimir";
|
|
|
|
|
in
|
2024-08-24 08:59:47 +00:00
|
|
|
|
rec {
|
|
|
|
|
grafonnet = fetchFromGitHub {
|
|
|
|
|
owner = "grafana";
|
|
|
|
|
repo = "grafonnet-lib";
|
|
|
|
|
# TODO: figure out how to read the jsonnet lockfile
|
|
|
|
|
# and propagate this a bit cleverly.
|
|
|
|
|
rev = "a1d61cce1da59c71409b99b5c7568511fec661ea";
|
|
|
|
|
hash = "sha256-fs5JZJbcL6sQXBjYhp5eeRtjTFw0J1O/BcwBC8Vm9EM=";
|
|
|
|
|
};
|
2024-08-24 09:19:33 +00:00
|
|
|
|
buildJsonnetDashboards = dashboardSrc: targets: stdenv.mkDerivation {
|
|
|
|
|
name = "jsonnet-grafana-dashboards";
|
2024-08-24 08:59:47 +00:00
|
|
|
|
src = dashboardSrc;
|
|
|
|
|
buildInputs = [ jsonnet ];
|
|
|
|
|
buildPhase = ''
|
|
|
|
|
runHook preBuild
|
2024-08-24 09:19:33 +00:00
|
|
|
|
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}
|
2024-08-24 08:59:47 +00:00
|
|
|
|
runHook postBuild
|
|
|
|
|
'';
|
|
|
|
|
};
|
2024-08-24 09:19:33 +00:00
|
|
|
|
|
|
|
|
|
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"
|
|
|
|
|
])
|
|
|
|
|
];
|
|
|
|
|
};
|
2024-08-24 08:59:47 +00:00
|
|
|
|
}
|