summaryrefslogtreecommitdiffstats
path: root/usecases/server/monitoring-server.nix
blob: 11237397de615c8a092a989444435bf75bc4a409 (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
inputs:

{ config, ... }:

{
  services.prometheus = {
    enable = true;

    listenAddress = "127.0.0.1";

    retentionTime = "15w";

    scrapeConfigs = [
      {
        job_name = "prometheus";
        static_configs = [
          { targets = [ "localhost:${toString config.services.prometheus.port}" ]; }
        ];
      }

      {
        job_name = "grafana";
        static_configs = [
          { targets = [ "localhost:${toString config.services.grafana.settings.server.http_port}" ]; }
        ];
      }
    ];
  };

  services.grafana = {
    enable = true;

    settings = {
      server.http_addr = config.topology.mainVpn.currentNodeIP;
      server.http_port = 3001;
      analytics.reporting_enabled = false;
    };
  };

  networking.firewall.interfaces.${config.topology.mainVpn.interfaceName}.allowedTCPPorts = [
    config.services.grafana.settings.server.http_port
  ];
}