aboutsummaryrefslogtreecommitdiff
path: root/modules/monitoring/default.nix
blob: 68df69b6ec9b9480a95c31c1b3792e48c46e0486 (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
{ self, config, lib, pkgs, ... }:

with self.lib.nginx;
{
  services.prometheus = {
    enable = true;
    enableReload = true;
    retentionTime = "14d";

    listenAddress = "10.10.0.1";
    webExternalUrl = "https://prometheus.vapor.systems";

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

      zfs = {
        enable = true;
      };

      postgres = {
        enable = true;
      };

      nginx = {
        enable = true;
      };
    };

    globalConfig = {
      scrape_interval = "10s";
    };

    scrapeConfigs = [
      { 
        job_name = "node"; 
        static_configs = [
          { targets = [ "localhost:${toString config.services.prometheus.exporters.node.port}" ]; }
        ]; 
      }
      { 
        job_name = "zfs"; 
        static_configs = [
          { targets = [ "localhost:${toString config.services.prometheus.exporters.zfs.port}" ]; }
        ]; 
      }
      { 
        job_name = "postgres"; 
        static_configs = [
          { targets = [ "localhost:${toString config.services.prometheus.exporters.postgres.port}" ]; }
        ]; 
      }
      { 
        job_name = "nginx"; 
        static_configs = [
          { targets = [ "localhost:${toString config.services.prometheus.exporters.nginx.port}" ]; }
        ]; 
      }
      { 
        job_name = "quassel"; 
        static_configs = [
          { targets = [ "localhost:${toString config.services.quassel.settings.metrics.port}" ]; }
        ]; 
      }
    ];
  };

  services.nginx.statusPage = true;

  security.acme.certs = {
    "vapor.systems" = {
      extraDomainNames = [ "*.vapor.systems" ];
    };
  };

  services.nginx = {
    enable = true;
    virtualHosts = {
      "prometheus.vapor.systems" = (proxyDomain "vapor.systems" "http://10.10.0.1:9090/");
    };
  };
}