Merge pull request #156813 from JQ-Networks/master

Sandro 2f54aad5 16c8c990

Changed files
+120
maintainers
nixos
modules
services
monitoring
prometheus
tests
pkgs
servers
monitoring
prometheus
top-level
+6
maintainers/maintainer-list.nix
···
githubId = 752510;
name = "Martin Potier";
};
jqueiroz = {
email = "nixos@johnjq.com";
github = "jqueiroz";
···
githubId = 752510;
name = "Martin Potier";
};
+
jqqqqqqqqqq = {
+
email = "jqqqqqqqqqq@gmail.com";
+
github = "jqqqqqqqqqq";
+
githubId = 12872927;
+
name = "Curtis Jiang";
+
};
jqueiroz = {
email = "nixos@johnjq.com";
github = "jqueiroz";
+1
nixos/modules/services/monitoring/prometheus/exporters.nix
···
"unbound"
"unifi"
"unifi-poller"
"varnish"
"wireguard"
"flow"
···
"unbound"
"unifi"
"unifi-poller"
+
"v2ray"
"varnish"
"wireguard"
"flow"
+29
nixos/modules/services/monitoring/prometheus/exporters/v2ray.nix
···
···
+
{ 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}
+
'';
+
};
+
};
+
}
+61
nixos/tests/prometheus-exporters.nix
···
'';
};
varnish = {
exporterConfig = {
enable = true;
···
'';
};
+
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;
+22
pkgs/servers/monitoring/prometheus/v2ray-exporter.nix
···
···
+
{ 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 ];
+
};
+
}
+1
pkgs/top-level/all-packages.nix
···
prometheus-unbound-exporter = callPackage ../servers/monitoring/prometheus/unbound-exporter.nix {
inherit (darwin.apple_sdk.frameworks) Security;
};
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;
···
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;