prometheus module: add nodeExporter submodule

This commit is contained in:
Robin Gloster 2016-07-26 09:50:17 +00:00
parent 51314631d6
commit e43a15720d
No known key found for this signature in database
GPG key ID: 5E4C836C632C2882
2 changed files with 60 additions and 0 deletions

View file

@ -289,6 +289,7 @@
./services/monitoring/munin.nix
./services/monitoring/nagios.nix
./services/monitoring/prometheus/default.nix
./services/monitoring/prometheus/node-exporter.nix
./services/monitoring/riemann.nix
./services/monitoring/riemann-dash.nix
./services/monitoring/riemann-tools.nix

View file

@ -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;
};
};
};
}