forked from the-distro/infra
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 {
|
rec {
|
||||||
grafonnet = fetchFromGitHub {
|
grafonnet = fetchFromGitHub {
|
||||||
owner = "grafana";
|
owner = "grafana";
|
||||||
|
@ -8,14 +12,32 @@ rec {
|
||||||
rev = "a1d61cce1da59c71409b99b5c7568511fec661ea";
|
rev = "a1d61cce1da59c71409b99b5c7568511fec661ea";
|
||||||
hash = "sha256-fs5JZJbcL6sQXBjYhp5eeRtjTFw0J1O/BcwBC8Vm9EM=";
|
hash = "sha256-fs5JZJbcL6sQXBjYhp5eeRtjTFw0J1O/BcwBC8Vm9EM=";
|
||||||
};
|
};
|
||||||
buildJsonnetDashboards = dashboardSrc: target: stdenv.mkDerivation {
|
buildJsonnetDashboards = dashboardSrc: targets: stdenv.mkDerivation {
|
||||||
name = "jsonnet-grafana-dashboard-${baseNameOf target}";
|
name = "jsonnet-grafana-dashboards";
|
||||||
src = dashboardSrc;
|
src = dashboardSrc;
|
||||||
buildInputs = [ jsonnet ];
|
buildInputs = [ jsonnet ];
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
runHook preBuild
|
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
|
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": {
|
"gerrit-dashboard": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1724491526,
|
"lastModified": 1724509518,
|
||||||
"narHash": "sha256-iBI8Rkcv3CYdZHz5hDI0104C+DgPZRh5K6Zcqz9iUWw=",
|
"narHash": "sha256-fwYXZVddxfzrlDa3QnFCwHqrbEX+3PrWy0QOlbO+8jk=",
|
||||||
"ref": "refs/heads/master",
|
"ref": "refs/heads/master",
|
||||||
"rev": "d6badc64723b888a4cfa0cf966aec8b91dcb8a2b",
|
"rev": "e544abac81c581558d68abb2a8dd583049073939",
|
||||||
"revCount": 74,
|
"revCount": 75,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git.lix.systems/the-distro/gerrit-monitoring.git"
|
"url": "https://git.lix.systems/the-distro/gerrit-monitoring.git"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,11 +1,16 @@
|
||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
|
pkgs,
|
||||||
|
inputs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
cfg = config.bagel.services.grafana;
|
cfg = config.bagel.services.grafana;
|
||||||
inherit (lib) mkEnableOption mkIf;
|
inherit (lib) mkEnableOption mkIf;
|
||||||
|
generatedJsonnetDashboards = (pkgs.callPackage ../../../dashboards {
|
||||||
|
inherit (inputs) gerrit-dashboard;
|
||||||
|
}).allDashboards;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.bagel.services.grafana.enable = mkEnableOption "Grafana frontend";
|
options.bagel.services.grafana.enable = mkEnableOption "Grafana frontend";
|
||||||
|
@ -84,6 +89,10 @@ in
|
||||||
name = "default";
|
name = "default";
|
||||||
options.path = ./dashboards;
|
options.path = ./dashboards;
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
name = "jsonnet";
|
||||||
|
options.path = generatedJsonnetDashboards;
|
||||||
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue