diff --git a/bert/configuration.nix b/bert/configuration.nix index 8004161..b175a80 100644 --- a/bert/configuration.nix +++ b/bert/configuration.nix @@ -5,6 +5,7 @@ [ ./hardware-configuration.nix ./services/http/index.nix + ./services/monitoring.nix ]; # Bootloader diff --git a/bert/services/http/home.chandlerswift.com.nix b/bert/services/http/home.chandlerswift.com.nix index 7cfb495..404673d 100644 --- a/bert/services/http/home.chandlerswift.com.nix +++ b/bert/services/http/home.chandlerswift.com.nix @@ -4,6 +4,7 @@ encode zstd gzip file_server root * /srv/home.chandlerswift.com + reverse_proxy /grafana/* localhost:3000 # hide .git # ??? ''; systemd.tmpfiles.settings."10-home-chandlerswift-com" = { diff --git a/bert/services/http/index.nix b/bert/services/http/index.nix index 8c61469..9c65855 100644 --- a/bert/services/http/index.nix +++ b/bert/services/http/index.nix @@ -8,5 +8,10 @@ services.caddy = { enable = true; email = "chandler@chandlerswift.com"; + globalConfig = '' + servers { + metrics # Enable Prometheus monitoring + } + ''; }; } diff --git a/bert/services/monitoring.nix b/bert/services/monitoring.nix new file mode 100644 index 0000000..8f524c4 --- /dev/null +++ b/bert/services/monitoring.nix @@ -0,0 +1,41 @@ +{ + services.prometheus = { + enable = true; + scrapeConfigs = [ + { + job_name = "caddy"; + static_configs = [{ + targets = [ + "localhost:2019" + ]; + }]; + } + { + job_name = "node"; + static_configs = [{ + targets = [ + "localhost:9100" + ]; + }]; + } + ]; + exporters.node = { + enable = true; + # https://github.com/NixOS/nixpkgs/blob/nixos-24.05/nixos/modules/services/monitoring/prometheus/exporters.nix + enabledCollectors = [ "systemd" ]; + # /nix/store/zgsw0yx18v10xa58psanfabmg95nl2bb-node_exporter-1.8.1/bin/node_exporter --help + # extraFlags = [ "--collector.ethtool" "--collector.softirqs" "--collector.tcpstat" "--collector.wifi" ]; + }; + }; + + services.grafana = { + enable = true; + settings = { + server = { + root_url = "https://home.chandlerswift.com/grafana/"; + serve_from_sub_path = true; + }; + }; + }; + +}