summaryrefslogtreecommitdiffstats
path: root/krebs/2configs/shack/influx.nix
blob: efc88f51dd4b1972b2e2be7d01a9f80ce52dc068 (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
{pkgs, ... }: # hostname: influx.shack
let
  port = 8086;
  collectd-port = 25826;
  db = "collectd_db";
in
{
  networking.firewall.allowedTCPPorts = [ port ]; # for legacy applications
  networking.firewall.allowedUDPPorts = [ collectd-port ];
  services.nginx.virtualHosts."influx.shack" = {
    # Disable constant GET request logging.
    # $loggable map is defined in 1/wolf
    extraConfig = ''
      access_log syslog:server=unix:/dev/log combined if=$loggable;
    '';
    locations."/" = {
      proxyPass = "http://localhost:${toString port}/";
      extraConfig = ''
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header Host             $host;
          proxy_set_header X-Real-IP        $remote_addr;
          proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection "upgrade";

          proxy_buffering off;
      '';
    };
  };
  nixpkgs.overlays = [ 
    (self: super:
      {
        # Hotfix for https://github.com/NixOS/nixpkgs/issues/157543
        collectd = super.collectd.override { xen = null; };
      }
    )
  ];
  services.influxdb = {
    enable = true;
    extraConfig = {
      http.bind-address = "0.0.0.0:${toString port}";
      http.log-enabled = false;
      http.write-tracing = false;
      http.suppress-write-log = true;
      data.trace-logging-enabled = false;
      data.query-log-enabled = false;
      monitoring.enabled = false;
      collectd = [{
        enabled = true;
        typesdb = "${pkgs.collectd}/share/collectd/types.db";
        database = db;
        bind-address = ":${toString collectd-port}";
      }];
    };
  };
}