about summary refs log tree commit diff
path: root/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/v2ray.nix
blob: 4fda15c9ee4ea1dc867b866318d8e02d7962b0d8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{ config, lib, pkgs, options, ... }:

let
  cfg = config.services.prometheus.exporters.v2ray;
  inherit (lib) mkOption types concatStringsSep;
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}
      '';
    };
  };
}