Skip to content

Commit a6e6be0

Browse files
Nix: prometheus support
1 parent 153ecfd commit a6e6be0

2 files changed

Lines changed: 48 additions & 0 deletions

File tree

nix/modules/default/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ in
1818
{
1919
imports = [
2020
./integration-nginx.nix
21+
./integration-prometheus.nix
2122
./users.nix
2223
(import ./gw-sharding.nix self)
2324
(import ./pion-sfu.nix self)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
config,
3+
lib,
4+
...
5+
}:
6+
7+
let
8+
cfg = config.services.spacebarchat-server;
9+
in
10+
{
11+
options.services.spacebarchat-server.prometheus = {
12+
enable = lib.mkEnableOption "prometheus integration";
13+
};
14+
15+
config = lib.mkIf (cfg.enable && cfg.prometheus.enable) {
16+
services.prometheus.scrapeConfigs = [
17+
{
18+
job_name = "spacebar-api-${builtins.toString cfg.apiEndpoint.localPort}";
19+
scrape_interval = "1s";
20+
static_configs = [
21+
{ targets = [ "localhost:${builtins.toString cfg.apiEndpoint.localPort}" ]; }
22+
];
23+
}
24+
{
25+
job_name = "spacebar-gateway-${builtins.toString cfg.gatewayEndpoint.localPort}";
26+
scrape_interval = "1s";
27+
static_configs = [
28+
{ targets = [ "localhost:${builtins.toString cfg.gatewayEndpoint.localPort}" ]; }
29+
];
30+
}
31+
{
32+
job_name = "spacebar-cdn-${builtins.toString cfg.cdnEndpoint.localPort}";
33+
scrape_interval = "1s";
34+
static_configs = [
35+
{ targets = [ "localhost:${builtins.toString cfg.cdnEndpoint.localPort}" ]; }
36+
];
37+
}
38+
]
39+
++ (lib.map (port: {
40+
job_name = "spacebar-gateway-${builtins.toString port}";
41+
scrape_interval = "1s";
42+
static_configs = [
43+
{ targets = [ "localhost:${builtins.toString port}" ]; }
44+
];
45+
}) cfg.extraGatewayPorts);
46+
};
47+
}

0 commit comments

Comments
 (0)