summaryrefslogtreecommitdiff
path: root/modules/xnet/monitoring/default.nix
blob: eed4963971cd35060a5f169ec8e6382ffb54c38c (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
{ 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;
            }];
          }];
    };
  };
}