summary refs log tree commit diff
path: root/modules/monitoring/system.nix
blob: 171a7afb349a6659bc2474673a58f1a7766344ca (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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
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 = [
      {
        job_name = "node";
        scrape_interval = "${toString cfg.prometheusScrapeInterval}s";
        static_configs = [ { targets = [ "localhost:${toString config.services.prometheus.exporters.node.port}" ]; } ];
      }
    ];

    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";
            };
          };
        }
      ];
    };

  };
}