aboutsummaryrefslogtreecommitdiffstats
path: root/modules/by-name/mo/monitoring/components/scrutiny.nix
blob: adb515e173f02505cd776d7eb14b41d35d21c7a1 (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
{
  config,
  pkgs,
  lib,
  ...
}: let
  cfg = config.vhack.monitoring.scrutiny;
in {
  options.vhack.monitoring.scrutiny = {
    enable = lib.mkEnableOption "scrutiny service";
  };

  # We don't currently _care_ about the health of the hardware, because hetzner does
  # this for us (nor can we care, because it's not exposed in the VPS)
  config = lib.mkIf false {
    vhack.monitoring = {
      prometheus.sources = [
        {
          name = "scrutiny";
          extra.metrics_path = "/api/metrics";
          target = "127.0.0.1:${toString config.services.scrutiny.settings.web.listen.port}";
        }
        {
          name = "smartctl";
          target = "127.0.0.1:${toString config.services.prometheus.exporters.smartctl.port}";
        }
      ];
      grafana.dashboards = [
        ../dashboards/Health.json
      ];
    };

    users = {
      groups = {
        smartctl-exporter-access.gid = config.vhack.constants.ids.gids.smartctl-exporter-access;
      };
      users = {
        smartctl-exporter-access = {
          isSystemUser = true;
          group = "smartctl-exporter-access";
          uid = config.vhack.constants.ids.uids.smartctl-exporter-access;
        };
      };
    };

    services = {
      scrutiny = {
        enable = true;

        openFirewall = false;

        # This src includes Prometheus metrics exporter.
        package = pkgs.scrutiny.overrideAttrs {
          src = pkgs.fetchFromGitHub {
            owner = "ibizaman";
            repo = "scrutiny";
            rev = "74faf06f77df83f29e7e1806cd88b2fafc0bbb82";
            hash = "sha256-r0AVWL+E046xHxitwMPfRNTOpjuOk+W6tB41YgmLTPg=";
          };

          vendorHash = "sha256-kAlnlWnBMFCdgdak5L5hRquRtyLi5MTmDa/kxwqPs4E=";
        };

        settings = {
          web = {
            metrics.enabled = true; # Enables Prometheus exporter
            listenHost = "127.0.0.1";
          };
        };

        collector = {
          enable = true;
        };
      };
      prometheus = {
        exporters.smartctl = {
          enable = true;
          port = 9115;
          listenAddress = "127.0.0.1";
        };
      };
    };

    # nixpkgs.overlays = [
    #   (final: prev: {
    #     prometheus-systemd-exporter = prev.prometheus-systemd-exporter.overrideAttrs {
    #       src = final.fetchFromGitHub {
    #         owner = "ibizaman";
    #         repo = prev.prometheus-systemd-exporter.pname;
    #         # rev = "v${prev.prometheus-systemd-exporter.version}";
    #         rev = "next_timer";
    #         sha256 = "sha256-jzkh/616tsJbNxFtZ0xbdBQc16TMIYr9QOkPaeQw8xA=";
    #       };
    #
    #       vendorHash = "sha256-4hsQ1417jLNOAqGkfCkzrmEtYR4YLLW2j0CiJtPg6GI=";
    #     };
    #   })
    # ];
  };
}