@@ -0,0 +1,39 @@
1+{ config, pkgs, lib, ... }:
2+
3+with lib;
4+
5+let
6+ cfg = config.services.prometheus.exporters.openvpn;
7+in {
8+ port = 9176;
9+ extraOpts = {
10+ statusPaths = mkOption {
11+ type = types.listOf types.str;
12+ description = ''
13+ Paths to OpenVPN status files. Please configure the OpenVPN option
14+ <literal>status</literal> accordingly.
15+ '';
16+ };
17+ telemetryPath = mkOption {
18+ type = types.str;
19+ default = "/metrics";
20+ description = ''
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+}