From 88498233d362a6d5bb85650c9a8a61bba10f1e38 Mon Sep 17 00:00:00 2001 From: xqtc161 Date: Sat, 30 Mar 2024 22:12:21 +0100 Subject: [PATCH] Some fixups and further config --- hosts/x86_64-linux/seraphim/default.nix | 2 + hosts/x86_64-linux/seraphim/monitoring.nix | 49 ++++++++++++++++++---- 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/hosts/x86_64-linux/seraphim/default.nix b/hosts/x86_64-linux/seraphim/default.nix index eab834c..7c8ec82 100644 --- a/hosts/x86_64-linux/seraphim/default.nix +++ b/hosts/x86_64-linux/seraphim/default.nix @@ -12,6 +12,8 @@ ../../../common inputs.nixos-hardware.nixosModules.common-cpu-intel ../../gc.nix + + ./monitoring.nix ]; nixpkgs.config.allowUnfree = true; nix.settings.experimental-features = ["nix-command" "flakes"]; diff --git a/hosts/x86_64-linux/seraphim/monitoring.nix b/hosts/x86_64-linux/seraphim/monitoring.nix index 6a08f3e..4522431 100644 --- a/hosts/x86_64-linux/seraphim/monitoring.nix +++ b/hosts/x86_64-linux/seraphim/monitoring.nix @@ -1,17 +1,48 @@ -{ config, pkgs, ... }: { - # grafana configuration +{ + config, + pkgs, + ... +}: { + networking.firewall.allowedTCPPorts = [80 443 9001]; services.grafana = { enable = true; - # domain = "grafana"; - port = 2342; - addr = "127.0.0.1"; + settings.server = { + # domain = "grafana.seraphim.fritz.box"; + port = 2342; + addr = "127.0.0.1"; + }; }; - # nginx reverse proxy - services.nginx.virtualHosts.${config.services.grafana.domain} = { + services.prometheus = { + enable = true; + port = 9001; + exporters = { + node = { + enable = true; + enabledCollectors = ["systemd"]; + port = 9002; + }; + }; + scrapeConfigs = [ + { + job_name = "seraphim"; + static_configs = [ + { + targets = ["127.0.0.1:${toString config.services.prometheus.exporters.node.port}"]; + } + ]; + } + ]; + }; + + services.nginx.enable = true; + services.nginx.virtualHosts.${config.services.grafana.settings.server.domain} = { locations."/" = { - proxyPass = "http://127.0.0.1:${toString config.services.grafana.port}"; - proxyWebsockets = true; + extraConfig = '' + proxy_set_header Host $host; + ''; + proxyPass = "http://127.0.0.1:${toString config.services.grafana.port}"; + proxyWebsockets = true; }; }; }