Merge pull request #156813 from JQ-Networks/master

This commit is contained in:
Sandro 2022-09-04 14:32:13 +02:00 committed by GitHub
commit 2f54aad5e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 120 additions and 0 deletions

View file

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

View file

@ -72,6 +72,7 @@ let
"unbound"
"unifi"
"unifi-poller"
"v2ray"
"varnish"
"wireguard"
"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 = {
exporterConfig = {
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

@ -23410,6 +23410,7 @@ with pkgs;
prometheus-unbound-exporter = callPackage ../servers/monitoring/prometheus/unbound-exporter.nix {
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-wireguard-exporter = callPackage ../servers/monitoring/prometheus/wireguard-exporter.nix {
inherit (darwin.apple_sdk.frameworks) Security;