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

Florian Sesser
committed
{ config, lib, pkgs, options, ... }:

Florian Sesser
committed
cfg = config.services.private-storage.monitoring.exporters.node;
mountsFileSystemType = fsType: {} != filterAttrs (n: v: v.fsType == fsType) config.fileSystems;
in {

Florian Sesser
committed
options.services.private-storage.monitoring.exporters.node = {
textfiles-directory = lib.mkOption {
type = lib.types.str;
description = "Directory used by the textfiles collector.";
default = "/run/prometheus-node-exporter";

Florian Sesser
committed
};

Tom Prince
committed
config.services.prometheus.exporters.node = lib.mkIf cfg.enable {
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.directory ${cfg.textfiles-directory}"
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
75
76
77
78
79
80
81
82
83
84
#"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" ]
);
};
}