git.iko.soy/typeable/nixpkgs
on master help sign in
prometheus module: add nodeExporter submodule
commite43a15720d62f6640d21ed49c12a3b76a563e99e authorRobin Gloster <mail@glob.in> dateTue 26 Jul 2016, 09:50 (10 years ago) parent5131463
2 files changed+60
nixos/modules/module-list.nix+1 nixos/modules/services/monitoring/prometheus/node-exporter.nix+59
nixos/modules/module-list.nix+1
@@ -289,6 +289,7 @@
289289 ./services/monitoring/munin.nix
290290 ./services/monitoring/nagios.nix
291291 ./services/monitoring/prometheus/default.nix
292+ ./services/monitoring/prometheus/node-exporter.nix
292293 ./services/monitoring/riemann.nix
293294 ./services/monitoring/riemann-dash.nix
294295 ./services/monitoring/riemann-tools.nix
nixos/modules/services/monitoring/prometheus/node-exporter.nixnew file+59
@@ -0,0 +1,59 @@
1+{ config, pkgs, lib, ... }:
2+
3+with lib;
4+
5+let
6+ cfg = config.services.prometheus.nodeExporter;
7+in {
8+ options = {
9+ services.prometheus.nodeExporter = {
10+ enable = mkEnableOption "prometheus node exporter";
11+
12+ port = mkOption {
13+ type = types.int;
14+ default = 9100;
15+ description = ''
16+ Port to listen on.
17+ '';
18+ };
19+
20+ listenAddress = mkOption {
21+ type = types.string;
22+ default = "0.0.0.0";
23+ description = ''
24+ Address to listen on.
25+ '';
26+ };
27+
28+ enabledCollectors = mkOption {
29+ type = types.listOf types.string;
30+ default = [];
31+ example = ''[ "systemd" ]'';
32+ description = ''
33+ Collectors to enable, additionally to the defaults.
34+ '';
35+ };
36+ };
37+ };
38+
39+ config = mkIf cfg.enable {
40+ networking.firewall.allowedTCPPorts = [ cfg.port ];
41+
42+ systemd.services.prometheus-node-exporter = {
43+ wantedBy = [ "multi-user.target" ];
44+ after = [ "network.target" ];
45+ script = ''
46+ ${pkgs.prometheus-node-exporter.bin}/bin/node_exporter \
47+ ${optionalString (cfg.enabledCollectors != [])
48+ ''-collectors.enabled ${concatStringsSep "," cfg.enabledCollectors}''} \
49+ -web.listen-address ${cfg.listenAddress}:${toString cfg.port}
50+ '';
51+ serviceConfig = {
52+ User = "nobody";
53+ Restart = "always";
54+ PrivateTmp = true;
55+ WorkingDirectory = /tmp;
56+ };
57+ };
58+ };
59+}