feat(server/grafana,server/prometheus): add prometheus datasource and node exporter config

This commit is contained in:
Mohammad Rafiq 2025-06-13 20:27:28 +08:00
parent 10661dda3b
commit 7e256c954d
No known key found for this signature in database
2 changed files with 24 additions and 1 deletions

View file

@ -19,7 +19,6 @@ in
extraConfig.proxyWebsockets = true; extraConfig.proxyWebsockets = true;
locations."/api/live/" = { locations."/api/live/" = {
proxyPass = "http://${config.system.hostname}:${builtins.toString cfg.port}"; proxyPass = "http://${config.system.hostname}:${builtins.toString cfg.port}";
proxyWebsockets = true;
}; };
}); });
services.grafana = { services.grafana = {
@ -29,6 +28,13 @@ in
http_port = cfg.port; http_port = cfg.port;
http_addr = "0.0.0.0"; http_addr = "0.0.0.0";
}; };
provision.datasources.settings.datasources = [
{
name = "prometheus";
type = "Prometheus";
url = "http://${config.system.hostname}:${builtins.toString config.server.monitoring.prometheus.port}";
}
];
}; };
}; };
} }

View file

@ -3,6 +3,7 @@ let
inherit (lib) mkEnableOption mkIf; inherit (lib) mkEnableOption mkIf;
inherit (lib.pantheon) mkPortOption; inherit (lib.pantheon) mkPortOption;
cfg = config.server.monitoring.prometheus; cfg = config.server.monitoring.prometheus;
upstreamCfg = config.services.prometheus;
in in
{ {
options.server.monitoring.prometheus = { options.server.monitoring.prometheus = {
@ -14,6 +15,22 @@ in
services.prometheus = { services.prometheus = {
enable = true; enable = true;
inherit (cfg) port; inherit (cfg) port;
scrapeConfigs = [
{
job_name = "chrysalis";
static_configs = [
{
targets = [ "127.0.0.1:${toString upstreamCfg.exporters.node.port}" ];
}
];
}
];
exporters.node = {
enable = true;
enabledCollectors = [ "systemd" ];
port = 9091;
};
}; };
}; };
} }