about summary refs log tree commit diff
path: root/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters/knot.nix
blob: 46c28fe0a57811679328dfc621b767bd0ea0cc30 (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
{ 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 = "\${pkgs.knot-dns}/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" ];
    };
  };
}