diff options
Diffstat (limited to 'modules/monitoring/system.nix')
-rw-r--r-- | modules/monitoring/system.nix | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/modules/monitoring/system.nix b/modules/monitoring/system.nix new file mode 100644 index 0000000..cc1ec66 --- /dev/null +++ b/modules/monitoring/system.nix @@ -0,0 +1,75 @@ +{ lib, config, ... }: +let + cfg = config.monitoring; +in +{ + config = lib.mkIf (cfg.monitorAll) { + services.prometheus.exporters.node = { + enable = true; + port = 9100; + enabledCollectors = [ + #"logind" #too slow + "systemd" + "processes" + "interrupts" + # Testing: + "buddyinfo" + "cgroups" + "ksmd" + "lnstat" + "mountstats" + "network_route" + #"perf" # requires sysctl change + "qdisc" + "sysctl" + "softirqs" + "tcpstat" + ]; + disabledCollectors = [ + "textfile" + "xfs" + "zfs" + "selinux" + "cpufreq" + "btrfs" + "powersupplyclass" + "mdadm" + "tapestats" + "fibrechannel" + "cpu_vulnerabilities" + "watchdog" + "thermal_zone" + "logind" + "nfs" + "nfsd" + "infiniband" + ]; + }; + + services.prometheus.scrapeConfigs = ( + lib.map (interval: { + job_name = "node-${toString interval}s"; + scrape_interval = "${toString interval}s"; + static_configs = [ { targets = [ "localhost:${toString config.services.prometheus.exporters.node.port}" ]; } ]; + }) cfg.prometheusScrapeIntervals + ); + + services.grafana.provision.dashboards.settings = { + apiVersion = 1; + providers = [ + { + name = "default"; + orgId = 1; + type = "file"; + options = { + path = builtins.fetchurl { + url = "https://grafana.com/api/dashboards/1860/revisions/37/download"; + sha256 = "0qza4j8lywrj08bqbww52dgh2p2b9rkhq5p313g72i57lrlkacfl"; + }; + }; + } + ]; + }; + + }; +} |