diff options
author | Robin Gloster <mail@glob.in> | 2016-07-26 09:50:17 +0000 |
---|---|---|
committer | Robin Gloster <mail@glob.in> | 2016-09-15 20:31:03 +0200 |
commit | e43a15720d62f6640d21ed49c12a3b76a563e99e (patch) | |
tree | 48943e28e4a4505825640012f008b692730ecd17 /nixos/modules/services | |
parent | 51314631d6ee153dab70d99f7a08f04a89d23c5e (diff) | |
download | nixlib-e43a15720d62f6640d21ed49c12a3b76a563e99e.tar nixlib-e43a15720d62f6640d21ed49c12a3b76a563e99e.tar.gz nixlib-e43a15720d62f6640d21ed49c12a3b76a563e99e.tar.bz2 nixlib-e43a15720d62f6640d21ed49c12a3b76a563e99e.tar.lz nixlib-e43a15720d62f6640d21ed49c12a3b76a563e99e.tar.xz nixlib-e43a15720d62f6640d21ed49c12a3b76a563e99e.tar.zst nixlib-e43a15720d62f6640d21ed49c12a3b76a563e99e.zip |
prometheus module: add nodeExporter submodule
Diffstat (limited to 'nixos/modules/services')
-rw-r--r-- | nixos/modules/services/monitoring/prometheus/node-exporter.nix | 59 |
1 files changed, 59 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 000000000000..6750d4c75070 --- /dev/null +++ b/nixos/modules/services/monitoring/prometheus/node-exporter.nix @@ -0,0 +1,59 @@ +{ config, pkgs, lib, ... }: + +with lib; + +let + cfg = config.services.prometheus.nodeExporter; +in { + options = { + services.prometheus.nodeExporter = { + enable = mkEnableOption "prometheus node exporter"; + + port = mkOption { + type = types.int; + default = 9100; + description = '' + Port to listen on. + ''; + }; + + listenAddress = mkOption { + type = types.string; + default = "0.0.0.0"; + description = '' + Address to listen on. + ''; + }; + + enabledCollectors = mkOption { + type = types.listOf types.string; + default = []; + example = ''[ "systemd" ]''; + description = '' + Collectors to enable, additionally to the defaults. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + networking.firewall.allowedTCPPorts = [ cfg.port ]; + + systemd.services.prometheus-node-exporter = { + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" ]; + script = '' + ${pkgs.prometheus-node-exporter.bin}/bin/node_exporter \ + ${optionalString (cfg.enabledCollectors != []) + ''-collectors.enabled ${concatStringsSep "," cfg.enabledCollectors}''} \ + -web.listen-address ${cfg.listenAddress}:${toString cfg.port} + ''; + serviceConfig = { + User = "nobody"; + Restart = "always"; + PrivateTmp = true; + WorkingDirectory = /tmp; + }; + }; + }; +} |