prometheus-v2ray-exporter: init at 0.6.0

This commit is contained in:
Curtis Jiang 2022-01-26 04:40:09 +00:00
parent 99bf46f5b2
commit d8bb7ec120
6 changed files with 120 additions and 0 deletions

View File

@ -6462,6 +6462,12 @@
githubId = 752510; githubId = 752510;
name = "Martin Potier"; name = "Martin Potier";
}; };
jqqqqqqqqqq = {
email = "jqqqqqqqqqq@gmail.com";
github = "jqqqqqqqqqq";
githubId = 12872927;
name = "Curtis Jiang";
};
jqueiroz = { jqueiroz = {
email = "nixos@johnjq.com"; email = "nixos@johnjq.com";
github = "jqueiroz"; github = "jqueiroz";

View File

@ -72,6 +72,7 @@ let
"unbound" "unbound"
"unifi" "unifi"
"unifi-poller" "unifi-poller"
"v2ray"
"varnish" "varnish"
"wireguard" "wireguard"
"flow" "flow"

View File

@ -0,0 +1,29 @@
{ config, lib, pkgs, options }:
with lib;
let
cfg = config.services.prometheus.exporters.v2ray;
in
{
port = 9299;
extraOpts = {
v2rayEndpoint = mkOption {
type = types.str;
default = "127.0.0.1:54321";
description = ''
v2ray grpc api endpoint
'';
};
};
serviceOpts = {
serviceConfig = {
ExecStart = ''
${pkgs.prometheus-v2ray-exporter}/bin/v2ray-exporter \
--v2ray-endpoint ${cfg.v2rayEndpoint} \
--listen ${cfg.listenAddress}:${toString cfg.port} \
${concatStringsSep " \\\n " cfg.extraFlags}
'';
};
};
}

View File

@ -1256,6 +1256,67 @@ let
''; '';
}; };
v2ray = {
exporterConfig = {
enable = true;
};
metricProvider = {
systemd.services.prometheus-nginx-exporter.after = [ "v2ray.service" ];
services.v2ray = {
enable = true;
config = {
stats = {};
api = {
tag = "api";
services = [ "StatsService" ];
};
inbounds = [
{
port = 1080;
listen = "127.0.0.1";
protocol = "http";
}
{
listen = "127.0.0.1";
port = 54321;
protocol = "dokodemo-door";
settings = { address = "127.0.0.1"; };
tag = "api";
}
];
outbounds = [
{
protocol = "freedom";
}
{
protocol = "freedom";
settings = {};
tag = "api";
}
];
routing = {
strategy = "rules";
settings = {
rules = [
{
inboundTag = [ "api" ];
outboundTag = "api";
type = "field";
}
];
};
};
};
};
};
exporterTest = ''
wait_for_unit("prometheus-v2ray-exporter.service")
wait_for_open_port(9299)
succeed("curl -sSf localhost:9299/scrape | grep 'v2ray_up 1'")
'';
};
varnish = { varnish = {
exporterConfig = { exporterConfig = {
enable = true; enable = true;

View File

@ -0,0 +1,22 @@
{ lib, buildGoModule, fetchFromGitHub }:
buildGoModule rec {
pname = "v2ray-exporter";
version = "0.6.0";
src = fetchFromGitHub {
owner = "wi1dcard";
repo = "v2ray-exporter";
rev = "v${version}";
sha256 = "12mzng3cw24fyyh8zjfi26gh853k5blzg3zbxcccnv5lryh2r0yi";
};
vendorSha256 = "sha256-+jrD+QatTrMaAdbxy5mpCm8lF37XDIy1GFyEiUibA2k=";
meta = with lib; {
description = "Prometheus exporter for V2Ray daemon";
homepage = "https://github.com/wi1dcard/v2ray-exporter";
license = licenses.mit;
maintainers = with maintainers; [ jqqqqqqqqqq ];
};
}

View File

@ -23319,6 +23319,7 @@ with pkgs;
prometheus-unbound-exporter = callPackage ../servers/monitoring/prometheus/unbound-exporter.nix { prometheus-unbound-exporter = callPackage ../servers/monitoring/prometheus/unbound-exporter.nix {
inherit (darwin.apple_sdk.frameworks) Security; inherit (darwin.apple_sdk.frameworks) Security;
}; };
prometheus-v2ray-exporter = callPackage ../servers/monitoring/prometheus/v2ray-exporter.nix { };
prometheus-varnish-exporter = callPackage ../servers/monitoring/prometheus/varnish-exporter.nix { }; prometheus-varnish-exporter = callPackage ../servers/monitoring/prometheus/varnish-exporter.nix { };
prometheus-wireguard-exporter = callPackage ../servers/monitoring/prometheus/wireguard-exporter.nix { prometheus-wireguard-exporter = callPackage ../servers/monitoring/prometheus/wireguard-exporter.nix {
inherit (darwin.apple_sdk.frameworks) Security; inherit (darwin.apple_sdk.frameworks) Security;