diff --git a/boxes/copernicus/services/default.nix b/boxes/copernicus/services/default.nix index 777283e..f539ace 100644 --- a/boxes/copernicus/services/default.nix +++ b/boxes/copernicus/services/default.nix @@ -4,5 +4,6 @@ imports = [ ./photoprism.nix ./wireguard.nix + ./grafana.nix ]; } diff --git a/boxes/copernicus/services/grafana.nix b/boxes/copernicus/services/grafana.nix new file mode 100644 index 0000000..e3957f4 --- /dev/null +++ b/boxes/copernicus/services/grafana.nix @@ -0,0 +1,44 @@ +{ lib, config, pkgs, ...}: + +{ + services.grafana = { + enable = true; + settings = { + server = { + http_addr = "10.100.0.2"; + http_port = 9802; + domain = "grafana.beepboop.systems"; + }; + }; + }; + + services.prometheus = { + enable = true; + listenAddress = "10.100.0.2"; + port = 9001; + + exporters = { + node = { + enable = true; + enabledCollectors = [ "systemd" ]; + listenAddress = "10.100.0.2"; + port = 9002; + }; + }; + + scrapeConfigs = [ + { + job_name = "copernicus"; + static_configs = [{ + targets = [ "10.100.0.2:9002" ]; + }]; + } + { + job_name = "netbox"; + static_configs = [{ + targets = [ "10.100.0.1:9002" ]; + }]; + } + ]; + }; +} diff --git a/boxes/netbox/default.nix b/boxes/netbox/default.nix index 67e67e5..52cc8b3 100644 --- a/boxes/netbox/default.nix +++ b/boxes/netbox/default.nix @@ -18,6 +18,8 @@ ./franklincce.nix ./wireguard.nix ./photoprism-bridge.nix + ./grafana-bridge.nix + ./prometheus.nix ]; nix = { diff --git a/boxes/netbox/grafana-bridge.nix b/boxes/netbox/grafana-bridge.nix new file mode 100644 index 0000000..83ce201 --- /dev/null +++ b/boxes/netbox/grafana-bridge.nix @@ -0,0 +1,16 @@ +{ lib, config, pkgs, ... }: +{ + services.nginx.virtualHosts."grafana.beepboop.systems" = { + forceSSL = true; + enableACME = true; + locations."/" = { + proxyPass = "http://10.100.0.2:9802"; + proxyWebsockets = true; + extraConfig = '' + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $host; + proxy_buffering off; + ''; + }; + }; +} diff --git a/boxes/netbox/prometheus.nix b/boxes/netbox/prometheus.nix new file mode 100644 index 0000000..32d5e01 --- /dev/null +++ b/boxes/netbox/prometheus.nix @@ -0,0 +1,13 @@ +{ lib, config, pkgs, ... }: +{ + services.prometheus = { + exporters = { + node = { + enable = true; + enabledCollectors = [ "systemd" ]; + listenAddress = "10.100.0.1"; + port = 9002; + }; + }; + }; +}