summaryrefslogtreecommitdiff
path: root/os/srv/prometheus.nix
blob: 5b133be8478d525c52570153b3e0649cd3c2d57f (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
70
71
72
73
74
75
{
  config,
  lib,
  masterDomain,
  ...
}:
let
  cfg = config.os.srv.prometheus;
in
{
  options.os.srv.prometheus.enable = lib.mkEnableOption "enables prometheus";
  config = lib.mkIf cfg.enable {
    services.prometheus = {
      enable = true;
      port = 9090;

      scrapeConfigs = [
        {
          job_name = "prometheus";
          static_configs = [ { targets = [ "127.0.0.1:9090" ]; } ];
        }
        {
          job_name = "node-hardware";
          static_configs = [ { targets = [ "127.0.0.1:9100" ]; } ];
        }
        {
          job_name = "node_exporter";
          static_configs = [ { targets = [ "127.0.0.1:9100" ]; } ];
        }
        {
          job_name = "bare_metal_host_netdata";
          scheme = "https";
          metrics_path = "/api/v1/allmetrics";
          params = {
            format = [ "prometheus" ];
          };
          static_configs = [
            { targets = [ "netdata.${masterDomain}" ]; }
          ];
        }
        {
          job_name = "uptime_kuma";
          metrics_path = "/metrics";
          static_configs = [ { targets = [ "127.0.0.1:3001" ]; } ];
        }
        {
          job_name = "network-latency";
          static_configs = [ { targets = [ "127.0.0.1:9374" ]; } ];
        }
      ];
      exporters = {
        node = {
          enable = true;
          enableCollectors = [ "systemd" ];
          port = 9100;
        };

        smokeping = {
          enable = true;
          listenAddress = "127.0.0.1";

          hosts = [
            "10.0.0.1" # Personal Router
            "192.168.0.1" # ISP Modem Box
            "84.116.254.69" # First ISP Hop
            "185.182.244.39" # Regional Katowice Hub
            "1.1.1.1" # Cloudflare DNS
            "8.8.8.8" # Google DNS
            "130.162.223.123" # OCI Instance
          ];
        };
      };
    };
  };
}