summaryrefslogtreecommitdiff
path: root/modules/xnet/monitoring/default.nix
blob: 20566d3e4e8ec0fed892024aef565800dc8a7399 (plain)
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
{ config, ... }:
let
  inherit (builtins)
    map
    ;

  inherit (config.services.prometheus) exporters;
in
{
  imports = [ ./grafana.nix ];

  config = {
    services.prometheus = {
      enable = config.xnet.monitoring.hostGrafana;
      globalConfig.scrape_interval = "1m";

      exporters = {
        node = {
          enable = true;
          openFirewall = true;
          enabledCollectors = [
            "processes"
            "systemd"
          ];
        };

        # systemd = {
        #   enable = true;
        #   openFirewall = true;
        #   extraFlags = [
        #     "--systemd.collector.enable-ip-accounting"
        #     "--systemd.collector.enable-restart-count"
        #   ];
        # };

        smartctl = {
          enable = true;
          openFirewall = true;
        };
      };

      scrapeConfigs =
        let
          hosts = [
            "iridium"
            "radon"
          ];
        in
        [
          {
            job_name = "node";
            static_configs = [
              {
                targets = map (h: "${h}:${toString exporters.node.port}") hosts;
              }
            ];
          }
          {
            job_name = "smartctl";
            static_configs = [
              {
                targets = map (h: "${h}:${toString exporters.smartctl.port}") hosts;
              }
            ];
          }
        ];
    };
  };
}