From 0aba3aac809fdcdf73f5568fa10747a7c01d048c Mon Sep 17 00:00:00 2001 From: "RingOfStorms (Joshua Bell)" Date: Mon, 23 Jun 2025 22:18:38 -0500 Subject: [PATCH] got grafana working --- hosts/h001/containers/homarr.nix | 17 +------------- hosts/h001/flake.nix | 1 + hosts/h001/mods/default.nix | 2 ++ hosts/h001/mods/monitoring.nix | 32 +++++++++++++++++++++++++ hosts/h001/mods/reporting.nix | 8 +++++++ hosts/h001/nginx.nix | 40 ++++++++++++++++++++++++++++++++ 6 files changed, 84 insertions(+), 16 deletions(-) create mode 100644 hosts/h001/mods/monitoring.nix create mode 100644 hosts/h001/mods/reporting.nix create mode 100644 hosts/h001/nginx.nix diff --git a/hosts/h001/containers/homarr.nix b/hosts/h001/containers/homarr.nix index 29aa69e..9ebed37 100644 --- a/hosts/h001/containers/homarr.nix +++ b/hosts/h001/containers/homarr.nix @@ -23,25 +23,10 @@ in }; }; }; + system.activationScripts."${name}_directories" = '' mkdir -p ${hostDataDir} chown -R root:root ${hostDataDir} chmod -R 777 ${hostDataDir} ''; - - services.nginx.virtualHosts = { - "100.64.0.13" = { - locations."/" = { - return = "301 http://h001.net.joshuabell.xyz"; - }; - }; - "h001.net.joshuabell.xyz" = { - locations = { - "/" = { - proxyWebsockets = true; - proxyPass = "http://127.0.0.1:${builtins.toString v_port}"; - }; - }; - }; - }; } diff --git a/hosts/h001/flake.nix b/hosts/h001/flake.nix index e064c42..109440d 100644 --- a/hosts/h001/flake.nix +++ b/hosts/h001/flake.nix @@ -35,6 +35,7 @@ ./configuration.nix ./hardware-configuration.nix ./mods + ./nginx.nix (import ./containers { inherit inputs; }) ( { config, pkgs, ... }: diff --git a/hosts/h001/mods/default.nix b/hosts/h001/mods/default.nix index 873e964..5d1fb62 100644 --- a/hosts/h001/mods/default.nix +++ b/hosts/h001/mods/default.nix @@ -5,5 +5,7 @@ imports = [ ./adguardhome.nix ./nixarr.nix + ./monitoring.nix + ./reporting.nix ]; } diff --git a/hosts/h001/mods/monitoring.nix b/hosts/h001/mods/monitoring.nix new file mode 100644 index 0000000..04cc962 --- /dev/null +++ b/hosts/h001/mods/monitoring.nix @@ -0,0 +1,32 @@ +{ + ... +}: +{ + config = { + services.prometheus = { + enable = true; + scrapeConfigs = [ + { + job_name = "node"; + static_configs = [ + { targets = [ "localhost:9100" ]; } + ]; + } + ]; + }; + + services.grafana = { + enable = true; + settings = { + server = { + http_port = 3001; + serve_from_sub_path = true; + domain = "h001.net.joshuabell.xyz"; + root_url = "http://h001.net.joshuabell.xyz/grafana/"; + enforce_domain = true; + enable_gzip = true; + }; + }; + }; + }; +} diff --git a/hosts/h001/mods/reporting.nix b/hosts/h001/mods/reporting.nix new file mode 100644 index 0000000..48e19e1 --- /dev/null +++ b/hosts/h001/mods/reporting.nix @@ -0,0 +1,8 @@ +{ + ... +}: +{ + config = { + services.prometheus.exporters.node.enable = true; + }; +} diff --git a/hosts/h001/nginx.nix b/hosts/h001/nginx.nix new file mode 100644 index 0000000..fa0373b --- /dev/null +++ b/hosts/h001/nginx.nix @@ -0,0 +1,40 @@ +{ + ... +}: +let + homarr = { + proxyWebsockets = true; + proxyPass = "http://localhost:7575"; + }; +in +{ + services.nginx.virtualHosts = { + "10.12.14.2" = { + locations = { + "/" = { + return = "301 http://h001.local.joshuabell.xyz"; + }; + }; + }; + "h001.local.joshuabell.xyz" = { + locations = { + "/" = homarr; + }; + }; + "100.64.0.13" = { + locations."/" = { + return = "301 http://h001.net.joshuabell.xyz"; + }; + }; + "h001.net.joshuabell.xyz" = { + locations = { + "/grafana/" = { + proxyPass = "http://localhost:3001"; + proxyWebsockets = true; + recommendedProxySettings = true; + }; + "/" = homarr; + }; + }; + }; +}