Newer
Older
# Prometheus common node exporter config
#
# Scope: Export platform data like CPU, memory, disk space etc. to be
# polled by Prometheus server
# Usage: Import this to every server you want to include in the central
# monitoring system
# See https://nixos.org/manual/nixos/stable/#module-services-prometheus-exporters
{ config, lib, pkgs, ... }:
with lib;
let
mountsFileSystemType = fsType: {} != filterAttrs (n: v: v.fsType == fsType) config.fileSystems;
in {
config.services.prometheus.exporters.node = {
enable = true;
openFirewall = true;
firewallFilter = "-i monitoringvpn -p tcp -m tcp --dport 9100";
port = 9100;
# extraFlags = [ "--collector.disable-defaults" ]; # not in nixpkgs 19.09
# Thanks https://github.com/mayflower/nixexprs/blob/master/modules/monitoring/default.nix
enabledCollectors = [
"arp"
"bcache"
"conntrack"
"filefd"
"logind"
"netclass"
"netdev"
"netstat"
#"rapl" # not in nixpkgs 19.09
"sockstat"
#"softnet" # not in nixpkgs 19.09
"stat"
"systemd"
"textfile"
"textfile.directory /run/prometheus-node-exporter"
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#"thermal_zone" # not in nixpkgs 19.09
"time"
#"udp_queues" # not in nixpkgs 19.09
"uname"
"vmstat"
] ++ optionals (!config.boot.isContainer) [
"cpu"
"cpufreq"
"diskstats"
"edac"
"entropy"
"filesystem"
"hwmon"
"interrupts"
"ksmd"
"loadavg"
"meminfo"
"pressure"
"timex"
] ++ (
optionals (config.services.nfs.server.enable) [ "nfsd" ]
) ++ (
optionals ("" != config.boot.initrd.mdadmConf) [ "mdadm" ]
) ++ (
optionals ({} != config.networking.bonds) [ "bonding" ]
) ++ (
optionals (mountsFileSystemType "nfs") [ "nfs" ]
) ++ (
optionals (mountsFileSystemType "xfs") [ "xfs" ]
) ++ (
optionals (mountsFileSystemType "zfs" || elem "zfs" config.boot.supportedFilesystems) [ "zfs" ]
);
};
}