From 62fb7f7c127ca8aee56b3903ee207dec766d0a11 Mon Sep 17 00:00:00 2001 From: Rory& Date: Wed, 28 Aug 2024 21:40:53 +0200 Subject: Monitoring? --- modules/monitoring/system.nix | 75 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 modules/monitoring/system.nix (limited to 'modules/monitoring/system.nix') 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"; + }; + }; + } + ]; + }; + + }; +} -- cgit 1.4.1