mirror of
https://github.com/spacebarchat/server.git
synced 2026-06-07 11:01:47 +00:00
Nix: prometheus support
This commit is contained in:
@@ -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);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user