Nix: prometheus support

This commit is contained in:
Rory&
2026-05-28 18:52:45 +02:00
parent 153ecfd992
commit a6e6be065e
2 changed files with 48 additions and 0 deletions
+1
View File
@@ -18,6 +18,7 @@ in
{
imports = [
./integration-nginx.nix
./integration-prometheus.nix
./users.nix
(import ./gw-sharding.nix self)
(import ./pion-sfu.nix self)
@@ -0,0 +1,47 @@
{
config,
lib,
...
}:
let
cfg = config.services.spacebarchat-server;
in
{
options.services.spacebarchat-server.prometheus = {
enable = lib.mkEnableOption "prometheus integration";
};
config = lib.mkIf (cfg.enable && cfg.prometheus.enable) {
services.prometheus.scrapeConfigs = [
{
job_name = "spacebar-api-${builtins.toString cfg.apiEndpoint.localPort}";
scrape_interval = "1s";
static_configs = [
{ targets = [ "localhost:${builtins.toString cfg.apiEndpoint.localPort}" ]; }
];
}
{
job_name = "spacebar-gateway-${builtins.toString cfg.gatewayEndpoint.localPort}";
scrape_interval = "1s";
static_configs = [
{ targets = [ "localhost:${builtins.toString cfg.gatewayEndpoint.localPort}" ]; }
];
}
{
job_name = "spacebar-cdn-${builtins.toString cfg.cdnEndpoint.localPort}";
scrape_interval = "1s";
static_configs = [
{ targets = [ "localhost:${builtins.toString cfg.cdnEndpoint.localPort}" ]; }
];
}
]
++ (lib.map (port: {
job_name = "spacebar-gateway-${builtins.toString port}";
scrape_interval = "1s";
static_configs = [
{ targets = [ "localhost:${builtins.toString port}" ]; }
];
}) cfg.extraGatewayPorts);
};
}