about summary refs log tree commit diff
path: root/nix/hosts/corrino/www/prometheus.emile.space.nix
blob: ec13dfa5ecb650f071131a86502550ca07768ea2 (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
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
101
102
103
104
105
106
107
108
109
110
{ config, ... }:

{
  services = {
    nginx.virtualHosts = {
      "prometheus.emile.space" = {
        addSSL = true;
        enableACME = true;
        locations."/" = {
          proxyPass = "http://${config.services.prometheus.listenAddress}:${toString config.services.prometheus.port}/";
          proxyWebsockets = true;
        };
      };
    };

    prometheus = {
      enable = true;
      retentionTime = "356d";

      listenAddress = "[::1]";
      port = config.emile.ports.prometheus.web;

      exporters = {
        node = {
          enable = true;
          enabledCollectors = [ "systemd" ];
          port = config.emile.ports.prometheus.exporter.node;
        };
        systemd = {
          enable = true;
          port = config.emile.ports.prometheus.exporter.systemd;
        };
        smartctl = {
          enable = true;
          port = config.emile.ports.prometheus.exporter.smartctl;
        };
        nginx = {
          enable = true;
          port = config.emile.ports.prometheus.exporter.nginx;
        };
        restic = {
          enable = true;
          # repository = "sftp:u331921@u331921.your-storagebox.de:/home/backup";
          repository = "/mnt/storagebox-bx11/corrino";
          port = config.emile.ports.prometheus.exporter.restic;
          passwordFile = config.age.secrets.restic_password.path;
        };
      };
      scrapeConfigs = [
        {
          job_name = "corrino";
          static_configs = [
            {
              targets = [
                "127.0.0.1:${toString config.services.prometheus.exporters.node.port}"
              ];
            }
            {
              targets = [
                "127.0.0.1:${toString config.services.prometheus.exporters.systemd.port}"
              ];
            }
            {
              targets = [
                "127.0.0.1:${toString config.services.prometheus.exporters.smartctl.port}"
              ];
            }
            {
              targets = [
                "127.0.0.1:${toString config.services.prometheus.exporters.nginx.port}"
              ];
            }
            {
              targets = [
                "127.0.0.1:${toString config.services.prometheus.exporters.restic.port}"
              ];
            }
          ];
        }
        {
          job_name = "lampadas";
          static_configs = [
            { targets = [ "lampadas:9100" ]; }
            { targets = [ "lampadas:9558" ]; }
            { targets = [ "lampadas:9633" ]; }
          ];
        }

        # adding this halts on...
        #
        # "waiting for lock on
        #   /nix/store/bpncr2rkz5larhbw51m4if7bmy0rs1d3-prometheus.yml"
        #
        # no idea why, as this is just another entry in the list and the other
        # two work

        # {
        #   job_name = "mail";
        #   static_configs = [
        #     { targets = [ "mail.emile.space:9002" ]; } # node
        #     { targets = [ "mail.emile.space:9558" ]; } # systemd
        #     { targets = [ "mail.emile.space:9633" ]; } # smartctl
        #     { targets = [ "mail.emile.space:9913" ]; } # nginx
        #     { targets = [ "mail.emile.space:9753" ]; } # restic
        #   ];
        # }
      ];
    };
  };
}