1{
2 config,
3 lib,
4 pkgs,
5 options,
6 ...
7}:
8
9let
10 cfg = config.services.prometheus.exporters.bind;
11 inherit (lib) mkOption types concatStringsSep;
12in
13{
14 port = 9119;
15 extraOpts = {
16 bindURI = mkOption {
17 type = types.str;
18 default = "http://localhost:8053/";
19 description = ''
20 HTTP XML API address of an Bind server.
21 '';
22 };
23 bindTimeout = mkOption {
24 type = types.str;
25 default = "10s";
26 description = ''
27 Timeout for trying to get stats from Bind.
28 '';
29 };
30 bindVersion = mkOption {
31 type = types.enum [
32 "xml.v2"
33 "xml.v3"
34 "auto"
35 ];
36 default = "auto";
37 description = ''
38 BIND statistics version. Can be detected automatically.
39 '';
40 };
41 bindGroups = mkOption {
42 type = types.listOf (
43 types.enum [
44 "server"
45 "view"
46 "tasks"
47 ]
48 );
49 default = [
50 "server"
51 "view"
52 ];
53 description = ''
54 List of statistics to collect. Available: [server, view, tasks]
55 '';
56 };
57 };
58 serviceOpts = {
59 serviceConfig = {
60 ExecStart = ''
61 ${pkgs.prometheus-bind-exporter}/bin/bind_exporter \
62 --web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
63 --bind.pid-file /var/run/named/named.pid \
64 --bind.timeout ${toString cfg.bindTimeout} \
65 --bind.stats-url ${cfg.bindURI} \
66 --bind.stats-version ${cfg.bindVersion} \
67 --bind.stats-groups ${concatStringsSep "," cfg.bindGroups} \
68 ${concatStringsSep " \\\n " cfg.extraFlags}
69 '';
70 };
71 };
72}