summary refs log tree commit diff
path: root/nixos/modules/services/monitoring/prometheus/exporters/knot.nix
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2021-03-05 13:06:40 +0100
committerMaximilian Bosch <maximilian@mbosch.me>2021-03-05 13:13:46 +0100
commitb4bd584b640d0bee0ab5a2d8dbbaf4f5e4ee53db (patch)
treefda0bbc90ff56098a2fa80ce9b9fc18f1f82fe92 /nixos/modules/services/monitoring/prometheus/exporters/knot.nix
parentbae2759a377283f44aa95facf4732101819f16c1 (diff)
downloadnixpkgs-b4bd584b640d0bee0ab5a2d8dbbaf4f5e4ee53db.tar
nixpkgs-b4bd584b640d0bee0ab5a2d8dbbaf4f5e4ee53db.tar.gz
nixpkgs-b4bd584b640d0bee0ab5a2d8dbbaf4f5e4ee53db.tar.bz2
nixpkgs-b4bd584b640d0bee0ab5a2d8dbbaf4f5e4ee53db.tar.lz
nixpkgs-b4bd584b640d0bee0ab5a2d8dbbaf4f5e4ee53db.tar.xz
nixpkgs-b4bd584b640d0bee0ab5a2d8dbbaf4f5e4ee53db.tar.zst
nixpkgs-b4bd584b640d0bee0ab5a2d8dbbaf4f5e4ee53db.zip
nixos/prometheus/exporters/knot: init
Diffstat (limited to 'nixos/modules/services/monitoring/prometheus/exporters/knot.nix')
-rw-r--r--nixos/modules/services/monitoring/prometheus/exporters/knot.nix50
1 files changed, 50 insertions, 0 deletions
diff --git a/nixos/modules/services/monitoring/prometheus/exporters/knot.nix b/nixos/modules/services/monitoring/prometheus/exporters/knot.nix
new file mode 100644
index 00000000000..46c28fe0a57
--- /dev/null
+++ b/nixos/modules/services/monitoring/prometheus/exporters/knot.nix
@@ -0,0 +1,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" ];
+    };
+  };
+}