modules/monitoring: add sing-box monitoring

This commit is contained in:
xinyangli 2024-12-10 12:04:54 +08:00
parent e4fd9e8b23
commit dacd22b7d2
Signed by: xin
SSH key fingerprint: SHA256:UU5pRTl7NiLFJbWJZa+snLylZSXIz5rgHmwjzv8v4oE
6 changed files with 69 additions and 0 deletions

View file

@ -1,5 +1,6 @@
{
config,
pkgs,
lib,
...
}:
@ -114,7 +115,24 @@ let
}
]);
};
experimental = {
v2ray_api = {
listen = "127.0.0.1:15175";
stats = {
users = map (u: u.name) users;
enabled = true;
inbounds = map (p: "sg" + toString p) (lib.range 0 4);
};
};
};
};
sing-box = pkgs.sing-box.overrideAttrs (
finalAttrs: previousAttrs: {
tags = previousAttrs.tags ++ [
"with_v2ray_api"
];
}
);
in
{
options.commonSettings.proxyServer = {
@ -166,6 +184,7 @@ in
services.sing-box = {
enable = true;
package = sing-box;
settings = (
mkSingConfig (
map (n: {

View file

@ -57,6 +57,13 @@ in
default = "${config.networking.hostName}.coho-tet.ts.net";
};
};
v2ray = {
enable = mkEnableOption "blackbox exporter";
listenAddress = mkOption {
type = types.str;
default = "${config.networking.hostName}.coho-tet.ts.net";
};
};
};
};
};

View file

@ -47,6 +47,13 @@ in
);
};
services.prometheus.exporters.v2ray = mkIf cfg.v2ray.enable {
enable = true;
listenAddress = cfg.v2ray.listenAddress;
port = 9516;
v2rayEndpoint = config.services.sing-box.settings.experimental.v2ray_api.listen;
};
# gotosocial
sops.templates."gotosocial_metrics.env" = {
content = ''