summary refs log tree commit diff
path: root/nixos/modules/services/monitoring/prometheus/exporters/knot.nix
blob: 29e543f1013b6f613432da0169b7bc9d39a0c237 (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
{ config, lib, pkgs, options }:

with lib;

let
  cfg = config.services.prometheus.exporters.knot;
in {
  port = 9433;
  extraOpts = {
    knotLibraryPath = mkOption {
      type = types.str;
      default = "${pkgs.knot-dns.out}/lib/libknot.so";
      defaultText = literalExpression ''"''${pkgs.knot-dns.out}/lib/libknot.so"'';
      description = ''
        Path to the library of <package>knot-dns</package>.
      '';
    };

    knotSocketPath = mkOption {
      type = types.str;
      default = "/run/knot/knot.sock";
      description = ''
        Socket path of <citerefentry><refentrytitle>knotd</refentrytitle>
        <manvolnum>8</manvolnum></citerefentry>.
      '';
    };

    knotSocketTimeout = mkOption {
      type = types.int;
      default = 2000;
      description = ''
        Timeout in seconds.
      '';
    };
  };
  serviceOpts = {
    serviceConfig = {
      ExecStart = ''
        ${pkgs.prometheus-knot-exporter}/bin/knot_exporter \
          --web-listen-addr ${cfg.listenAddress} \
          --web-listen-port ${toString cfg.port} \
          --knot-library-path ${cfg.knotLibraryPath} \
          --knot-socket-path ${cfg.knotSocketPath} \
          --knot-socket-timeout ${toString cfg.knotSocketTimeout} \
          ${concatStringsSep " \\\n  " cfg.extraFlags}
      '';
      SupplementaryGroups = [ "knot" ];
      RestrictAddressFamilies = [
        # Need AF_UNIX to collect data
        "AF_UNIX"
      ];
    };
  };
}