1{ config, pkgs, lib, ... }:
2
3with lib;
4
5let
6 cfg = config.services.prometheus.exporters.openvpn;
7in {
8 port = 9176;
9 extraOpts = {
10 statusPaths = mkOption {
11 type = types.listOf types.str;
12 description = lib.mdDoc ''
13 Paths to OpenVPN status files. Please configure the OpenVPN option
14 `status` accordingly.
15 '';
16 };
17 telemetryPath = mkOption {
18 type = types.str;
19 default = "/metrics";
20 description = lib.mdDoc ''
21 Path under which to expose metrics.
22 '';
23 };
24 };
25
26 serviceOpts = {
27 serviceConfig = {
28 PrivateDevices = true;
29 ProtectKernelModules = true;
30 NoNewPrivileges = true;
31 ExecStart = ''
32 ${pkgs.prometheus-openvpn-exporter}/bin/openvpn_exporter \
33 -openvpn.status_paths "${concatStringsSep "," cfg.statusPaths}" \
34 -web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
35 -web.telemetry-path ${cfg.telemetryPath}
36 '';
37 };
38 };
39}