summary refs log tree commit diff
path: root/nixos/modules/services/monitoring/prometheus
diff options
context:
space:
mode:
authorTom Hunger <tehunger@gmail.com>2016-09-11 22:45:17 +0100
committerTom Hunger <tehunger@gmail.com>2016-09-13 11:28:45 +0100
commit0ded9a63a30eb9d42ad76fd28d7de836c2f82bdc (patch)
treebfc448a80e638ad03e22fe8326a9fb1974b28358 /nixos/modules/services/monitoring/prometheus
parent300adc84580c7fdc35112052f168aa714eca977d (diff)
downloadnixpkgs-0ded9a63a30eb9d42ad76fd28d7de836c2f82bdc.tar
nixpkgs-0ded9a63a30eb9d42ad76fd28d7de836c2f82bdc.tar.gz
nixpkgs-0ded9a63a30eb9d42ad76fd28d7de836c2f82bdc.tar.bz2
nixpkgs-0ded9a63a30eb9d42ad76fd28d7de836c2f82bdc.tar.lz
nixpkgs-0ded9a63a30eb9d42ad76fd28d7de836c2f82bdc.tar.xz
nixpkgs-0ded9a63a30eb9d42ad76fd28d7de836c2f82bdc.tar.zst
nixpkgs-0ded9a63a30eb9d42ad76fd28d7de836c2f82bdc.zip
prometheus-node-exporter: Add module.
Diffstat (limited to 'nixos/modules/services/monitoring/prometheus')
-rw-r--r--nixos/modules/services/monitoring/prometheus/node-exporter.nix47
1 files changed, 47 insertions, 0 deletions
diff --git a/nixos/modules/services/monitoring/prometheus/node-exporter.nix b/nixos/modules/services/monitoring/prometheus/node-exporter.nix
new file mode 100644
index 00000000000..a462d16eef9
--- /dev/null
+++ b/nixos/modules/services/monitoring/prometheus/node-exporter.nix
@@ -0,0 +1,47 @@
+{ config, pkgs, lib, ... }:
+
+with lib;
+
+let
+  cfg = config.services.prometheus.nodeExporter;
+  cmdlineArgs = cfg.extraFlags ++ [
+    "-web.listen-address=${cfg.listenAddress}"
+  ];
+in {
+  options = {
+    services.prometheus.nodeExporter = {
+      enable = mkEnableOption "Enable the Prometheus node exporter (CPU stats etc).";
+      listenAddress = mkOption {
+        type = types.str;
+        default = "0.0.0.0:9100";
+        description = ''
+          Address to listen on.
+        '';
+      };
+      extraFlags = mkOption {
+        type = types.listOf types.str;
+        default = [];
+        description = ''
+          Extra commandline options when launching the node exporter.
+        '';
+      };
+    };
+  };
+
+  config = mkIf cfg.enable {
+    systemd.services.prometheus-node-exporter = {
+      description = "Prometheus exporter for machine metrics";
+      unitConfig.Documentation = "https://github.com/prometheus/node_exporter";
+      wantedBy = [ "multi-user.target" ];
+      script = ''
+        exec ${pkgs.prometheus-node-exporter}/bin/node_exporter \
+        ${concatStringsSep " \\\n  " cmdlineArgs}
+      '';
+      serviceConfig = {
+        User = "nobody";
+        Restart  = "always";
+        ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
+      };
+    };
+  };
+}